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

#include <ANIM_action.hh>

Inherits ActionChannelbag.

Public Member Functions

 Channelbag ()=default
 Channelbag (const Channelbag &other)
 ~Channelbag ()
blender::Span< const FCurve * > fcurves () const
blender::Span< FCurve * > fcurves ()
const FCurvefcurve (int64_t index) const
FCurvefcurve (int64_t index)
const FCurvefcurve_find (const FCurveDescriptor &fcurve_descriptor) const
FCurvefcurve_find (const FCurveDescriptor &fcurve_descriptor)
FCurvefcurve_ensure (Main *bmain, const FCurveDescriptor &fcurve_descriptor)
FCurvefcurve_create_unique (Main *bmain, const FCurveDescriptor &fcurve_descriptor)
Vector< FCurve * > fcurve_create_many (Main *bmain, Span< FCurveDescriptor > fcurve_descriptors)
void fcurve_append (FCurve &fcurve)
bool fcurve_remove (FCurve &fcurve_to_remove)
void fcurve_remove_by_index (int64_t fcurve_index)
bool fcurve_detach (FCurve &fcurve_to_detach)
void fcurve_detach_by_index (int64_t fcurve_index)
void fcurve_move_to_index (FCurve &fcurve, int to_fcurve_index)
void fcurves_clear ()
blender::Span< const bActionGroup * > channel_groups () const
blender::Span< bActionGroup * > channel_groups ()
const bActionGroupchannel_group (int64_t index) const
bActionGroupchannel_group (int64_t index)
const bActionGroupchannel_group_find (StringRef name) const
bActionGroupchannel_group_find (StringRef name)
int channel_group_find_index (const bActionGroup *group) const
int channel_group_containing_index (int fcurve_array_index)
bActionGroupchannel_group_create (StringRefNull name)
bActionGroupchannel_group_ensure (StringRefNull name)
bool channel_group_remove (bActionGroup &group)
void channel_group_move_to_index (bActionGroup &group, int to_group_index)
bool fcurve_assign_to_channel_group (FCurve &fcurve, bActionGroup &to_group)
bool fcurve_ungroup (FCurve &fcurve)

Protected Member Functions

FCurvefcurve_create (Main *bmain, const FCurveDescriptor &fcurve_descriptor)

Additional Inherited Members

Public Attributes inherited from ActionChannelbag
int32_t slot_handle
int group_array_num
struct bActionGroup ** group_array
uint8_t _pad [4]
int fcurve_array_num
struct FCurve ** fcurve_array

Detailed Description

Collection of F-Curves, intended for a specific Slot handle.

