Blender V4.3
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 (FCurveDescriptor fcurve_descriptor) const
 
FCurvefcurve_find (FCurveDescriptor fcurve_descriptor)
 
FCurvefcurve_ensure (Main *bmain, FCurveDescriptor fcurve_descriptor)
 
FCurvefcurve_create_unique (Main *bmain, FCurveDescriptor fcurve_descriptor)
 
void fcurve_append (FCurve &fcurve)
 
bool fcurve_remove (FCurve &fcurve_to_remove)
 
void fcurve_remove_by_index (int64_t fcurve_array_index)
 
bool fcurve_detach (FCurve &fcurve_to_detach)
 
void fcurve_detach_by_index (int64_t fcurve_array_index)
 
void fcurve_move (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_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 (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, 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.

Definition at line 806 of file ANIM_action.hh.

Constructor & Destructor Documentation

◆ ChannelBag() [1/2]

blender::animrig::ChannelBag::ChannelBag ( )
default

◆ 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 1992 of file animrig/intern/action.cc.

References channel_groups().

Referenced by 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 2007 of file animrig/intern/action.cc.

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

Referenced by animchannels_group_channels(), channel_group_ensure(), 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 2052 of file animrig/intern/action.cc.

References channel_group_create(), and channel_group_find().

Referenced by fcurve_create(), and updateDuplicateActionConstraintSettings().

◆ channel_group_find() [1/2]

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

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

References channel_groups().

◆ 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 1968 of file animrig/intern/action.cc.

References channel_groups().

Referenced by channel_group_ensure(), and what_does_obaction().

◆ channel_group_move()

void blender::animrig::ChannelBag::channel_group_move ( 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 2087 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 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 2062 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.

◆ 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 1944 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.

Ownership of the F-Curve is also transferred to the ChannelBag. The F-Curve will not belong to any channel group after appending.

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

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

References fcurve(), ActionChannelBag::fcurve_array, ActionChannelBag::fcurve_array_num, blender::animrig::grow_array_and_append(), and FCurve::grp.

Referenced by blender::animrig::action_fcurve_attach(), blender::animrig::tests::add_fcurve_to_action(), and updateDuplicateActionConstraintSettings().

◆ fcurve_assign_to_channel_group()

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

Assigns the given FCurve to the given channel group.

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

Returns
True on success, false on failure.

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

References blender::animrig::array_shift_range(), bActionGroup::fcurve_range_length, bActionGroup::fcurve_range_start, and FCurve::grp.

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

◆ fcurve_create()

FCurve & blender::animrig::ChannelBag::fcurve_create ( Main * bmain,
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 1710 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, FCurve::flag, and blender::animrig::grow_array_and_insert().

Referenced by fcurve_create_unique(), and fcurve_ensure().

◆ fcurve_create_unique()

FCurve * blender::animrig::ChannelBag::fcurve_create_unique ( Main * bmain,
FCurveDescriptor fcurve_descriptor )

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

Returns
the F-Curve it it 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 1702 of file animrig/intern/action.cc.

References fcurve_create(), and fcurve_find().

Referenced by 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 1773 of file animrig/intern/action.cc.

References fcurve_detach_by_index(), and fcurves().

Referenced by fcurve_remove().

◆ fcurve_detach_by_index()

void blender::animrig::ChannelBag::fcurve_detach_by_index ( int64_t fcurve_array_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 1783 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(), and blender::dna::array::remove_index().

Referenced by fcurve_detach(), and fcurve_remove_by_index().

◆ fcurve_ensure()

FCurve & blender::animrig::ChannelBag::fcurve_ensure ( Main * bmain,
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 1694 of file animrig/intern/action.cc.

References fcurve_create(), and fcurve_find().

Referenced by blender::animrig::action_fcurve_ensure(), and blender::animrig::StripKeyframeData::keyframe_insert().

◆ fcurve_find() [1/2]

FCurve * blender::animrig::ChannelBag::fcurve_find ( FCurveDescriptor fcurve_descriptor)

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

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

◆ fcurve_find() [2/2]

◆ fcurve_move()

void blender::animrig::ChannelBag::fcurve_move ( 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 1812 of file animrig/intern/action.cc.

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

Referenced by 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 fcurve was the last fcurve 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 1752 of file animrig/intern/action.cc.

References BKE_fcurve_free(), and fcurve_detach().

Referenced by animchannels_delete_exec().

◆ fcurve_remove_by_index()

void blender::animrig::ChannelBag::fcurve_remove_by_index ( int64_t fcurve_array_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 1761 of file animrig/intern/action.cc.

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

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

◆ fcurve_ungroup()

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

Removes the 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 2587 of file animrig/intern/action.cc.

References blender::animrig::array_shift_range(), bActionGroup::fcurve_range_length, and FCurve::grp.

◆ fcurves() [1/2]

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

◆ fcurves() [2/2]

◆ fcurves_clear()

void blender::animrig::ChannelBag::fcurves_clear ( )

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