Blender V5.0
blender::animrig::Action Class Reference

#include <ANIM_action.hh>

Inherits bAction.

Public Member Functions

 Action ()=default
 Action (const Action &other)=delete
bool is_empty () const
bool is_action_legacy () const
bool is_action_layered () const
blender::Span< const Layer * > layers () const
blender::Span< Layer * > layers ()
const Layerlayer (int64_t index) const
Layerlayer (int64_t index)
Layerlayer_add (std::optional< StringRefNull > name)
bool layer_remove (Layer &layer_to_remove)
void layer_keystrip_ensure ()
blender::Span< const Slot * > slots () const
blender::Span< Slot * > slots ()
const Slotslot (int64_t index) const
Slotslot (int64_t index)
Slotslot_for_handle (slot_handle_t handle)
const Slotslot_for_handle (slot_handle_t handle) const
void slot_display_name_set (Main &bmain, Slot &slot, StringRefNull new_display_name)
void slot_display_name_define (Slot &slot, StringRefNull new_display_name)
void slot_idtype_define (Slot &slot, ID_Type idtype)
void slot_identifier_set (Main &bmain, Slot &slot, StringRefNull new_identifier)
void slot_identifier_define (Slot &slot, StringRefNull new_identifier)
void slot_identifier_propagate (Main &bmain, const Slot &slot)
Slotslot_find_by_identifier (StringRefNull slot_identifier)
Slotslot_add ()
Slotslot_add_for_id_type (ID_Type idtype)
Slotslot_add_for_id (const ID &animated_id)
bool slot_remove (Slot &slot_to_remove)
void slot_move_to_index (Slot &slot, int to_slot_index)
void slot_active_set (slot_handle_t slot_handle)
Slotslot_active_get ()
Span< const StripKeyframeData * > strip_keyframe_data () const
Span< StripKeyframeData * > strip_keyframe_data ()
bool is_slot_animated (slot_handle_t slot_handle) const
bool has_keyframes (slot_handle_t action_slot_handle) const ATTR_WARN_UNUSED_RESULT
bool has_single_frame () const ATTR_WARN_UNUSED_RESULT
bool is_cyclic () const ATTR_WARN_UNUSED_RESULT
Layerget_layer_for_keyframing ()
float2 get_frame_range () const ATTR_WARN_UNUSED_RESULT
float2 get_frame_range_of_slot (slot_handle_t slot_handle) const ATTR_WARN_UNUSED_RESULT
float2 get_frame_range_of_keys (bool include_modifiers) const ATTR_WARN_UNUSED_RESULT
void slot_setup_for_id (Slot &slot, const ID &animated_id)

Protected Member Functions

int64_t find_layer_index (const Layer &layer) const
int64_t find_slot_index (const Slot &slot) const
int strip_keyframe_data_append (StripKeyframeData *strip_data)
void strip_keyframe_data_remove_if_unused (int index)

Protected Attributes

friend Strip
friend Layer

Additional Inherited Members

Public Attributes inherited from bAction
ID id
struct ActionLayer ** layer_array
int layer_array_num
int layer_active_index
struct ActionSlot ** slot_array
int slot_array_num
int32_t last_slot_handle
struct ActionStripKeyframeData ** strip_keyframe_data_array
int strip_keyframe_data_array_num
char _pad0 [4]
ListBase curves
ListBase groups
ListBase markers
int flag
int active_marker
int idroot
char _pad1 [4]
float frame_start
float frame_end
PreviewImagepreview

Detailed Description

Container of animation data for one or more animated IDs.

An Action broadly consists of four things:

  1. Layers, which contain Strips.
  2. Strips, which reference StripData.
  3. StripData: Strip{TYPE}Data contains animation data of the given type. For example, StripKeyframeData (currently the only StripData type) contains keyframes.
  4. Slots, which are used as identifiers for subsets of animation data within StripData items.

StripData is not stored in the Strips themselves, but rather is stored separately at the top level of the Action, and each Strip references a StripData item. This allows Strip instancing by having more than one Strip reference the same StripData item.

Each Action has a set of Slots defined at its top level. The animation data within a StripData item is organized into one or more subsets, each of which is marked as being for a different Slot.

For an ID to be animated by an Action, the ID must specify both an Action and a Slot within that Action. The Slot that the ID uses determines which subset of the animation data throughout the Action it is animated by. If an Action but no Slot is specified, the ID is simply not animated.

