Blender  V2.93
Classes | Macros | Typedefs | Functions | Variables
anim_data.c File Reference
#include "MEM_guardedalloc.h"
#include <string.h>
#include "BKE_action.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_fcurve_driver.h"
#include "BKE_global.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_nla.h"
#include "BKE_node.h"
#include "BKE_report.h"
#include "DNA_ID.h"
#include "DNA_anim_types.h"
#include "DNA_light_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_world_types.h"
#include "BLI_alloca.h"
#include "BLI_dynstr.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DEG_depsgraph.h"
#include "BLO_read_write.h"
#include "RNA_access.h"
#include "CLG_log.h"

Go to the source code of this file.

Classes

struct  AllFCurvesCbWrapper
 

Macros

#define ANIMDATA_IDS_CB(first)
 
#define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type)
 
#define RENAMEFIX_ANIM_IDS(first)
 
#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type)
 

Typedefs

typedef struct AllFCurvesCbWrapper AllFCurvesCbWrapper
 

Functions

bool id_type_can_have_animdata (const short id_type)
 
bool id_can_have_animdata (const ID *id)
 
AnimDataBKE_animdata_from_id (ID *id)
 
AnimDataBKE_animdata_add_id (ID *id)
 
bool BKE_animdata_set_action (ReportList *reports, ID *id, bAction *act)
 
bool BKE_animdata_action_editable (const AnimData *adt)
 
bool BKE_animdata_action_ensure_idroot (const ID *owner, bAction *action)
 
void BKE_animdata_free (ID *id, const bool do_id_user)
 
bool BKE_animdata_id_is_animated (const struct ID *id)
 
void BKE_animdata_foreach_id (AnimData *adt, LibraryForeachIDData *data)
 
AnimDataBKE_animdata_copy (Main *bmain, AnimData *adt, const int flag)
 
bool BKE_animdata_copy_id (Main *bmain, ID *id_to, ID *id_from, const int flag)
 
static void animdata_copy_id_action (Main *bmain, ID *id, const bool set_newid, const bool do_linked_id)
 
void BKE_animdata_copy_id_action (Main *bmain, ID *id)
 
void BKE_animdata_duplicate_id_action (struct Main *bmain, struct ID *id, const eDupli_ID_Flags duplicate_flags)
 
void BKE_animdata_merge_copy (Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers)
 
static bool animpath_matches_basepath (const char path[], const char basepath[])
 
static void animpath_update_basepath (FCurve *fcu, const char *old_basepath, const char *new_basepath)
 
static void action_move_fcurves_by_basepath (bAction *srcAct, bAction *dstAct, const char *src_basepath, const char *dst_basepath)
 
static void animdata_move_drivers_by_basepath (AnimData *srcAdt, AnimData *dstAdt, const char *src_basepath, const char *dst_basepath)
 
void BKE_animdata_transfer_by_basepath (Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths)
 
char * BKE_animdata_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *prop, char *base_path)
 
static bool check_rna_path_is_valid (ID *owner_id, const char *path)
 
static char * rna_path_rename_fix (ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, bool verify_paths)
 
static bool fcurves_path_rename_fix (ID *owner_id, const char *prefix, const char *oldName, const char *newName, const char *oldKey, const char *newKey, ListBase *curves, bool verify_paths)
 
static bool drivers_path_rename_fix (ID *owner_id, ID *ref_id, const char *prefix, const char *oldName, const char *newName, const char *oldKey, const char *newKey, ListBase *curves, bool verify_paths)
 
static bool nlastrips_path_rename_fix (ID *owner_id, const char *prefix, const char *oldName, const char *newName, const char *oldKey, const char *newKey, ListBase *strips, bool verify_paths)
 