In addition to F-Curves, Channelbags can also contain ChannelGroups, which are used to organize F-Curves within the Channelbag (e.g. all F-Curves for a given bone can be put into a ChannelGroup with that bone's name).

See also
ChannelGroup

Definition at line 1061 of file ANIM_action.hh.

Constructor & Destructor Documentation

◆ Channelbag() [1/2]

◆ Channelbag() [2/2]

◆ ~Channelbag()

Member Function Documentation

◆ channel_group() [1/2]

bActionGroup * blender::animrig::Channelbag::channel_group ( int64_t index)

◆ channel_group() [2/2]

◆ channel_group_containing_index()

int blender::animrig::Channelbag::channel_group_containing_index ( int fcurve_array_index)

Find the channel group that contains the fcurve at fcurve_array_index as a member.

Returns
The index of the channel group if found, or -1 if no such group is found.

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

References channel_groups(), and i.

Referenced by Channelbag(), and fcurve_detach_by_index().

◆ channel_group_create()

bActionGroup & blender::animrig::Channelbag::channel_group_create ( StringRefNull name)

Create a new empty channel group with the given name.

The new group is added to the end of the channel group array of the Channelbag.

This function ensures the group has a unique name, and thus the name of the created group may differ from the name parameter.

Returns
A reference to the new channel group.

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

References AGRP_SELECTED, BLI_uniquename_cb(), channel_group(), channel_groups(), bActionGroup::channelbag, DATA_, bActionGroup::fcurve_range_length, bActionGroup::fcurve_range_start, bActionGroup::flag, ActionChannelbag::group_array, ActionChannelbag::group_array_num, blender::animrig::grow_array_and_append(), length(), MEM_callocN(), bActionGroup::name, name, STREQ, STRNCPY_UTF8, and unique_name().

Referenced by animchannels_group_channels(), channel_group_ensure(), Channelbag(), and blender::animrig::convert_to_layered_action().

◆ channel_group_ensure()

bActionGroup & blender::animrig::Channelbag::channel_group_ensure ( StringRefNull name)

Find a channel group with the given name, or if none exists create one.

If a new group is created, it's added to the end of the channel group array of the Channelbag.

Returns
A reference to the channel group.

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

References channel_group_create(), channel_group_find(), and name.

Referenced by Channelbag(), blender::animrig::channelbag_fcurves_move(), copy_animedit_keys(), fcurve_create(), fcurve_create_many(), and update_duplicate_action_constraint_settings().

◆ channel_group_find() [1/2]

bActionGroup * blender::animrig::Channelbag::channel_group_find ( StringRef name)

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

References channel_groups(), and name.

◆ channel_group_find() [2/2]

const bActionGroup * blender::animrig::Channelbag::channel_group_find ( StringRef name) const

Find the first bActionGroup (channel group) with the given name.

Note that channel groups with the same name are allowed, and this simply returns the first match.

If no matching group is found, nullptr is returned.

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

References channel_groups(), and name.

Referenced by animviz_calc_motionpaths(), channel_group_ensure(), Channelbag(), and what_does_obaction().

◆ channel_group_find_index()

int blender::animrig::Channelbag::channel_group_find_index ( const bActionGroup * group) const

Find the index of the channel group.

Returns
The index of the channel group if found, or -1 if no such group is found.

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

References ActionChannelbag::group_array, ActionChannelbag::group_array_num, and i.

Referenced by Channelbag(), and fcurve_create_many().

◆ channel_group_move_to_index()

void blender::animrig::Channelbag::channel_group_move_to_index ( bActionGroup & group,
int to_group_index )

Move the given channel group's to position to_group_index among the channel groups.

The fcurves in the channel group are moved with it, so that membership doesn't change.

group must belong to this channel bag, and to_group_index must be a valid index in the channel group array.

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

References blender::animrig::array_shift_range(), BLI_assert, BLI_assert_msg, channel_groups(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, bActionGroup::fcurve_range_length, bActionGroup::fcurve_range_start, ActionChannelbag::group_array, ActionChannelbag::group_array_num, and size().

Referenced by Channelbag(), and rearrange_layered_action_channel_groups().

◆ channel_group_remove()

bool blender::animrig::Channelbag::channel_group_remove ( bActionGroup & group)

Remove the given channel group from the channel bag.

Any fcurves that were part of this group will me moved to just after all grouped fcurves.

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

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

References blender::animrig::array_shift_range(), BLI_assert, channel_groups(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, bActionGroup::fcurve_range_length, and bActionGroup::fcurve_range_start.

Referenced by Channelbag().

◆ channel_groups() [1/2]

blender::Span< bActionGroup * > blender::animrig::Channelbag::channel_groups ( )

◆ channel_groups() [2/2]

◆ fcurve() [1/2]

FCurve * blender::animrig::Channelbag::fcurve ( int64_t index)

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

References ActionChannelbag::fcurve_array.

◆ fcurve() [2/2]

◆ fcurve_append()

void blender::animrig::Channelbag::fcurve_append ( FCurve & fcurve)

Append an F-Curve to this Channelbag.

This transfers ownership of the F-Curve to this Channelbag, and it is up to the caller to ensure that this is valid (e.g. the F-Curve doesn't also belong to something else).

The F-Curve will not be member of any group after appending.

This is considered a low-level function. Things like depsgraph relations tagging is left to the caller.

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

References fcurve(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, and blender::animrig::grow_array_and_append().

Referenced by blender::animrig::action_fcurve_attach(), blender::animrig::tests::add_fcurve_to_action(), Channelbag(), blender::animrig::channelbag_fcurves_move(), copy_animedit_keys(), and update_duplicate_action_constraint_settings().

◆ fcurve_assign_to_channel_group()

bool blender::animrig::Channelbag::fcurve_assign_to_channel_group ( FCurve & fcurve,
bActionGroup & to_group )

◆ fcurve_create()

FCurve & blender::animrig::Channelbag::fcurve_create ( Main * bmain,
const FCurveDescriptor & fcurve_descriptor )
protected

Create an F-Curve.

Assumes that there is no such F-Curve yet on this Channelbag. If it is uncertain whether this is the case, use fcurve_create_unique() instead.

Parameters
bmainUsed to tag the dependency graph(s) for relationship rebuilding. This is necessary when adding a new F-Curve, as a previously-unanimated depsgraph component may become animated now. Can be nullptr, in which case the tagging is skipped and is left as the responsibility of the caller.

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

References BLI_assert, blender::animrig::FCurveDescriptor::channel_group, channel_group_ensure(), blender::animrig::create_fcurve_for_channel(), DEG_relations_tag_update(), FCURVE_ACTIVE, ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, bActionGroup::fcurve_range_length, bActionGroup::fcurve_range_start, FCurve::flag, and blender::animrig::grow_array_and_insert().

Referenced by Channelbag(), fcurve_create_unique(), and fcurve_ensure().

◆ fcurve_create_many()

Vector< FCurve * > blender::animrig::Channelbag::fcurve_create_many ( Main * bmain,
Span< FCurveDescriptor > fcurve_descriptors )

Create many F-Curves at once.

Conceptually the same as adding many curves in a loop:

Vector<FCurve*> res(fcurve_descriptors.size(), nullptr);
for (int64_t i = 0; i < fcurve_descriptors.size(); i++) {
const FCurveDescriptor &desc = fcurve_descriptors[i];
res[i] = this->fcurve_create_unique(bmain, desc);
}
return res;
long long int int64_t
FCurve * fcurve_create_unique(Main *bmain, const FCurveDescriptor &fcurve_descriptor)
i
Definition text_draw.cc:230

However that is quadratic complexity due to each curve uniqueness check being a linear scan, plus invariants rebuilding after each curve.

Returns
Vector of created F-Curves. Vector size is the same as input span size. A vector element can be nullptr if input descriptor has empty RNA path, or if if such curve already exists.
Parameters
bmainUsed to tag the dependency graph(s) for relationship rebuilding. This is necessary when adding a new F-Curve, as a previously-unanimated depsgraph component may become animated now. Can be nullptr, in which case the tagging is skipped and is left as the responsibility of the caller.

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

References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::animrig::FCurveDescriptor::array_index, blender::animrig::array_shift_range(), BLI_assert, blender::animrig::FCurveDescriptor::channel_group, channel_group_ensure(), channel_group_find_index(), blender::animrig::create_fcurve_for_channel(), DEG_relations_tag_update(), fcurve(), FCURVE_ACTIVE, ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, bActionGroup::fcurve_range_length, bActionGroup::fcurve_range_start, fcurves(), blender::get_default_hash(), ActionChannelbag::group_array, ActionChannelbag::group_array_num, blender::animrig::grow_array(), hash, i, blender::StringRefBase::is_empty(), operator==(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reserve(), blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), blender::animrig::FCurveDescriptor::rna_path, blender::animrig::shrink_array(), and blender::Span< T >::size().

Referenced by Channelbag(), and blender::io::fbx::import_animations().

◆ fcurve_create_unique()

FCurve * blender::animrig::Channelbag::fcurve_create_unique ( Main * bmain,
const FCurveDescriptor & fcurve_descriptor )

Create an F-Curve, but only if it doesn't exist yet in this Channelbag.

Returns
the F-Curve was created, or nullptr if it already existed.
Parameters
bmainUsed to tag the dependency graph(s) for relationship rebuilding. This is necessary when adding a new F-Curve, as a previously-unanimated depsgraph component may become animated now. Can be nullptr, in which case the tagging is skipped and is left as the responsibility of the caller.

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

References fcurve_create(), and fcurve_find().

Referenced by Channelbag(), blender::io::fbx::create_fcurve(), blender::io::usd::create_fcurve(), and blender::animrig::tests::TEST_F().

◆ fcurve_detach()

bool blender::animrig::Channelbag::fcurve_detach ( FCurve & fcurve_to_detach)

Detach an F-Curve from the Channelbag.

Additionally, if the fcurve was the last fcurve in a channel group, that channel group is deleted.

The F-Curve is not freed. After the call returns true, its ownership has transferred to the caller.

Returns
true when the F-Curve was found & detached, false if it wasn't found.
See also
fcurve_remove

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

References fcurve_detach_by_index(), and fcurves().

Referenced by Channelbag(), blender::animrig::channelbag_fcurves_move(), and fcurve_remove().

◆ fcurve_detach_by_index()

void blender::animrig::Channelbag::fcurve_detach_by_index ( int64_t fcurve_index)

Detach an F-Curve from the Channelbag, identified by its index in the array.

Acts the same as fcurve_detach() except it's a bit more efficient as it doesn't need to find the F-Curve in the array first.

See also
fcurve_detach

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

References BLI_assert, channel_group(), channel_group_containing_index(), channel_groups(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, blender::animrig::fcurve_ptr_noop_destructor(), bActionGroup::fcurve_range_length, and blender::dna::array::remove_index().

Referenced by Channelbag(), fcurve_detach(), and fcurve_remove_by_index().

◆ fcurve_ensure()

FCurve & blender::animrig::Channelbag::fcurve_ensure ( Main * bmain,
const FCurveDescriptor & fcurve_descriptor )

Find an FCurve matching the fcurve descriptor, or create one if it doesn't exist.

Parameters
bmainUsed to tag the dependency graph(s) for relationship rebuilding. This is necessary when adding a new F-Curve, as a previously-unanimated depsgraph component may become animated now. Can be nullptr, in which case the tagging is skipped and is left as the responsibility of the caller.

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

References fcurve_create(), and fcurve_find().

Referenced by blender::animrig::action_fcurve_ensure(), Channelbag(), blender::animrig::StripKeyframeData::keyframe_insert(), blender::ed::animrig::replace_pose_key(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::animrig::tests::TEST_F(), blender::editor::animation::tests::TEST_F(), and blender::editor::animation::tests::TEST_F().

◆ fcurve_find() [1/2]

FCurve * blender::animrig::Channelbag::fcurve_find ( const FCurveDescriptor & fcurve_descriptor)

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

References blender::animrig::fcurve_find(), and fcurves().

◆ fcurve_find() [2/2]

◆ fcurve_move_to_index()

void blender::animrig::Channelbag::fcurve_move_to_index ( FCurve & fcurve,
int to_fcurve_index )

Move the given fcurve to position to_fcurve_index in the fcurve array.

Note: this can indirectly alter channel group memberships, because the channel groups don't change what ranges in the fcurve array they cover.

fcurve must belong to this channel bag, and to_fcurve_index must be a valid index in the fcurve array.

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

References blender::animrig::array_shift_range(), BLI_assert, BLI_assert_msg, fcurve(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, fcurves(), and size().

Referenced by Channelbag(), and rearrange_layered_action_fcurves().

◆ fcurve_remove()

bool blender::animrig::Channelbag::fcurve_remove ( FCurve & fcurve_to_remove)

Remove an F-Curve from the Channelbag.

Additionally, if the F-Curve was the last F-Curve in a channel group, that channel group is also deleted.

After this call, if the F-Curve was found, the reference will no longer be valid, as the curve will have been freed.

Returns
true when the F-Curve was found & removed, false if it wasn't found.
See also
fcurve_detach

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

References BKE_fcurve_free(), and fcurve_detach().

Referenced by animchannels_delete_containers(), Channelbag(), and remove_sequencer_fcurves().

◆ fcurve_remove_by_index()

void blender::animrig::Channelbag::fcurve_remove_by_index ( int64_t fcurve_index)

Remove an F-Curve from the Channelbag, identified by its index in the array.

Acts the same as fcurve_remove() except it's a bit more efficient as it doesn't need to find the F-Curve in the array first.

See also
fcurve_remove

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

References BKE_fcurve_free(), fcurve(), and fcurve_detach_by_index().

Referenced by blender::animrig::legacy::action_fcurves_remove(), and Channelbag().

◆ fcurve_ungroup()

bool blender::animrig::Channelbag::fcurve_ungroup ( FCurve & fcurve)

Removes the given FCurve from the channel group it's in, if any.

As part of removing fcurve from its group, fcurve is moved to the end of the fcurve array. However, if fcurve is already ungrouped then this method is a no-op.

Fails if the fcurve doesn't belong to this channel bag, but otherwise always succeeds.

Returns
True on success, false on failure.

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

References blender::animrig::array_shift_range(), channel_groups(), fcurve(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, bActionGroup::fcurve_range_length, and fcurve_ungroup().

Referenced by Channelbag(), and fcurve_ungroup().

◆ fcurves() [1/2]

blender::Span< FCurve * > blender::animrig::Channelbag::fcurves ( )

◆ fcurves() [2/2]

◆ fcurves_clear()

void blender::animrig::Channelbag::fcurves_clear ( )

Remove all F-Curves from this Channelbag.

Since all channel groups become empty, this also removes all channel groups.

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

References channel_groups(), blender::dna::array::clear(), ActionChannelbag::fcurve_array, ActionChannelbag::fcurve_array_num, and blender::animrig::fcurve_ptr_destructor().

Referenced by Channelbag().


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