Note
Temporary limitations: each Action can only contain one Layer, and each Layer can only contain one infinite Strip with no time offset. These limitations will be progressively lifted as we implement layered animation and non-linear animation functionality for Actions in the future. (See: assert_baklava_phase_1_invariants().)
This wrapper class for the bAction DNA struct only has functionality for the layered animation data. The legacy F-Curves (in bAction::curves) and their groups (in bAction::groups) are not managed here.

To continue supporting legacy actions at runtime, there are Action::is_action_legacy() and Action::is_action_layered() that report whether an Action uses that legacy F-Curve data or is instead a layered Action. These methods will eventually be removed when runtime support for legacy actions is fully removed. For code in blend file loading and versioning, which will stick around for the long-term, use animrig::versioning::action_is_layered() instead. (Note that an empty Action is considered both a valid legacy and layered action.)

See also
AnimData::action
AnimData::slot_handle
assert_baklava_phase_1_invariants()
#animrig::versioning::action_is_layered()

Definition at line 94 of file ANIM_action.hh.

Constructor & Destructor Documentation

◆ Action() [1/2]

blender::animrig::Action::Action ( )
default

Referenced by Action(), and slot_for_handle().

◆ Action() [2/2]

blender::animrig::Action::Action ( const Action & other)
delete

Copy constructor is deleted, as code should use regular ID library management functions to duplicate this data-block.

References Action(), ATTR_WARN_UNUSED_RESULT, get_frame_range(), get_frame_range_of_keys(), get_frame_range_of_slot(), get_layer_for_keyframing(), is_cyclic(), Layer, name, slot(), and slot_setup_for_id().

Member Function Documentation

◆ find_layer_index()

int64_t blender::animrig::Action::find_layer_index ( const Layer & layer) const
protected

Return the layer's index, or -1 if not found in this Action.

Definition at line 325 of file animrig/intern/action.cc.

References Layer, layer(), and layers().

Referenced by layer_remove().

◆ find_slot_index()

int64_t blender::animrig::Action::find_slot_index ( const Slot & slot) const
protected

Return the slot's index, or -1 if not found in this Action.

Definition at line 336 of file animrig/intern/action.cc.

References slot(), and slots().

Referenced by slot_remove().

◆ get_frame_range()

float2 blender::animrig::Action::get_frame_range ( ) const

Retrieve the intended playback frame range of the entire Action.

Returns
a tuple (start frame, end frame). This is either the manually set range (if enabled), or the result of a scan of all F-Curves for their first & last frames.
See also
get_frame_range_of_keys()
get_frame_range_of_slot()

Definition at line 802 of file animrig/intern/action.cc.

References ACT_FRAME_RANGE, blender::animrig::legacy::fcurves_all(), bAction::flag, bAction::frame_end, bAction::frame_start, and blender::animrig::get_frame_range_of_fcurves().

Referenced by Action(), draw_nla_main_data(), and blender::animrig::insert_key_layer().

◆ get_frame_range_of_keys()

float2 blender::animrig::Action::get_frame_range_of_keys ( bool include_modifiers) const

Calculate the extents of this Action.

Performs a scan of all F-Curves for their first & last key frames.

Returns
tuple (first key frame, last key frame).

Definition at line 832 of file animrig/intern/action.cc.

References blender::animrig::legacy::fcurves_all(), and blender::animrig::get_frame_range_of_fcurves().

Referenced by Action(), and blender::animrig::tests::TEST_F().

◆ get_frame_range_of_slot()

float2 blender::animrig::Action::get_frame_range_of_slot ( slot_handle_t slot_handle) const

Retrieve the intended playback frame range of a slot.

Returns
a tuple (start frame, end frame). This is either the manually set range (if enabled) of the Action, or the result of a scan of all F-Curves of the slot for their first & last frames.
See also
get_frame_range()

Definition at line 812 of file animrig/intern/action.cc.

References ACT_FRAME_RANGE, blender::animrig::legacy::fcurves_all(), blender::animrig::fcurves_for_action_slot(), bAction::flag, bAction::frame_end, bAction::frame_start, blender::animrig::get_frame_range_of_fcurves(), and is_action_layered().

Referenced by Action().

◆ get_layer_for_keyframing()

Layer * blender::animrig::Action::get_layer_for_keyframing ( )

Get the layer that should be used for user-level keyframe insertion.