char * BKE_animsys_fix_rna_path_rename (ID *owner_id, char *old_path, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
 
void BKE_action_fix_paths_rename (ID *owner_id, bAction *act, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
 
void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
 
static bool fcurves_path_remove_fix (const char *prefix, ListBase *curves)
 
static bool nlastrips_path_remove_fix (const char *prefix, ListBase *strips)
 
bool BKE_animdata_fix_paths_remove (ID *id, const char *prefix)
 
static void fcurves_apply_cb (ID *id, ListBase *fcurves, ID_FCurve_Edit_Callback func, void *user_data)
 
static void nlastrips_apply_all_curves_cb (ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper)
 
static void adt_apply_all_fcurves_cb (ID *id, AnimData *adt, void *wrapper_data)
 
void BKE_fcurves_id_cb (ID *id, ID_FCurve_Edit_Callback func, void *user_data)
 
void BKE_fcurves_main_cb (Main *bmain, ID_FCurve_Edit_Callback func, void *user_data)
 
void BKE_animdata_main_cb (Main *bmain, ID_AnimData_Edit_Callback func, void *user_data)
 
void BKE_animdata_fix_paths_rename_all (ID *ref_id, const char *prefix, const char *oldName, const char *newName)
 
void BKE_animdata_fix_paths_rename_all_ex (Main *bmain, ID *ref_id, const char *prefix, const char *oldName, const char *newName, const int oldSubscript, const int newSubscript, const bool verify_paths)
 
void BKE_animdata_blend_write (BlendWriter *writer, struct AnimData *adt)
 
void BKE_animdata_blend_read_data (BlendDataReader *reader, AnimData *adt)
 
void BKE_animdata_blend_read_lib (BlendLibReader *reader, ID *id, AnimData *adt)
 
void BKE_animdata_blend_read_expand (struct BlendExpander *expander, AnimData *adt)
 

Variables

static CLG_LogRef LOG = {"bke.anim_sys"}
 

Macro Definition Documentation

◆ ANIMDATA_IDS_CB

#define ANIMDATA_IDS_CB (   first)
Value:
for (id = first; id; id = id->next) { \
AnimData *adt = BKE_animdata_from_id(id); \
if (adt) { \
func(id, adt, user_data); \
} \
} \
(void)0
AnimData * BKE_animdata_from_id(ID *id)
Definition: anim_data.c:96
void * user_data
void * next
Definition: DNA_ID.h:274

◆ ANIMDATA_NODETREE_IDS_CB

#define ANIMDATA_NODETREE_IDS_CB (   first,
  NtId_Type 
)
Value:
for (id = first; id; id = id->next) { \
AnimData *adt = BKE_animdata_from_id(id); \
NtId_Type *ntp = (NtId_Type *)id; \
if (ntp->nodetree) { \
AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
if (adt2) { \
func(id, adt2, user_data); \
} \
} \
if (adt) { \
func(id, adt, user_data); \
} \
} \
(void)0
Definition: DNA_ID.h:273

◆ RENAMEFIX_ANIM_IDS

#define RENAMEFIX_ANIM_IDS (   first)
Value:
for (id = first; id; id = id->next) { \
AnimData *adt = BKE_animdata_from_id(id); \
BKE_animdata_fix_paths_rename( \
id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
} \
(void)0

◆ RENAMEFIX_ANIM_NODETREE_IDS

#define RENAMEFIX_ANIM_NODETREE_IDS (   first,
  NtId_Type 
)
Value:
for (id = first; id; id = id->next) { \
AnimData *adt = BKE_animdata_from_id(id); \
NtId_Type *ntp = (NtId_Type *)id; \
if (ntp->nodetree) { \
AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
BKE_animdata_fix_paths_rename((ID *)ntp->nodetree, \
adt2, \
ref_id, \
prefix, \
oldName, \
newName, \
oldSubscript, \
newSubscript, \
verify_paths); \
} \
BKE_animdata_fix_paths_rename( \
id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
} \
(void)0

Typedef Documentation

◆ AllFCurvesCbWrapper

Function Documentation

◆ action_move_fcurves_by_basepath()

static void action_move_fcurves_by_basepath ( bAction srcAct,
bAction dstAct,
const char *  src_basepath,
const char *  dst_basepath 
)
static

◆ adt_apply_all_fcurves_cb()

static void adt_apply_all_fcurves_cb ( ID id,
AnimData adt,
void *  wrapper_data 
)
static

◆ animdata_copy_id_action()

static void animdata_copy_id_action ( Main bmain,
ID id,
const bool  set_newid,
const bool  do_linked_id 
)
static

◆ animdata_move_drivers_by_basepath()

static void animdata_move_drivers_by_basepath ( AnimData srcAdt,
AnimData dstAdt,
const char *  src_basepath,
const char *  dst_basepath 
)
static

◆ animpath_matches_basepath()

static bool animpath_matches_basepath ( const char  path[],
const char  basepath[] 
)
static

Helper heuristic for determining if a path is compatible with the basepath

Parameters
pathFull RNA-path from some data (usually an F-Curve) to compare
basepathShorter path fragment to look for
Returns
Whether there is a match

Definition at line 518 of file anim_data.c.

References STRPREFIX.

Referenced by action_move_fcurves_by_basepath(), animdata_move_drivers_by_basepath(), and animpath_update_basepath().

◆ animpath_update_basepath()

static void animpath_update_basepath ( FCurve fcu,
const char *  old_basepath,
const char *  new_basepath 
)
static

◆ BKE_action_fix_paths_rename()

void BKE_action_fix_paths_rename ( ID owner_id,
bAction act,
const char *  prefix,
const char *  oldName,
const char *  newName,
int  oldSubscript,
int  newSubscript,
bool  verify_paths 
)

◆ BKE_animdata_action_editable()

bool BKE_animdata_action_editable ( const AnimData adt)

Definition at line 201 of file anim_data.c.

References AnimData::actstrip, ADT_NLA_EDIT_ON, AnimData::flag, NULL, and AnimData::tmpact.

Referenced by BKE_animdata_set_action().

◆ BKE_animdata_action_ensure_idroot()

bool BKE_animdata_action_ensure_idroot ( const ID owner,
bAction action 
)

Definition at line 209 of file anim_data.c.

References GS, bAction::idroot, ID::name, and NULL.

Referenced by BKE_animdata_set_action(), and BKE_animdata_transfer_by_basepath().

◆ BKE_animdata_add_id()

AnimData* BKE_animdata_add_id ( ID id)

◆ BKE_animdata_blend_read_data()

void BKE_animdata_blend_read_data ( BlendDataReader reader,
AnimData adt 
)

◆ BKE_animdata_blend_read_expand()

void BKE_animdata_blend_read_expand ( struct BlendExpander expander,
AnimData adt 
)

◆ BKE_animdata_blend_read_lib()

void BKE_animdata_blend_read_lib ( BlendLibReader reader,
ID id,
AnimData adt 
)

◆ BKE_animdata_blend_write()

void BKE_animdata_blend_write ( BlendWriter writer,
struct AnimData adt 
)

◆ BKE_animdata_copy()

AnimData* BKE_animdata_copy ( Main bmain,
AnimData adt,
const int  flag 
)

Make a copy of the given AnimData - to be used when copying data-blocks.

Parameters
flagControl ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h
Returns
The copied animdata.

Definition at line 318 of file anim_data.c.

References AnimData::action, BKE_fcurves_copy(), BKE_id_copy_ex(), BKE_nla_tracks_copy(), BLI_assert, BLI_listbase_clear(), AnimData::driver_array, AnimData::drivers, id_us_plus(), LIB_ID_COPY_ACTIONS, LIB_ID_CREATE_NO_MAIN, LIB_ID_CREATE_NO_USER_REFCOUNT, MEM_dupallocN, AnimData::nla_tracks, NULL, AnimData::overrides, and AnimData::tmpact.

Referenced by BKE_animdata_copy_id(), BKE_libblock_copy_ex(), ED_armature_join_objects_exec(), and ED_gpencil_join_objects_exec().

◆ BKE_animdata_copy_id()

bool BKE_animdata_copy_id ( Main bmain,
ID id_to,
ID id_from,
const int  flag 
)
Parameters
flagControl ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h
Returns
true is successfully copied.

Definition at line 375 of file anim_data.c.

References IdAdtTemplate::adt, BKE_animdata_copy(), BKE_animdata_free(), BKE_animdata_from_id(), GS, LIB_ID_CREATE_NO_USER_REFCOUNT, and ID::name.

Referenced by make_links_data_exec().

◆ BKE_animdata_copy_id_action()

void BKE_animdata_copy_id_action ( Main bmain,
ID id 
)

◆ BKE_animdata_driver_path_hack()

char* BKE_animdata_driver_path_hack ( bContext C,
PointerRNA ptr,
PropertyRNA prop,
char *  base_path 
)

Temporary wrapper for driver operators for buttons to make it easier to create such drivers by rerouting all paths through the active object instead so that they will get picked up by the dependency system.

Parameters
CContext pointer - for getting active data
[in,out]ptrRNA pointer for property's data-block. May be modified as result of path remapping.
propRNA definition of property to add for
Returns
MEM_alloc'd string representing the path to the property from the given PointerRNA

Definition at line 732 of file anim_data.c.

References blender::compositor::area(), C, CTX_data_active_object(), CTX_wm_area(), PointerRNA::data, Object::id, PointerRNA::owner_id, ptr, RNA_path_from_ID_to_property(), RNA_pointer_create(), SPACE_PROPERTIES, and PointerRNA::type.

Referenced by add_driver_button_invoke(), add_driver_button_none(), BKE_fcurve_find_by_rna_context_ui(), copy_driver_button_exec(), driverdropper_sample(), paste_driver_button_exec(), and remove_driver_button_exec().

◆ BKE_animdata_duplicate_id_action()

void BKE_animdata_duplicate_id_action ( struct Main bmain,
struct ID id,
const eDupli_ID_Flags  duplicate_flags 
)

Definition at line 426 of file anim_data.c.

References animdata_copy_id_action(), USER_DUP_ACT, and USER_DUP_LINKED_ID.

◆ BKE_animdata_fix_paths_remove()

bool BKE_animdata_fix_paths_remove ( ID id,
const char *  prefix 
)

◆ BKE_animdata_fix_paths_rename()

void BKE_animdata_fix_paths_rename ( ID owner_id,
AnimData adt,
ID ref_id,
const char *  prefix,
const char *  oldName,
const char *  newName,
int  oldSubscript,
int  newSubscript,
bool  verify_paths 
)

◆ BKE_animdata_fix_paths_rename_all()

void BKE_animdata_fix_paths_rename_all ( ID ref_id,
const char *  prefix,
const char *  oldName,
const char *  newName 
)

◆ BKE_animdata_fix_paths_rename_all_ex()

void BKE_animdata_fix_paths_rename_all_ex ( Main bmain,
ID ref_id,
const char *  prefix,
const char *  oldName,
const char *  newName,
const int  oldSubscript,
const int  newSubscript,
const bool  verify_paths 
)

◆ BKE_animdata_foreach_id()

void BKE_animdata_foreach_id ( AnimData adt,
LibraryForeachIDData data 
)

Callback used by lib_query to walk over all ID usages (mimics foreach_id callback of IDTypeInfo structure).

Definition at line 294 of file anim_data.c.

References AnimData::action, BKE_fcurve_foreach_id(), BKE_LIB_FOREACHID_PROCESS, BKE_nla_strip_foreach_id(), data, AnimData::drivers, IDWALK_CB_USER, LISTBASE_FOREACH, AnimData::nla_tracks, NlaStrip::strips, and AnimData::tmpact.

Referenced by library_foreach_ID_link().

◆ BKE_animdata_free()

void BKE_animdata_free ( ID id,
const bool  do_id_user 
)

◆ BKE_animdata_from_id()

AnimData* BKE_animdata_from_id ( ID id)

Definition at line 96 of file anim_data.c.

References IdAdtTemplate::adt, id_can_have_animdata(), and NULL.

Referenced by achannel_setting_slider_cb(), action_to_animdata(), ANIM_list_elem_update(), ANIM_remove_driver(), animdata_copy_id_action(), animdata_filter_base_is_ok(), animdata_keyframe_list_get(), animfilter_block_data(), animrecord_check_state(), animviz_calc_motionpaths(), BKE_animdata_copy_id(), BKE_animdata_id_is_animated(), BKE_animdata_merge_copy(), BKE_animdata_set_action(), BKE_animdata_transfer_by_basepath(), BKE_animsys_eval_animdata(), BKE_animsys_eval_driver(), BKE_animsys_update_driver_array(), BKE_fcurve_find_by_rna_context_ui(), BKE_fcurves_id_cb(), BKE_library_id_can_use_idtype(), blender::deg::DepsgraphNodeBuilder::build_animdata(), blender::deg::DepsgraphRelationBuilder::build_animdata_curves(), blender::deg::DepsgraphRelationBuilder::build_animdata_drivers(), blender::deg::DepsgraphRelationBuilder::build_copy_on_write_relations(), blender::deg::DepsgraphRelationBuilder::build_driver_relations(), clear_keyframe(), curve_is_animated(), curve_rename_fcurves(), delete_keyframe(), do_graph_region_driver_buttons(), do_version_hue_sat_node(), do_versions_after_linking_250(), do_versions_ipos_to_animato(), draw_fcurve_curve(), ED_curve_updateAnimPaths(), ED_id_action_ensure(), expand_id(), gather_frames_to_render(), gather_frames_to_render_for_id(), id_data_find_fcurve(), id_frame_has_keyframe(), insert_key_button_exec(), insert_keyframe(), ipo_to_animdata(), lib_link_id(), library_foreach_ID_link(), make_local_exec(), make_local_material_tag(), make_new_animlistelem(), mouse_nla_channels(), nlastrips_to_animdata(), ntree_has_drivers(), poseAnim_mapping_refresh(), pyrna_struct_driver_add(), RE_RenderAnim(), remove_sequencer_fcurves(), seq_prefetch_frames(), seq_render_mask(), tag_update_animation_element(), texture_slot_move_exec(), undocurve_from_editcurve(), undocurve_to_editcurve(), and verify_driver_fcurve().

◆ BKE_animdata_id_is_animated()

bool BKE_animdata_id_is_animated ( const struct ID id)

◆ BKE_animdata_main_cb()

void BKE_animdata_main_cb ( Main bmain,
ID_AnimData_Edit_Callback  func,
void *  user_data 
)

◆ BKE_animdata_merge_copy()

void BKE_animdata_merge_copy ( Main bmain,
ID dst_id,
ID src_id,
eAnimData_MergeCopy_Modes  action_mode,
bool  fix_drivers 
)

◆ BKE_animdata_set_action()

bool BKE_animdata_set_action ( ReportList reports,
ID id,
bAction act 
)

Called when user tries to change the active action of an AnimData block (via RNA, Outliner, etc.)

Parameters
reportsCan be NULL.
idThe owner of the animation data
actThe Action to set, or NULL to clear.
Returns
true when the action was successfully updated, false otherwise.

Definition at line 150 of file anim_data.c.

References AnimData::action, BKE_animdata_action_editable(), BKE_animdata_action_ensure_idroot(), BKE_animdata_from_id(), BKE_report(), BKE_reportf(), id, bAction::id, id_us_min(), id_us_plus(), ID::name, NULL, RPT_ERROR, and RPT_WARNING.

Referenced by actionset_id_fn(), unlink_action_fn(), and unlinkact_animdata_fn().

◆ BKE_animdata_transfer_by_basepath()

void BKE_animdata_transfer_by_basepath ( Main bmain,
ID srcID,
ID dstID,
ListBase basepaths 
)

◆ BKE_animsys_fix_rna_path_rename()

char* BKE_animsys_fix_rna_path_rename ( ID owner_id,
char *  old_path,
const char *  prefix,
const char *  oldName,
const char *  newName,
int  oldSubscript,
int  newSubscript,
bool  verify_paths 
)

◆ BKE_fcurves_id_cb()

void BKE_fcurves_id_cb ( ID id,
ID_FCurve_Edit_Callback  func,
void *  user_data 
)

◆ BKE_fcurves_main_cb()

void BKE_fcurves_main_cb ( Main bmain,
ID_FCurve_Edit_Callback  func,
void *  user_data 
)

◆ check_rna_path_is_valid()

static bool check_rna_path_is_valid ( ID owner_id,
const char *  path 
)
static

Definition at line 771 of file anim_data.c.

References NULL, ptr, RNA_id_pointer_create(), and RNA_path_resolve_property().

Referenced by rna_path_rename_fix().

◆ drivers_path_rename_fix()

static bool drivers_path_rename_fix ( ID owner_id,
ID ref_id,
const char *  prefix,
const char *  oldName,
const char *  newName,
const char *  oldKey,
const char *  newKey,
ListBase curves,
bool  verify_paths 
)
static

◆ fcurves_apply_cb()

static void fcurves_apply_cb ( ID id,
ListBase fcurves,
ID_FCurve_Edit_Callback  func,
void *  user_data 
)
static

Definition at line 1227 of file anim_data.c.

References ListBase::first, FCurve::next, and user_data.

Referenced by adt_apply_all_fcurves_cb(), and nlastrips_apply_all_curves_cb().

◆ fcurves_path_remove_fix()

static bool fcurves_path_remove_fix ( const char *  prefix,
ListBase curves 
)
static

◆ fcurves_path_rename_fix()

static bool fcurves_path_rename_fix ( ID owner_id,
const char *  prefix,
const char *  oldName,
const char *  newName,
const char *  oldKey,
const char *  newKey,
ListBase curves,
bool  verify_paths 
)
static

◆ id_can_have_animdata()

bool id_can_have_animdata ( const ID id)

◆ id_type_can_have_animdata()

bool id_type_can_have_animdata ( const short  id_type)

◆ nlastrips_apply_all_curves_cb()

static void nlastrips_apply_all_curves_cb ( ID id,
ListBase strips,
AllFCurvesCbWrapper wrapper 
)
static

◆ nlastrips_path_remove_fix()

static bool nlastrips_path_remove_fix ( const char *  prefix,
ListBase strips 
)
static

◆ nlastrips_path_rename_fix()

static bool nlastrips_path_rename_fix ( ID owner_id,
const char *  prefix,
const char *  oldName,
const char *  newName,
const char *  oldKey,
const char *  newKey,
ListBase strips,
bool  verify_paths 
)
static

◆ rna_path_rename_fix()

static char* rna_path_rename_fix ( ID owner_id,
const char *  prefix,
const char *  oldName,
const char *  newName,
char *  oldpath,
bool  verify_paths 
)
static

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"bke.anim_sys"}
static