Blender V5.0
keyframes_keylist.cc File Reference
#include <algorithm>
#include <cfloat>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <optional>
#include "MEM_guardedalloc.h"
#include "BLI_array.hh"
#include "BLI_bounds_types.hh"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_mask_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "BKE_fcurve.hh"
#include "BKE_grease_pencil.hh"
#include "ED_anim_api.hh"
#include "ED_keyframes_keylist.hh"
#include "SEQ_retiming.hh"
#include "ANIM_action.hh"

Go to the source code of this file.

Classes

struct  GreasePencilCel
struct  AnimKeylist
struct  BezTripleChain
struct  SeqAllocateData

Typedefs

using KeylistCreateColumnFunction = std::function<ActKeyColumn *(void *userdata)>
using KeylistUpdateColumnFunction = std::function<void(ActKeyColumn *, void *)>

Functions

BLI_INLINE bool is_cfra_eq (const float a, const float b)
BLI_INLINE bool is_cfra_lt (const float a, const float b)
AnimKeylistED_keylist_create ()
void ED_keylist_free (AnimKeylist *keylist)
static void keylist_convert_key_columns_to_array (AnimKeylist *keylist)
static void keylist_runtime_update_key_column_next_prev (AnimKeylist *keylist)
static void keylist_runtime_init_listbase (AnimKeylist *keylist)
static void keylist_runtime_init (AnimKeylist *keylist)
static void keylist_reset_last_accessed (AnimKeylist *keylist)
void ED_keylist_prepare_for_direct_access (AnimKeylist *keylist)
static const ActKeyColumnkeylist_find_lower_bound (const AnimKeylist *keylist, const float cfra)
static const ActKeyColumnkeylist_find_upper_bound (const AnimKeylist *keylist, const float cfra)
const ActKeyColumnED_keylist_find_exact (const AnimKeylist *keylist, const float cfra)
const ActKeyColumnED_keylist_find_next (const AnimKeylist *keylist, const float cfra)
const ActKeyColumnED_keylist_find_prev (const AnimKeylist *keylist, const float cfra)
const ActKeyColumnED_keylist_find_closest (const AnimKeylist *keylist, const float cfra)
const ActKeyColumnED_keylist_find_any_between (const AnimKeylist *keylist, const Bounds< float > frame_range)
const ActKeyColumnED_keylist_array (const AnimKeylist *keylist)
int64_t ED_keylist_array_len (const AnimKeylist *keylist)
bool ED_keylist_is_empty (const AnimKeylist *keylist)
const ListBaseED_keylist_listbase (const AnimKeylist *keylist)
static void keylist_first_last (const AnimKeylist *keylist, const ActKeyColumn **first_column, const ActKeyColumn **last_column)
bool ED_keylist_all_keys_frame_range (const AnimKeylist *keylist, Bounds< float > *r_frame_range)
bool ED_keylist_selected_keys_frame_range (const AnimKeylist *keylist, Bounds< float > *r_frame_range)
static eKeyframeHandleDrawOpts bezt_handle_type (const BezTriple *bezt)
static eKeyframeExtremeDrawOpts bezt_extreme_type (const BezTripleChain *chain)
static ActKeyColumnnalloc_ak_bezt (void *data)
static void nupdate_ak_bezt (ActKeyColumn *ak, void *data)
static ActKeyColumnnalloc_ak_cel (void *data)
static void nupdate_ak_cel (ActKeyColumn *ak, void *data)
static ActKeyColumnnalloc_ak_gpframe (void *data)
static void nupdate_ak_gpframe (ActKeyColumn *ak, void *data)
static ActKeyColumnnalloc_ak_seqframe (void *data)
static void nupdate_ak_seqframe (ActKeyColumn *ak, void *data)
static ActKeyColumnnalloc_ak_masklayshape (void *data)
static void nupdate_ak_masklayshape (ActKeyColumn *ak, void *data)
static ActKeyColumnkeylist_find_neighbor_front_to_back (ActKeyColumn *cursor, float cfra)
static ActKeyColumnkeylist_find_neighbor_back_to_front (ActKeyColumn *cursor, float cfra)
static ActKeyColumnkeylist_find_exact_or_neighbor_column (AnimKeylist *keylist, float cfra)
static void keylist_add_or_update_column (AnimKeylist *keylist, float cfra, KeylistCreateColumnFunction create_func, KeylistUpdateColumnFunction update_func, void *userdata)
static void add_bezt_to_keycolumns_list (AnimKeylist *keylist, BezTripleChain *bezt)
static void add_gpframe_to_keycolumns_list (AnimKeylist *keylist, bGPDframe *gpf)
static void add_masklay_to_keycolumns_list (AnimKeylist *keylist, MaskLayerShape *masklay_shape)
static void compute_keyblock_data (ActKeyBlockInfo *info, const BezTriple *prev, const BezTriple *beztn)
static void add_keyblock_info (ActKeyColumn *col, const ActKeyBlockInfo *block)
static void add_bezt_to_keyblocks_list (AnimKeylist *keylist, BezTriple *bezt, const int bezt_len)
static void update_keyblocks (AnimKeylist *keylist, BezTriple *bezt, const int bezt_len)
bool actkeyblock_is_valid (const ActKeyColumn *ac)
int actkeyblock_get_valid_hold (const ActKeyColumn *ac)
void summary_to_keylist (bAnimContext *ac, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
void action_slot_summary_to_keylist (bAnimContext *ac, ID *animated_id, animrig::Action &action, const animrig::slot_handle_t slot_handle, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
void scene_to_keylist (bDopeSheet *ads, Scene *sce, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
void ob_to_keylist (bDopeSheet *ads, Object *ob, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
void cachefile_to_keylist (bDopeSheet *ads, CacheFile *cache_file, AnimKeylist *keylist, const int saction_flag)
static void set_up_beztriple_chain (BezTripleChain &chain, const FCurve *fcu, const int key_index, const bool do_extremes, const bool is_cyclic)
void fcurve_to_keylist (AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, blender::float2 range, const bool use_nla_remapping)
void action_group_to_keylist (AnimData *adt, bActionGroup *agrp, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
void action_to_keylist (AnimData *adt, bAction *dna_action, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
void gpencil_to_keylist (bDopeSheet *ads, bGPdata *gpd, AnimKeylist *keylist, const bool active)
void grease_pencil_data_block_to_keylist (AnimData *adt, const GreasePencil *grease_pencil, AnimKeylist *keylist, const int saction_flag, const bool active_layer_only)
void grease_pencil_cels_to_keylist (AnimData *, const GreasePencilLayer *gpl, AnimKeylist *keylist, int)
void grease_pencil_layer_group_to_keylist (AnimData *adt, const GreasePencilLayerTreeGroup *layer_group, AnimKeylist *keylist, const int saction_flag)
void gpl_to_keylist (bDopeSheet *, bGPDlayer *gpl, AnimKeylist *keylist)
void mask_to_keylist (bDopeSheet *, MaskLayer *masklay, AnimKeylist *keylist)
void sequencer_strip_to_keylist (const Strip &strip, AnimKeylist &keylist, Scene &scene)

Variables

static const ActKeyBlockInfo dummy_keyblock = {0}

Typedef Documentation

◆ KeylistCreateColumnFunction

using KeylistCreateColumnFunction = std::function<ActKeyColumn *(void *userdata)>

Definition at line 704 of file keyframes_keylist.cc.

◆ KeylistUpdateColumnFunction

using KeylistUpdateColumnFunction = std::function<void(ActKeyColumn *, void *)>

Definition at line 705 of file keyframes_keylist.cc.

Function Documentation

◆ action_group_to_keylist()

◆ action_slot_summary_to_keylist()

void action_slot_summary_to_keylist ( bAnimContext * ac,
ID * animated_id,
blender::animrig::Action & action,
blender::animrig::slot_handle_t slot_handle,
AnimKeylist * keylist,
int saction_flag,
blender::float2 range )

Generate a summary channel keylist for the specified slot, merging it into keylist.

This filters the keys to be consistent with the visible channels in the editor indicated by ac

Parameters
animated_idthe particular animated ID that the slot summary is being generated for. This is needed for filtering channels based on bone selection, etc. NOTE: despite being passed as a pointer, this should never be null. It's currently passed as a pointer to be defensive because I (Nathan) am not 100% confident at the time of writing (PR #134922) that the callers of this actually guarantee a non-null pointer (they should, but bugs). This way we can assert internally to catch if that ever happens.
actionthe action containing the slot to generate the summary for.
slot_handlethe handle of the slot to generate the summary for.
keylistthe keylist that the generated summary will be merged into.
saction_flagneeded for the SACTION_SHOW_EXTREMES flag, to determine whether to compute and store the data needed to determine which keys are "extremes" (local maxima/minima).
rangeonly keys within this time range will be included in the summary.

Definition at line 1057 of file keyframes_keylist.cc.

References ALE_FCURVE, ANIM_animdata_freelist(), ANIM_animfilter_action_slot(), ANIM_nla_mapping_allowed(), ANIMFILTER_DATA_VISIBLE, BLI_assert, fcurve_to_keylist(), filter, LISTBASE_FOREACH, and blender::animrig::Action::slot_for_handle().

Referenced by actkeys_list_element_to_keylist(), build_channel_keylist(), blender::editor::animation::tests::TEST_F(), and blender::editor::animation::tests::TEST_F().

◆ action_to_keylist()

void action_to_keylist ( AnimData * adt,
bAction * dna_action,
AnimKeylist * keylist,
int saction_flag,
blender::float2 range )

Generate a full list of the keys in dna_action that are within the frame range range.

For layered actions, this is limited to the keys that are for the slot assigned to adt.

Note: this should only be used in places that need or want the full list of keys, without any filtering by e.g. channel selection/visibility, etc. For use cases that need such filtering, use action_slot_summary_to_keylist() instead.

See also
action_slot_summary_to_keylist()

Assumption: the animation is bound to adt->slot_handle. This assumption will break when we have things like reference strips, where the strip can reference another slot handle.

Definition at line 1375 of file keyframes_keylist.cc.

References BLI_assert, bAction::curves, fcurve_to_keylist(), blender::animrig::Action::is_action_legacy(), LISTBASE_FOREACH, and AnimData::slot_handle.

Referenced by actkeys_list_element_to_keylist(), animviz_calc_motionpaths(), build_channel_keylist(), and nla_action_draw_keyframes().

◆ actkeyblock_get_valid_hold()

int actkeyblock_get_valid_hold ( const ActKeyColumn * ac)

Checks if ActKeyColumn can be used as a block (i.e. drawn/used to detect "holds").

Definition at line 996 of file keyframes_keylist.cc.

References ACTKEYBLOCK_FLAG_ANY_HOLD, ACTKEYBLOCK_FLAG_STATIC_HOLD, actkeyblock_is_valid(), ActKeyColumn::block, ActKeyBlockInfo::conflict, and ActKeyBlockInfo::flag.

Referenced by draw_keylist_block().

◆ actkeyblock_is_valid()

bool actkeyblock_is_valid ( const ActKeyColumn * ac)

Checks if ActKeyColumn has any block data.

Definition at line 991 of file keyframes_keylist.cc.

References ActKeyColumn::next, and ActKeyColumn::totblock.

Referenced by actkeyblock_get_valid_hold(), and draw_keylist_block().

◆ add_bezt_to_keyblocks_list()

void add_bezt_to_keyblocks_list ( AnimKeylist * keylist,
BezTriple * bezt,
const int bezt_len )
static

◆ add_bezt_to_keycolumns_list()

void add_bezt_to_keycolumns_list ( AnimKeylist * keylist,
BezTripleChain * bezt )
static

◆ add_gpframe_to_keycolumns_list()

void add_gpframe_to_keycolumns_list ( AnimKeylist * keylist,
bGPDframe * gpf )
static

◆ add_keyblock_info()

void add_keyblock_info ( ActKeyColumn * col,
const ActKeyBlockInfo * block )
static

Definition at line 879 of file keyframes_keylist.cc.

References col, ActKeyBlockInfo::flag, and ActKeyBlockInfo::sel.

Referenced by add_bezt_to_keyblocks_list().

◆ add_masklay_to_keycolumns_list()

void add_masklay_to_keycolumns_list ( AnimKeylist * keylist,
MaskLayerShape * masklay_shape )
static

◆ bezt_extreme_type()

◆ bezt_handle_type()

◆ cachefile_to_keylist()

◆ compute_keyblock_data()

◆ ED_keylist_all_keys_frame_range()

bool ED_keylist_all_keys_frame_range ( const AnimKeylist * keylist,
Bounds< float > * r_frame_range )

◆ ED_keylist_array()

const ActKeyColumn * ED_keylist_array ( const AnimKeylist * keylist)

◆ ED_keylist_array_len()

int64_t ED_keylist_array_len ( const AnimKeylist * keylist)

Definition at line 334 of file keyframes_keylist.cc.

References AnimKeylist::column_len.

Referenced by draw_channel_blocks(), and draw_channel_keys().

◆ ED_keylist_create()

◆ ED_keylist_find_any_between()

◆ ED_keylist_find_closest()

◆ ED_keylist_find_exact()

◆ ED_keylist_find_next()

◆ ED_keylist_find_prev()

◆ ED_keylist_free()

◆ ED_keylist_is_empty()

◆ ED_keylist_listbase()

◆ ED_keylist_prepare_for_direct_access()

◆ ED_keylist_selected_keys_frame_range()

bool ED_keylist_selected_keys_frame_range ( const AnimKeylist * keylist,
blender::Bounds< float > * r_frame_range )

Return the selected key-frame's range. If none are selected, return False and do not affect the frame range.

Definition at line 383 of file keyframes_keylist.cc.

References BLI_assert, ActKeyColumn::cfra, ED_keylist_is_empty(), keylist_first_last(), blender::Bounds< T >::max, blender::Bounds< T >::min, ActKeyColumn::next, ActKeyColumn::prev, ActKeyColumn::sel, and SELECT.

Referenced by animviz_motionpath_compute_range().

◆ fcurve_to_keylist()

void fcurve_to_keylist ( AnimData * adt,
FCurve * fcu,
AnimKeylist * keylist,
int saction_flag,
blender::float2 range,
bool use_nla_remapping )

◆ gpencil_to_keylist()

void gpencil_to_keylist ( bDopeSheet * ads,
bGPdata * gpd,
AnimKeylist * keylist,
const bool active )

◆ gpl_to_keylist()

◆ grease_pencil_cels_to_keylist()

◆ grease_pencil_data_block_to_keylist()

void grease_pencil_data_block_to_keylist ( AnimData * adt,
const GreasePencil * grease_pencil,
AnimKeylist * keylist,
const int saction_flag,
const bool active_layer_only )

◆ grease_pencil_layer_group_to_keylist()

◆ is_cfra_eq()

BLI_INLINE bool is_cfra_eq ( const float a,
const float b )

◆ is_cfra_lt()

◆ keylist_add_or_update_column()

◆ keylist_convert_key_columns_to_array()

void keylist_convert_key_columns_to_array ( AnimKeylist * keylist)
static

◆ keylist_find_exact_or_neighbor_column()

◆ keylist_find_lower_bound()

const ActKeyColumn * keylist_find_lower_bound ( const AnimKeylist * keylist,
const float cfra )
static

◆ keylist_find_neighbor_back_to_front()

ActKeyColumn * keylist_find_neighbor_back_to_front ( ActKeyColumn * cursor,
float cfra )
static

Definition at line 719 of file keyframes_keylist.cc.

References ActKeyColumn::cfra, and ActKeyColumn::prev.

Referenced by keylist_find_exact_or_neighbor_column().

◆ keylist_find_neighbor_front_to_back()

ActKeyColumn * keylist_find_neighbor_front_to_back ( ActKeyColumn * cursor,
float cfra )
static

Definition at line 709 of file keyframes_keylist.cc.

References ActKeyColumn::cfra, and ActKeyColumn::next.

Referenced by keylist_find_exact_or_neighbor_column().

◆ keylist_find_upper_bound()

const ActKeyColumn * keylist_find_upper_bound ( const AnimKeylist * keylist,
const float cfra )
static

◆ keylist_first_last()

void keylist_first_last ( const AnimKeylist * keylist,
const ActKeyColumn ** first_column,
const ActKeyColumn ** last_column )
static

◆ keylist_reset_last_accessed()

void keylist_reset_last_accessed ( AnimKeylist * keylist)
static

◆ keylist_runtime_init()

◆ keylist_runtime_init_listbase()

◆ keylist_runtime_update_key_column_next_prev()

void keylist_runtime_update_key_column_next_prev ( AnimKeylist * keylist)
static

◆ mask_to_keylist()

◆ nalloc_ak_bezt()

◆ nalloc_ak_cel()

◆ nalloc_ak_gpframe()

◆ nalloc_ak_masklayshape()

◆ nalloc_ak_seqframe()

◆ nupdate_ak_bezt()

◆ nupdate_ak_cel()

◆ nupdate_ak_gpframe()

◆ nupdate_ak_masklayshape()

void nupdate_ak_masklayshape ( ActKeyColumn * ak,
void * data )
static

◆ nupdate_ak_seqframe()

void nupdate_ak_seqframe ( ActKeyColumn * ak,
void * data )
static

◆ ob_to_keylist()

◆ scene_to_keylist()

◆ sequencer_strip_to_keylist()

◆ set_up_beztriple_chain()

void set_up_beztriple_chain ( BezTripleChain & chain,
const FCurve * fcu,
const int key_index,
const bool do_extremes,
const bool is_cyclic )
inlinestatic

◆ summary_to_keylist()

◆ update_keyblocks()

void update_keyblocks ( AnimKeylist * keylist,
BezTriple * bezt,
const int bezt_len )
static

Variable Documentation

◆ dummy_keyblock

const ActKeyBlockInfo dummy_keyblock = {0}
static

Definition at line 830 of file keyframes_keylist.cc.

Referenced by add_bezt_to_keyblocks_list().