Returns
The layer, or nullptr if no layer exists that can currently be used for keyframing (e.g. all layers are locked, once we've implemented locking).

Definition at line 701 of file animrig/intern/action.cc.

References blender::animrig::assert_baklava_phase_1_invariants(), is_empty(), Layer, layer(), and layers().

Referenced by Action(), and blender::animrig::prep_action_layer_for_keying().

◆ has_keyframes()

bool blender::animrig::Action::has_keyframes ( slot_handle_t action_slot_handle) const

Check if the slot with this handle has any keyframes.

If called on a legacy action, action_slot_handle is ignored and the fcurves of the legacy action are checked for keyframes.

See also
is_slot_animated()

Definition at line 736 of file animrig/intern/action.cc.

References bAction::curves, blender::animrig::fcurves_for_action_slot(), is_action_legacy(), and LISTBASE_FOREACH.

Referenced by blender::animrig::legacy::assigned_action_has_keyframes().

◆ has_single_frame()

bool blender::animrig::Action::has_single_frame ( ) const

Return whether the action has one unique point in time keyed.

This is mostly for the pose library, which will have different behavior depending on whether an Action corresponds to a "pose" (one keyframe) or "animation snippet" (multiple keyframes).

Returns
false when there is no keyframe at all or keys on different points in time, true when exactly one point in time is keyed.

Definition at line 756 of file animrig/intern/action.cc.

References compare_ff(), and blender::animrig::legacy::fcurves_all().

◆ is_action_layered()

bool blender::animrig::Action::is_action_layered ( ) const

Return whether this is a layered Action.

  • Animation data is stored in bAction::layer_array.
  • Evaluated for data-blocks based on their slot handle.
Note
An empty Action is valid as both a legacy and layered Action.
This method will be removed when runtime support for legacy Actions is removed, so only use it in such runtime code. See animrig::versioning::action_is_layered() for uses that should stick around for the long term, such as blend file loading and versioning.
See also
#animrig::versioning::action_is_layered()

Definition at line 231 of file animrig/intern/action.cc.

References BLI_listbase_is_empty(), bAction::curves, bAction::groups, bAction::layer_array_num, and bAction::slot_array_num.

Referenced by blender::bke::action_blend_write(), animchannels_delete_containers(), animviz_calc_motionpaths(), BKE_animdata_id_is_animated(), BKE_animsys_evaluate_animdata(), BKE_nla_tweakmode_enter(), BKE_nla_tweakmode_exit(), clear_anim_v3d_exec(), blender::animrig::clear_keyframe(), delete_key_v3d_without_keying_set(), blender::animrig::delete_keyframe(), blender::animrig::fcurve_find_by_rna_path(), blender::animrig::fcurves_for_action_slot(), blender::animrig::fcurves_for_action_slot(), blender::animrig::find_related_action(), blender::animrig::foreach_fcurve_in_action_slot(), get_frame_range_of_slot(), blender::animrig::insert_key_layered_action(), key_data_from_adt(), blender::animrig::prep_action_layer_for_keying(), separate_slots_poll(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), and what_does_obaction().

◆ is_action_legacy()

bool blender::animrig::Action::is_action_legacy ( ) const

Return whether this is a legacy Action.

  • Animation data is stored in bAction::curves.
  • Evaluated equally for all data-blocks that reference this Action.
  • Slot handle is ignored.
Note
An empty Action is valid as both a legacy and layered Action. Code that only supports layered Actions should assert on is_action_layered().
This method will be removed when runtime support for legacy Actions is removed, so only use it in such runtime code. See animrig::versioning::action_is_layered() for uses that should stick around for the long term, such as blend file loading and versioning.
See also
#animrig::versioning::action_is_layered()

Definition at line 226 of file animrig/intern/action.cc.

References bAction::layer_array_num, and bAction::slot_array_num.

Referenced by achannel_is_part_of_disconnected_slot(), blender::animrig::action_fcurve_detach(), blender::animrig::legacy::action_fcurves_remove(), action_to_keylist(), blender::seq::animation_backup_original(), blender::seq::animation_restore_original(), blender::animrig::animdata_fcurve_delete(), animfilter_act_group(), animfilter_action(), animsys_blend_in_action(), animsys_evaluate_action(), blender::animrig::assert_baklava_phase_1_invariants(), blender::animrig::legacy::assigned_action_has_keyframes(), BKE_animdata_id_is_animated(), blender::deg::DepsgraphRelationBuilder::build_animdata_action_targets(), blender::animrig::legacy::channel_groups_all(), blender::animrig::legacy::channel_groups_for_assigned_slot(), blender::animrig::versioning::convert_legacy_animato_action(), blender::animrig::convert_to_layered_action(), ED_anim_ale_fcurve_delete(), ED_curve_updateAnimPaths(), blender::animrig::fcurve_find_in_action(), blender::animrig::fcurve_find_in_action_slot(), blender::animrig::legacy::fcurves_first_slot(), blender::animrig::foreach_fcurve_in_action(), blender::animrig::foreach_fcurve_in_action_slot(), has_keyframes(), merge_actions_selection_exec(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), and update_duplicate_action_constraint_settings().

◆ is_cyclic()

bool blender::animrig::Action::is_cyclic ( ) const

Returns whether this Action is configured as cyclic.

Definition at line 794 of file animrig/intern/action.cc.

References ACT_CYCLIC, ACT_FRAME_RANGE, and bAction::flag.

Referenced by Action(), blender::animrig::insert_key_layer(), and nlastrip_new().

◆ is_empty()

◆ is_slot_animated()

bool blender::animrig::Action::is_slot_animated ( slot_handle_t slot_handle) const

Return whether this Action actually has any animation data for the given slot.

See also
has_keyframes()

Definition at line 626 of file animrig/intern/action.cc.

References blender::animrig::fcurves_for_action_slot(), blender::Span< T >::is_empty(), and blender::animrig::Slot::unassigned.

Referenced by BKE_animdata_id_is_animated().

◆ layer() [1/2]

Layer * blender::animrig::Action::layer ( int64_t index)

Definition at line 253 of file animrig/intern/action.cc.

References Layer, and bAction::layer_array.

◆ layer() [2/2]

◆ layer_add()

Layer & blender::animrig::Action::layer_add ( std::optional< StringRefNull > name)

Create a new layer in this Action.

The new layer is added to the end of the layer array, and will be empty (no strips).

Note
At the time of writing this comment only a single layer per Action is supported in Blender, but this function does NOT enforce that. Be careful!
Parameters
nameThe name to give the new layer. If no name is given, a default name is used. The name may be altered (e.g. appending ".001") to enforce uniqueness within the Action.
Returns
A reference to the newly created layer.
See also
assert_baklava_phase_1_invariants()

Definition at line 258 of file animrig/intern/action.cc.

References blender::animrig::ActionLayer_alloc(), DATA_, blender::animrig::grow_array_and_append(), bAction::idroot, Layer, bAction::layer_active_index, bAction::layer_array, bAction::layer_array_num, ActionLayer::name, name, and STRNCPY_UTF8.

Referenced by blender::animrig::legacy::channelbag_ensure(), blender::animrig::versioning::convert_legacy_animato_action(), blender::animrig::convert_to_layered_action(), blender::ed::animrig::extract_pose(), layer_keystrip_ensure(), separate_slots_exec(), slot_channels_move_to_new_action_exec(), blender::animrig::tests::TEST_F(), and blender::animrig::tests::TEST_F().

◆ layer_keystrip_ensure()

void blender::animrig::Action::layer_keystrip_ensure ( )

◆ layer_remove()

bool blender::animrig::Action::layer_remove ( Layer & layer_to_remove)

Remove the layer from this Action.

After this call, the passed reference is no longer valid, as the memory will have been freed. Any strips on the layer will be freed too.

Returns
true when the layer was found & removed, false if it wasn't found.

Definition at line 288 of file animrig/intern/action.cc.

References find_layer_index(), Layer, bAction::layer_active_index, bAction::layer_array, bAction::layer_array_num, blender::animrig::layer_ptr_destructor(), and blender::dna::array::remove_index().

◆ layers() [1/2]

blender::Span< Layer * > blender::animrig::Action::layers ( )

Definition at line 244 of file animrig/intern/action.cc.

References Layer, bAction::layer_array, and bAction::layer_array_num.

◆ layers() [2/2]

◆ slot() [1/2]

Slot * blender::animrig::Action::slot ( int64_t index)

Definition at line 359 of file animrig/intern/action.cc.

References bAction::slot_array.

◆ slot() [2/2]

◆ slot_active_get()

Slot * blender::animrig::Action::slot_active_get ( )

Get the active Slot.

This requires a linear scan of the slots, to find the one with the 'Active' flag set. Storing this on the Slot itself has the advantage that the 'active' status of a Slot can be determined without requiring access to the owning Action.

As this already does a linear scan for the active slot, the slot is returned as a pointer; obtaining the pointer from a handle would require another linear scan to get the pointer, whereas obtaining the handle from the pointer is a constant operation.

Definition at line 616 of file animrig/intern/action.cc.

References slot(), and slots().

◆ slot_active_set()

void blender::animrig::Action::slot_active_set ( slot_handle_t slot_handle)

Set the active Slot, ensuring only one Slot is flagged as the Active one.

Parameters
slot_handleif #Slot::unassigned, there will not be any active slot. Passing an unknown/invalid slot handle will result in no slot being active.

Definition at line 609 of file animrig/intern/action.cc.

References slot(), and slots().

Referenced by click_select_channel_action_slot(), and mouse_action_keys().

◆ slot_add()

Slot & blender::animrig::Action::slot_add ( )

Create a new Slot.

This method should generally not be used outside of low-level code and legacy action versioning code, because it creates a Slot with an unspecified intended ID type, which should be avoided. Prefer slot_add_for_id_type() and slot_add_for_id() for adding new slots.

TODO: we should probably rename this method to make it clear that it shouldn't be used as the standard way to add a slot.

The slot is given a default name and will be suitable for any ID type. After assigning the slot to an ID, it will be changed to only be suitable for that ID's type.

See also
slot_add_for_id_type()
slot_add_for_id()

Definition at line 503 of file animrig/intern/action.cc.

References ARRAY_SIZE, BLI_strncpy_utf8(), DATA_, blender::animrig::grow_array_and_append(), bAction::idroot, slot(), bAction::slot_array, bAction::slot_array_num, blender::animrig::slot_identifier_ensure_unique(), and STRNCPY_UTF8.

Referenced by blender::animrig::tests::add_fcurve_to_action(), blender::animrig::versioning::convert_legacy_animato_action(), blender::animrig::convert_to_layered_action(), blender::animrig::duplicate_slot(), blender::animrig::move_slot(), slot_add_for_id(), slot_add_for_id_type(), blender::animrig::legacy::slot_ensure(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), and blender::animrig::tests::TEST_F().

◆ slot_add_for_id()

Slot & blender::animrig::Action::slot_add_for_id ( const ID & animated_id)

Create a new, unused Slot suitable for the given ID.

The slot will be named after animated_id.adt.last_slot_identifier, defaulting to the ID's name when that is not set. This is done so that toggling Actions works transparently, when toggling between this and the Action last assigned to the ID.

The slot will only be suitable for the ID's type.

Note that this assigns neither this Action nor the new Slot to the ID. This function merely initializes the Slot itself to suitable values to start animating this ID.

Definition at line 542 of file animrig/intern/action.cc.

References BKE_animdata_from_id(), GS, ActionSlot::idtype, blender::StringRefBase::is_empty(), AnimData::last_slot_identifier, ID::name, slot(), slot_add(), and slot_identifier_define().

Referenced by blender::animrig::assign_action_ensure_slot_for_keying(), BKE_animdata_transfer_by_basepath(), blender::ed::animrig::extract_pose(), blender::bke::greasepencil::convert::AnimDataConvertor::fcurves_convert_finalize(), and blender::animrig::tests::TEST_F().

◆ slot_add_for_id_type()

Slot & blender::animrig::Action::slot_add_for_id_type ( ID_Type idtype)

Create a new, unused Slot for the given ID type.

The returned slot will only be suitable for the specified ID type.

Definition at line 527 of file animrig/intern/action.cc.

References ARRAY_SIZE, BLI_strncpy_utf8(), DATA_, ActionSlot::idtype, slot(), slot_add(), and blender::animrig::slot_identifier_ensure_unique().

Referenced by blender::io::fbx::import_animations().

◆ slot_display_name_define()

void blender::animrig::Action::slot_display_name_define ( Slot & slot,
StringRefNull new_display_name )

Set the slot display name (the part of the identifier after the two-letter ID prefix), and ensure the resulting identifier is unique.

This has to be done on the Action level to ensure each slot has a unique identifier within the Action.

Note
This does NOT propagate the resulting slot identifier to the slot's users.
See also
#Action::slot_display_name_set
#Action::slot_identifier_propagate

Definition at line 409 of file animrig/intern/action.cc.

References ARRAY_SIZE, BLI_assert_msg, BLI_strncpy_utf8(), blender::StringRefNull::c_str(), blender::StringRefBase::size(), size(), slot(), and blender::animrig::slot_identifier_ensure_unique().

Referenced by slot_display_name_set(), and blender::animrig::legacy::slot_ensure().

◆ slot_display_name_set()

void blender::animrig::Action::slot_display_name_set ( Main & bmain,
Slot & slot,
StringRefNull new_display_name )

Set the slot display name (the part of the identifier after the two-letter ID prefix), ensure the resulting identifier is unique, and propagate the new identifier to all data-blocks that use it

This has to be done on the Action level to ensure each slot has a unique identifier within the Action.

See also
#Action::slot_identifier_set

Definition at line 403 of file animrig/intern/action.cc.

References slot(), slot_display_name_define(), and slot_identifier_propagate().

◆ slot_find_by_identifier()

Slot * blender::animrig::Action::slot_find_by_identifier ( StringRefNull slot_identifier)

Return the slot in this action with the given identifier, if any.

Returns
A pointer to the matching slot, or nullptr if no matching slot is found.

Definition at line 479 of file animrig/intern/action.cc.

References blender::StringRefNull::c_str(), slot(), slots(), and STREQ.

Referenced by blender::animrig::generic_slot_for_autoassign().

◆ slot_for_handle() [1/2]

◆ slot_for_handle() [2/2]

const Slot * blender::animrig::Action::slot_for_handle ( slot_handle_t handle) const

Definition at line 370 of file animrig/intern/action.cc.

References slot(), slots(), and blender::animrig::Slot::unassigned.

◆ slot_identifier_define()

void blender::animrig::Action::slot_identifier_define ( Slot & slot,
StringRefNull new_identifier )

Set the slot identifier, and ensure it is unique.

Note
This does NOT ensure the first two characters match the ID type of this slot. This is the caller's responsibility.
See also
#Action::slot_identifier_set
#Action::slot_identifier_propagate

Definition at line 439 of file animrig/intern/action.cc.

References BLI_assert_msg, blender::StringRefNull::c_str(), blender::animrig::Slot::identifier_length_min, size(), slot(), blender::animrig::slot_identifier_ensure_unique(), and STRNCPY_UTF8.

Referenced by blender::animrig::versioning::convert_legacy_animato_action(), blender::io::fbx::import_animations(), slot_add_for_id(), slot_identifier_set(), and blender::animrig::tests::TEST_F().

◆ slot_identifier_propagate()

void blender::animrig::Action::slot_identifier_propagate ( Main & bmain,
const Slot & slot )

Update the AnimData::last_slot_identifier field of any ID that is animated by this Slot.

Should be called after slot_identifier_define(slot). This is implemented as a separate function due to the need to access bmain, which is available in the RNA on-property-update handler, but not in the RNA property setter.

Definition at line 448 of file animrig/intern/action.cc.

References AnimData::action, BKE_animdata_from_id(), FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, bAction::id, id_can_have_animdata(), AnimData::last_slot_identifier, slot(), AnimData::slot_handle, and STRNCPY_UTF8.

Referenced by slot_display_name_set(), and slot_identifier_set().

◆ slot_identifier_set()

void blender::animrig::Action::slot_identifier_set ( Main & bmain,
Slot & slot,
StringRefNull new_identifier )

Set the slot identifier, ensure it is unique, and propagate the new identifier to all data-blocks that use it.

This has to be done on the Action level to ensure each slot has a unique identifier within the Action.

Note
This does NOT ensure the first two characters match the ID type of this slot. This is the caller's responsibility.
See also
#Action::slot_identifier_define
#Action::slot_identifier_propagate

Definition at line 428 of file animrig/intern/action.cc.

References slot(), slot_identifier_define(), and slot_identifier_propagate().

Referenced by convert_action_exec().

◆ slot_idtype_define()

void blender::animrig::Action::slot_idtype_define ( Slot & slot,
ID_Type idtype )

Set the slot's target ID type, updating the identifier prefix to match and ensuring that the resulting identifier is unique.

This has to be done on the Action level to ensure each slot has a unique identifier within the Action.

Note
This does NOT propagate the identifier to the slot's users. That is the caller's responsibility.
See also
#Action::slot_identifier_propagate

Definition at line 421 of file animrig/intern/action.cc.

References slot(), and blender::animrig::slot_identifier_ensure_unique().

◆ slot_move_to_index()

void blender::animrig::Action::slot_move_to_index ( Slot & slot,
int to_slot_index )

Move the given slot to position to_slot_index among the slots of the action.

slot must belong to this action, and to_slot_index must be a valid index in the slot array.

Definition at line 598 of file animrig/intern/action.cc.

References blender::animrig::array_shift_range(), BLI_assert, BLI_assert_msg, slot(), bAction::slot_array, bAction::slot_array_num, and slots().

Referenced by rearrange_layered_action_slots().

◆ slot_remove()

bool blender::animrig::Action::slot_remove ( Slot & slot_to_remove)

Remove a slot, and ALL animation data that belongs to it.

After this call, the reference is no longer valid as the slot will have been freed.

Note that this does NOT unassign this slot from all its users. When the Action is linked into another file, that other file cannot be updated, and so missing slots are something that has to be handled anyway. Also any new slot on this Action will NOT reuse this slot's handle.

Returns
true when the layer was found & removed, false if it wasn't found.

Definition at line 576 of file animrig/intern/action.cc.

References find_slot_index(), ActionSlot::handle, blender::dna::array::remove_index(), bAction::slot_array, bAction::slot_array_num, blender::animrig::slot_ptr_destructor(), and strip_keyframe_data().

Referenced by animchannels_delete_containers(), and blender::animrig::move_slot().

◆ slot_setup_for_id()

void blender::animrig::Action::slot_setup_for_id ( Slot & slot,
const ID & animated_id )

Set the slot's ID type to that of the animated ID, ensure the identifier prefix is set accordingly, and that the identifier is unique within the Action.

This is a low-level function, and shouldn't be called directly outside of the generic slot-assignment functions.

Note
This assumes that the slot has no ID type set yet. If it does, it is considered a bug to call this function.

Definition at line 718 of file animrig/intern/action.cc.

References BLI_assert, GS, ID_IS_EDITABLE, ID_IS_OVERRIDE_LIBRARY, ID::name, and slot().

Referenced by Action(), and blender::animrig::generic_assign_action_slot().

◆ slots() [1/2]

blender::Span< Slot * > blender::animrig::Action::slots ( )

Definition at line 351 of file animrig/intern/action.cc.

References bAction::slot_array, and bAction::slot_array_num.

◆ slots() [2/2]

blender::Span< const Slot * > blender::animrig::Action::slots ( ) const

◆ strip_keyframe_data() [1/2]

Span< StripKeyframeData * > blender::animrig::Action::strip_keyframe_data ( )

◆ strip_keyframe_data() [2/2]

◆ strip_keyframe_data_append()

int blender::animrig::Action::strip_keyframe_data_append ( StripKeyframeData * strip_data)
protected

Append the given StripKeyframeData item to the action's keyframe data array.

Note: this takes ownership of strip_data.

Returns
The index of the appended item in the array.

Definition at line 636 of file animrig/intern/action.cc.

References BLI_assert, blender::animrig::grow_array_and_append(), bAction::strip_keyframe_data_array, and bAction::strip_keyframe_data_array_num.

Referenced by blender::animrig::Strip::create().

◆ strip_keyframe_data_remove_if_unused()

void blender::animrig::Action::strip_keyframe_data_remove_if_unused ( int index)
protected

Remove the keyframe strip data at index if it is no longer used anywhere in the action.

If the strip data is unused, it is both removed from the array and freed. Otherwise no changes are made and the action remains as-is.

Note: this may alter the indices of some strip data items, due to items shifting around to fill the gap left by the removed item. This method ensures that all indices stored within the action (e.g. in the strips themselves) are properly updated to the new values so that everything is still referencing the same data. However, if any indices are stored outside the action, they will no longer be valid.

Definition at line 646 of file animrig/intern/action.cc.

References BLI_assert, Layer, layer(), layers(), blender::animrig::shrink_array_and_swap_remove(), Strip, bAction::strip_keyframe_data_array, and bAction::strip_keyframe_data_array_num.

Referenced by blender::animrig::Layer::strip_remove().

Member Data Documentation

◆ Layer

◆ Strip

friend blender::animrig::Action::Strip
protected

Definition at line 476 of file ANIM_action.hh.

Referenced by strip_keyframe_data_remove_if_unused().


The documentation for this class was generated from the following files: