diff options
author | Bastien Montagne <bastien@blender.org> | 2020-05-26 12:53:00 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-05-26 13:33:28 +0300 |
commit | 13b10ab852815861fad656a7ed4c07ffbd5a800c (patch) | |
tree | 490a0f2feb6be4e1ae78f9a007dd3cd09bc196a9 /source/blender/blenkernel/intern/fcurve.c | |
parent | 825d5c9992b2698d0e38cfec952593b0b15caa18 (diff) |
Fix/refactor foreach_id handling of animdata.
Now callbacks for animdata, nla strip and fcurve are in their own proper
BKE files (mimicking `foreach_id` callback of `IDTypeInfo`).
This commit also fixes some missing handling of ID pointers (text ID and
IDProperties of script fcurve modifier...).
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 5d2207b5b80..d1a3e0f1cea 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -31,6 +31,7 @@ #include "DNA_anim_types.h" #include "DNA_object_types.h" +#include "DNA_text_types.h" #include "BLI_blenlib.h" #include "BLI_easing.h" @@ -43,6 +44,8 @@ #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" #include "BKE_global.h" +#include "BKE_idprop.h" +#include "BKE_lib_query.h" #include "BKE_nla.h" #include "RNA_access.h" @@ -158,6 +161,38 @@ void copy_fcurves(ListBase *dst, ListBase *src) } } +/** Callback used by lib_query to walk over all ID usages (mimics `foreach_id` callback of + * `IDTypeInfo` structure). */ +void BKE_fcurve_foreach_id(FCurve *fcu, LibraryForeachIDData *data) +{ + ChannelDriver *driver = fcu->driver; + + if (driver != NULL) { + LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) { + /* only used targets */ + DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { + BKE_LIB_FOREACHID_PROCESS_ID(data, dtar->id, IDWALK_CB_NOP); + } + DRIVER_TARGETS_LOOPER_END; + } + } + + LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) { + switch (fcm->type) { + case FMODIFIER_TYPE_PYTHON: { + FMod_Python *fcm_py = (FMod_Python *)fcm->data; + BKE_LIB_FOREACHID_PROCESS(data, fcm_py->script, IDWALK_CB_NOP); + + IDP_foreach_property(fcm_py->prop, + IDP_TYPE_FILTER_ID, + BKE_lib_query_idpropertiesForeachIDLink_callback, + data); + break; + } + } + } +} + /* ----------------- Finding F-Curves -------------------------- */ /* high level function to get an fcurve from C without having the rna */ |