diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_anim_data.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_fcurve.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_data.c | 19 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 35 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_query.c | 35 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 16 |
8 files changed, 84 insertions, 34 deletions
diff --git a/source/blender/blenkernel/BKE_anim_data.h b/source/blender/blenkernel/BKE_anim_data.h index 8809fadd55c..5aeaf4405f5 100644 --- a/source/blender/blenkernel/BKE_anim_data.h +++ b/source/blender/blenkernel/BKE_anim_data.h @@ -32,6 +32,7 @@ extern "C" { struct AnimData; struct ID; +struct LibraryForeachIDData; struct Main; struct ReportList; struct bAction; @@ -58,6 +59,8 @@ void BKE_animdata_free(struct ID *id, const bool do_id_user); /* Return true if the ID-block has non-empty AnimData. */ bool BKE_animdata_id_is_animated(const struct ID *id); +void BKE_animdata_foreach_id(struct AnimData *adt, struct LibraryForeachIDData *data); + /* Copy AnimData */ struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag); diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 21a9b7b8b04..1eb5da974ce 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -37,6 +37,7 @@ struct FModifier; struct AnimData; struct BezTriple; +struct LibraryForeachIDData; struct PathResolvedRNA; struct PointerRNA; struct PropertyRNA; @@ -185,6 +186,8 @@ struct FCurve *copy_fcurve(const struct FCurve *fcu); void free_fcurves(ListBase *list); void copy_fcurves(ListBase *dst, ListBase *src); +void BKE_fcurve_foreach_id(struct FCurve *fcu, struct LibraryForeachIDData *data); + /* find matching F-Curve in the given list of F-Curves */ struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index); diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index e5a77bce0e6..2be8d657bf4 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -29,6 +29,7 @@ extern "C" { #endif struct AnimData; +struct LibraryForeachIDData; struct Main; struct NlaStrip; struct NlaTrack; @@ -63,6 +64,8 @@ struct NlaStrip *BKE_nla_add_soundstrip(struct Main *bmain, struct Scene *scene, struct Speaker *spk); +void BKE_nla_strip_foreach_id(struct NlaStrip *strip, struct LibraryForeachIDData *data); + /* ----------------------------- */ /* API */ diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index bd39ffc65e7..ca58b69689c 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -159,6 +159,10 @@ static void action_foreach_id(ID *id, LibraryForeachIDData *data) { bAction *act = (bAction *)id; + LISTBASE_FOREACH (FCurve *, fcu, &act->curves) { + BKE_fcurve_foreach_id(fcu, data); + } + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { BKE_LIB_FOREACHID_PROCESS(data, marker->camera, IDWALK_CB_NOP); } diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index 02b7763a9b4..726753a4e70 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -32,6 +32,7 @@ #include "BKE_fcurve_driver.h" #include "BKE_global.h" #include "BKE_lib_id.h" +#include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_nla.h" #include "BKE_node.h" @@ -289,6 +290,24 @@ bool BKE_animdata_id_is_animated(const struct ID *id) !BLI_listbase_is_empty(&adt->overrides); } +/** Callback used by lib_query to walk over all ID usages (mimics `foreach_id` callback of + * `IDTypeInfo` structure). */ +void BKE_animdata_foreach_id(AnimData *adt, LibraryForeachIDData *data) +{ + LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) { + BKE_fcurve_foreach_id(fcu, data); + } + + BKE_LIB_FOREACHID_PROCESS(data, adt->action, IDWALK_CB_USER); + BKE_LIB_FOREACHID_PROCESS(data, adt->tmpact, IDWALK_CB_USER); + + LISTBASE_FOREACH (NlaTrack *, nla_track, &adt->nla_tracks) { + LISTBASE_FOREACH (NlaStrip *, nla_strip, &nla_track->strips) { + BKE_nla_strip_foreach_id(nla_strip, data); + } + } +} + /* Copying -------------------------------------------- */ /** 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 */ diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index dca3ea189a8..e425dae3022 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -183,39 +183,6 @@ void BKE_lib_query_idpropertiesForeachIDLink_callback(IDProperty *id_prop, void BKE_LIB_FOREACHID_PROCESS_ID(data, id_prop->data.pointer, IDWALK_CB_USER); } -static void library_foreach_nla_strip(LibraryForeachIDData *data, NlaStrip *strip) -{ - BKE_LIB_FOREACHID_PROCESS(data, strip->act, IDWALK_CB_USER); - - LISTBASE_FOREACH (NlaStrip *, substrip, &strip->strips) { - library_foreach_nla_strip(data, substrip); - } -} - -static void library_foreach_animationData(LibraryForeachIDData *data, AnimData *adt) -{ - LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) { - ChannelDriver *driver = fcu->driver; - - 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; - } - } - - BKE_LIB_FOREACHID_PROCESS(data, adt->action, IDWALK_CB_USER); - BKE_LIB_FOREACHID_PROCESS(data, adt->tmpact, IDWALK_CB_USER); - - LISTBASE_FOREACH (NlaTrack *, nla_track, &adt->nla_tracks) { - LISTBASE_FOREACH (NlaStrip *, nla_strip, &nla_track->strips) { - library_foreach_nla_strip(data, nla_strip); - } - } -} - bool BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp) { /* Needed e.g. for callbacks handling relationships... This call shall be absolutely readonly. */ @@ -342,7 +309,7 @@ static void library_foreach_ID_link(Main *bmain, AnimData *adt = BKE_animdata_from_id(id); if (adt) { - library_foreach_animationData(&data, adt); + BKE_animdata_foreach_id(adt, &data); } const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 6edccbccc76..4ef68b91a84 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -49,6 +49,7 @@ #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_lib_id.h" +#include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_nla.h" #include "BKE_sound.h" @@ -425,6 +426,21 @@ NlaStrip *BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker) return strip; } +/** Callback used by lib_query to walk over all ID usages (mimics `foreach_id` callback of + * `IDTypeInfo` structure). */ +void BKE_nla_strip_foreach_id(NlaStrip *strip, LibraryForeachIDData *data) +{ + BKE_LIB_FOREACHID_PROCESS(data, strip->act, IDWALK_CB_USER); + + LISTBASE_FOREACH (FCurve *, fcu, &strip->fcurves) { + BKE_fcurve_foreach_id(fcu, data); + } + + LISTBASE_FOREACH (NlaStrip *, substrip, &strip->strips) { + BKE_nla_strip_foreach_id(substrip, data); + } +} + /* *************************************************** */ /* NLA Evaluation <-> Editing Stuff */ |