76 if (typeinfo !=
NULL) {
167 BKE_report(reports,
RPT_ERROR,
"Cannot change action, as it is still being edited in NLA");
188 "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths "
206 return !is_tweaking_strip;
211 const int idcode =
GS(owner->
name);
213 if (action ==
NULL) {
218 if (action->
idroot == 0) {
224 return (action->
idroot == idcode);
351 else if (do_id_user) {
379 if ((id_to && id_from) && (
GS(id_to->
name) !=
GS(id_from->
name))) {
396 const bool set_newid,
397 const bool do_linked_id)
451 "Merging AnimData blocks while editing NLA is dangerous as it may cause data corruption");
490 for (fcu = drivers.
first; fcu; fcu = fcu->
next) {
496 if (dtar->id == src_id) {
521 return (path && basepath) &&
STRPREFIX(path, basepath);
525 const char *old_basepath,
526 const char *new_basepath)
529 if (
STREQ(old_basepath, new_basepath)) {
546 const char *src_basepath,
547 const char *dst_basepath)
552 if (
ELEM(
NULL, srcAct, dstAct, src_basepath, dst_basepath)) {
555 "srcAct: %p, dstAct: %p, src_basepath: %p, dst_basepath: %p has insufficient "
559 (
void *)src_basepath,
560 (
void *)dst_basepath);
615 for (agrp = srcAct->
groups.
first; agrp; agrp = grp) {
636 const char *src_basepath,
637 const char *dst_basepath)
663 CLOG_ERROR(&
LOG,
"no source or destination ID to separate AnimData with");
683 if (dstAdt->action ==
NULL) {
687 else if (dstAdt->action == srcAdt->
action) {
689 "Argh! Source and Destination share animation! "
690 "('%s' and '%s' both use '%s') Making new empty action",
705 basepath_change->src_basepath,
706 basepath_change->dst_basepath);
714 srcAdt, dstAdt, basepath_change->src_basepath, basepath_change->dst_basepath);
742 char *path = basepath;
756 if (basepath != path) {
793 char *prefixPtr = strstr(oldpath, prefix);
794 char *oldNamePtr = strstr(oldpath, oldName);
795 int prefixLen = strlen(prefix);
796 int oldNameLen = strlen(oldName);
801 if ((prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr)) {
805 const char *postfixPtr = oldNamePtr + oldNameLen;
806 char *newPath =
NULL;
809 if (prefixPtr > oldpath) {
854 bool is_changed =
false;
856 for (fcu = curves->
first; fcu; fcu = fcu->
next) {
860 const char *old_path = fcu->
rna_path;
863 owner_id, prefix, oldKey, newKey, fcu->
rna_path, verify_paths);
889 bool is_changed =
false;
892 for (fcu = curves->
first; fcu; fcu = fcu->
next) {
895 const char *old_rna_path = fcu->
rna_path;
897 owner_id, prefix, oldKey, newKey, fcu->
rna_path, verify_paths);
898 is_changed |= (fcu->
rna_path != old_rna_path);
910 if (dtar->rna_path && dtar->id) {
911 const char *old_rna_path = dtar->rna_path;
913 dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths);
914 is_changed |= (dtar->rna_path != old_rna_path);
917 if (strstr(prefix,
"bones")) {
918 if (((dtar->id) && (
GS(dtar->id->name) ==
ID_OB) &&
919 (!ref_id || ((
Object *)(dtar->id))->data == ref_id)) &&
920 (dtar->pchan_name[0]) &&
STREQ(oldName, dtar->pchan_name)) {
922 BLI_strncpy(dtar->pchan_name, newName,
sizeof(dtar->pchan_name));
943 bool is_changed =
false;
945 for (strip = strips->
first; strip; strip = strip->
next) {
949 owner_id, prefix, oldName, newName, oldKey, newKey, &strip->
act->
curves, verify_paths);
954 owner_id, prefix, oldName, newName, oldKey, newKey, &strip->
strips, verify_paths);
982 if (
ELEM(
NULL, owner_id, old_path)) {
990 if ((oldName !=
NULL) && (newName !=
NULL)) {
992 const size_t name_old_len = strlen(oldName);
993 const size_t name_new_len = strlen(newName);
994 char *name_old_esc =
BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
995 char *name_new_esc =
BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
1009 printf(
"%s | %s | oldpath = %p ", oldN, newN, old_path);
1013 printf(
"path rename result = %p\n",
result);
1035 const char *oldName,
1036 const char *newName,
1049 if ((oldName !=
NULL) && (newName !=
NULL)) {
1051 const size_t name_old_len = strlen(oldName);
1052 const size_t name_new_len = strlen(newName);
1053 char *name_old_esc =
BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
1054 char *name_new_esc =
BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
1068 owner_id, prefix, oldName, newName, oldN, newN, &act->
curves, verify_paths);
1083 const char *oldName,
1084 const char *newName,
1095 bool is_self_changed =
false;
1097 if ((oldName !=
NULL) && (newName !=
NULL)) {
1099 const size_t name_old_len = strlen(oldName);
1100 const size_t name_new_len = strlen(newName);
1101 char *name_old_esc =
BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1);
1102 char *name_new_esc =
BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1);
1116 owner_id, prefix, oldName, newName, oldN, newN, &adt->
action->
curves, verify_paths)) {
1122 owner_id, prefix, oldName, newName, oldN, newN, &adt->
tmpact->
curves, verify_paths)) {
1128 owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->
drivers, verify_paths);
1132 owner_id, prefix, oldName, newName, oldN, newN, &nlt->
strips, verify_paths);
1135 if (is_self_changed) {
1149 bool any_removed =
false;
1155 for (fcu = curves->
first; fcu; fcu = fcn) {
1173 bool any_removed =
false;
1176 for (strip = strips->
first; strip; strip = strip->
next) {
1196 bool any_removed =
false;
1234 for (fcu = fcurves->
first; fcu; fcu = fcu->
next) {
1244 for (strip = strips->
first; strip; strip = strip->
next) {
1305 #define ANIMDATA_IDS_CB(first) \
1306 for (id = first; id; id = id->next) { \
1307 AnimData *adt = BKE_animdata_from_id(id); \
1309 func(id, adt, user_data); \
1315 #define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \
1316 for (id = first; id; id = id->next) { \
1317 AnimData *adt = BKE_animdata_from_id(id); \
1318 NtId_Type *ntp = (NtId_Type *)id; \
1319 if (ntp->nodetree) { \
1320 AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
1322 func(id, adt2, user_data); \
1326 func(id, adt, user_data); \
1416 const char *oldName,
1417 const char *newName)
1419 Main *bmain =
G.main;
1431 const char *oldName,
1432 const char *newName,
1433 const int oldSubscript,
1434 const int newSubscript,
1435 const bool verify_paths)
1444 #define RENAMEFIX_ANIM_IDS(first) \
1445 for (id = first; id; id = id->next) { \
1446 AnimData *adt = BKE_animdata_from_id(id); \
1447 BKE_animdata_fix_paths_rename( \
1448 id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, verify_paths); \
1453 #define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \
1454 for (id = first; id; id = id->next) { \
1455 AnimData *adt = BKE_animdata_from_id(id); \
1456 NtId_Type *ntp = (NtId_Type *)id; \
1457 if (ntp->nodetree) { \
1458 AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
1459 BKE_animdata_fix_paths_rename((ID *)ntp->nodetree, \
1469 BKE_animdata_fix_paths_rename( \
1470 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)
struct ScrArea * CTX_wm_area(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
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
@ IDTYPE_FLAGS_NO_ANIMDATA
const struct IDTypeInfo * BKE_idtype_get_info_from_idcode(const short id_code)
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void id_us_min(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, const int flag)
void id_us_plus(struct ID *id)
#define BKE_LIB_FOREACHID_PROCESS(_data, _id_super, _cb_flag)
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_copy(struct Main *bmain, ListBase *dst, ListBase *src, const int flag)
void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
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_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#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()
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
char * BLI_dynstr_get_cstring(DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT 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
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy) ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t 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.
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)
char * BKE_animdata_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *prop, char *base_path)
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_add_id(ID *id)
AnimData * BKE_animdata_from_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)
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)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
char * RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
ID_FCurve_Edit_Callback func
struct bActionGroup * next