60 if (typeinfo !=
NULL) {
135 BKE_report(reports,
RPT_ERROR,
"Cannot change action, as it is still being edited in NLA");
156 "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths "
174 return !is_tweaking_strip;
179 const int idcode =
GS(owner->
name);
181 if (action ==
NULL) {
186 if (action->
idroot == 0) {
192 return (action->
idroot == idcode);
308 else if (do_id_user) {
331 if ((id_to && id_from) && (
GS(id_to->
name) !=
GS(id_from->
name))) {
348 const bool set_newid,
349 const bool do_linked_id)
402 "Merging AnimData blocks while editing NLA is dangerous as it may cause data corruption");
422 if (
src->nla_tracks.first) {
430 if (
src->drivers.first) {
441 for (fcu = drivers.
first; fcu; fcu = fcu->
next) {
447 if (dtar->id == src_id) {
472 return (path && basepath) &&
STRPREFIX(path, basepath);
476 const char *old_basepath,
477 const char *new_basepath)
480 if (
STREQ(old_basepath, new_basepath)) {
497 const char *src_basepath,
498 const char *dst_basepath)
503 if (
ELEM(
NULL, srcAct, dstAct, src_basepath, dst_basepath)) {
506 "srcAct: %p, dstAct: %p, src_basepath: %p, dst_basepath: %p has insufficient "
510 (
void *)src_basepath,
511 (
void *)dst_basepath);
566 for (agrp = srcAct->
groups.
first; agrp; agrp = grp) {
587 const char *src_basepath,
588 const char *dst_basepath)
608 CLOG_ERROR(&
LOG,
"no source or destination ID to separate AnimData with");
628 if (dstAdt->action ==
NULL) {
632 else if (dstAdt->action == srcAdt->
action) {
634 "Argh! Source and Destination share animation! "
635 "('%s' and '%s' both use '%s') Making new empty action",
642 dstAdt->action =
BKE_action_add(bmain, dstAdt->action->id.name + 2);
650 basepath_change->src_basepath,
651 basepath_change->dst_basepath);
659 srcAdt, dstAdt, basepath_change->src_basepath, basepath_change->dst_basepath);
692 char *prefixPtr = strstr(oldpath, prefix);
693 char *oldNamePtr = strstr(oldpath, oldName);
694 int prefixLen = strlen(prefix);
695 int oldNameLen = strlen(oldName);
700 if ((prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr)) {
704 const char *postfixPtr = oldNamePtr + oldNameLen;
705 char *newPath =
NULL;
708 if (prefixPtr > oldpath) {
753 bool is_changed =
false;
755 for (fcu =
curves->first; fcu; fcu = fcu->
next) {
759 const char *old_path = fcu->
rna_path;
762 owner_id, prefix, oldKey, newKey, fcu->
rna_path, verify_paths);
788 bool is_changed =
false;
791 for (fcu =
curves->first; fcu; fcu = fcu->
next) {
794 const char *old_rna_path = fcu->
rna_path;
796 owner_id, prefix, oldKey, newKey, fcu->
rna_path, verify_paths);
797 is_changed |= (fcu->
rna_path != old_rna_path);
809 if (dtar->rna_path && dtar->id) {
810 const char *old_rna_path = dtar->rna_path;
812 dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths);
813 is_changed |= (dtar->rna_path != old_rna_path);
816 if (strstr(prefix,
"bones")) {
817 if (((dtar->id) && (
GS(dtar->id->name) ==
ID_OB) &&
818 (!ref_id || ((
Object *)(dtar->id))->data == ref_id)) &&
819 (dtar->pchan_name[0]) &&
STREQ(oldName, dtar->pchan_name)) {
821 BLI_strncpy(dtar->pchan_name, newName,
sizeof(dtar->pchan_name));
842 bool is_changed =
false;
844 for (strip = strips->
first; strip; strip = strip->
next) {
848 owner_id, prefix, oldName, newName, oldKey, newKey, &strip->
act->
curves, verify_paths);
853 owner_id, prefix, oldName, newName, oldKey, newKey, &strip->
strips, verify_paths);
873 if (
ELEM(
NULL, owner_id, old_path)) {
881 if ((oldName !=
NULL) && (newName !=
NULL)) {
883 const size_t name_old_len = strlen(oldName);
884 const size_t name_new_len = strlen(newName);
885 char *name_old_esc =
BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
886 char *name_new_esc =
BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
900 printf(
"%s | %s | oldpath = %p ", oldN, newN, old_path);
904 printf(
"path rename result = %p\n",
result);
932 if ((oldName !=
NULL) && (newName !=
NULL)) {
934 const size_t name_old_len = strlen(oldName);
935 const size_t name_new_len = strlen(newName);
936 char *name_old_esc =
BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
937 char *name_new_esc =
BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
951 owner_id, prefix, oldName, newName, oldN, newN, &act->
curves, verify_paths);
974 bool is_self_changed =
false;
976 if ((oldName !=
NULL) && (newName !=
NULL)) {
978 const size_t name_old_len = strlen(oldName);
979 const size_t name_new_len = strlen(newName);
980 char *name_old_esc =
BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
981 char *name_new_esc =
BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
995 owner_id, prefix, oldName, newName, oldN, newN, &adt->
action->
curves, verify_paths)) {
1001 owner_id, prefix, oldName, newName, oldN, newN, &adt->
tmpact->
curves, verify_paths)) {
1007 owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->
drivers, verify_paths);
1011 owner_id, prefix, oldName, newName, oldN, newN, &nlt->
strips, verify_paths);
1014 if (is_self_changed) {
1028 bool any_removed =
false;
1034 for (fcu =
curves->first; fcu; fcu = fcn) {
1052 bool any_removed =
false;
1055 for (strip = strips->
first; strip; strip = strip->
next) {
1075 bool any_removed =
false;
1113 for (fcu = fcurves->
first; fcu; fcu = fcu->
next) {
1123 for (strip = strips->
first; strip; strip = strip->
next) {
1182 #define ANIMDATA_IDS_CB(first) \
1183 for (id = first; id; id = id->next) { \
1184 AnimData *adt = BKE_animdata_from_id(id); \
1186 func(id, adt, user_data); \
1192 #define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \
1193 for (id = first; id; id = id->next) { \
1194 AnimData *adt = BKE_animdata_from_id(id); \
1195 NtId_Type *ntp = (NtId_Type *)id; \
1196 if (ntp->nodetree) { \
1197 AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
1199 func(id, adt2, user_data); \
1203 func(id, adt, user_data); \
1289 const char *oldName,
1290 const char *newName)
1292 Main *bmain =
G.main;
1299 const char *oldName,
1300 const char *newName,
1301 const int oldSubscript,
1302 const int newSubscript,
1303 const bool verify_paths)
1313 #define RENAMEFIX_ANIM_IDS(first) \
1314 for (id = first; id; id = id->next) { \
1315 AnimData *adt = BKE_animdata_from_id(id); \
1316 BKE_animdata_fix_paths_rename( \
1317 id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
1322 #define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \
1323 for (id = first; id; id = id->next) { \
1324 AnimData *adt = BKE_animdata_from_id(id); \
1325 NtId_Type *ntp = (NtId_Type *)id; \
1326 if (ntp->nodetree) { \
1327 AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
1328 BKE_animdata_fix_paths_rename((ID *)ntp->nodetree, \
1338 BKE_animdata_fix_paths_rename( \
1339 id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
Blender kernel action and pose functionality.
struct bActionGroup * action_groups_add_new(struct bAction *act, const char name[])
void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu)
void action_groups_clear_tempflags(struct bAction *act)
struct bActionGroup * BKE_action_group_find_name(struct bAction *act, const char name[])
struct bAction * BKE_action_add(struct Main *bmain, const char name[])
void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, struct FCurve *fcurve)
eAnimData_MergeCopy_Modes
void(* ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data)
void(* ID_FCurve_Edit_Callback)(struct ID *id, struct FCurve *fcu, void *user_data)
void BKE_fcurve_blend_write(struct BlendWriter *writer, struct ListBase *fcurves)
void BKE_fcurve_blend_read_data(struct BlendDataReader *reader, struct ListBase *fcurves)
void BKE_fcurve_free(struct FCurve *fcu)
void BKE_fcurve_foreach_id(struct FCurve *fcu, struct LibraryForeachIDData *data)
void BKE_fcurve_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct ListBase *fcurves)
void BKE_fcurve_blend_read_expand(struct BlendExpander *expander, struct ListBase *fcurves)
void BKE_fcurves_free(ListBase *list)
void BKE_fcurves_copy(ListBase *dst, ListBase *src)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
const struct IDTypeInfo * BKE_idtype_get_info_from_idcode(short id_code)
@ IDTYPE_FLAGS_NO_ANIMDATA
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
void id_us_min(struct ID *id)
void id_us_plus(struct ID *id)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag)
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(_data, _func_call)
void BKE_nla_strip_foreach_id(struct NlaStrip *strip, struct LibraryForeachIDData *data)
void BKE_nla_blend_read_data(struct BlendDataReader *reader, struct ListBase *tracks)
void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
void BKE_nla_tracks_copy_from_adt(struct Main *bmain, struct AnimData *adt_dest, const struct AnimData *adt_source, int flag)
void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, const ListBase *src, int flag)
void BKE_nla_blend_write(struct BlendWriter *writer, struct ListBase *tracks)
void BKE_nla_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct ListBase *tracks)
void BKE_nla_blend_read_expand(struct BlendExpander *expander, struct ListBase *tracks)
struct bNodeTree * ntreeFromID(struct ID *id)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_array_alloca(arr, realsize)
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL()
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_expand(expander, id)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
void DEG_id_tag_update(struct ID *id, int flag)
ID and Library types, which are fundamental for sdna.
@ ID_RECALC_COPY_ON_WRITE
#define ID_IS_LINKED(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
#define ID_NEW_SET(_id, _idn)
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
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)
bool BKE_animdata_action_ensure_idroot(const ID *owner, bAction *action)
void BKE_animdata_blend_read_lib(BlendLibReader *reader, ID *id, AnimData *adt)
bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix)
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_merge_copy(Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers)
#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type)
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 check_rna_path_is_valid(ID *owner_id, const char *path)
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 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)
bool id_can_have_animdata(const ID *id)
static bool fcurves_path_remove_fix(const char *prefix, ListBase *curves)
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_foreach_id(AnimData *adt, LibraryForeachIDData *data)
#define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type)
bool id_type_can_have_animdata(const short id_type)
static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data)
static void fcurves_apply_cb(ID *id, ListBase *fcurves, ID_FCurve_Edit_Callback func, void *user_data)
void BKE_animdata_blend_write(BlendWriter *writer, struct AnimData *adt)
void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *user_data)
bool BKE_animdata_action_editable(const AnimData *adt)
struct AllFCurvesCbWrapper AllFCurvesCbWrapper
#define RENAMEFIX_ANIM_IDS(first)
bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
void BKE_fcurves_id_cb(ID *id, ID_FCurve_Edit_Callback func, void *user_data)
bool BKE_animdata_id_is_animated(const struct ID *id)
void BKE_animdata_free(ID *id, const bool do_id_user)
static bool animpath_matches_basepath(const char path[], const char basepath[])
static bool nlastrips_path_remove_fix(const char *prefix, ListBase *strips)
AnimData * BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
void BKE_animdata_duplicate_id_action(struct Main *bmain, struct ID *id, const eDupli_ID_Flags duplicate_flags)
void BKE_animdata_blend_read_data(BlendDataReader *reader, AnimData *adt)
AnimData * BKE_animdata_ensure_id(ID *id)
static void animpath_update_basepath(FCurve *fcu, const char *old_basepath, const char *new_basepath)
void BKE_animdata_blend_read_expand(struct BlendExpander *expander, AnimData *adt)
#define ANIMDATA_IDS_CB(first)
void BKE_animdata_transfer_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths)
void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const char *oldName, const char *newName)
AnimData * BKE_animdata_from_id(const ID *id)
void BKE_fcurves_main_cb(Main *bmain, ID_FCurve_Edit_Callback func, void *user_data)
void BKE_animdata_copy_id_action(Main *bmain, ID *id)
static char * rna_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, bool verify_paths)
static void animdata_move_drivers_by_basepath(AnimData *srcAdt, AnimData *dstAdt, const char *src_basepath, const char *dst_basepath)
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 void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper)
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)
static void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char *src_basepath, const char *dst_basepath)
SyclQueue void void * src
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
ID_FCurve_Edit_Callback func
struct bActionGroup * next