diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_animsys.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 11 |
3 files changed, 24 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 68dd62af179..1bf0164884a 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -94,7 +94,15 @@ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, ch /* Fix all the paths for the entire database... */ void BKE_all_animdata_fix_paths_rename(char *prefix, char *oldName, char *newName); -void BKE_animdata_main_cb(struct Main *main, void (*func)(struct ID *, struct AnimData *, void *), void *user_data); +/* ************************************* */ +/* Batch AnimData API */ + +/* Define for callback looper used in BKE_animdata_main_cb */ +typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data); + + +/* Loop over all datablocks applying callback */ +void BKE_animdata_main_cb(struct Main *main, ID_AnimData_Edit_Callback func, void *user_data); /* ************************************* */ // TODO: overrides, remapping, and path-finding api's diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 81871828af2..bcc25b6a60f 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -422,14 +422,17 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c MEM_freeN(newN); } -void BKE_animdata_main_cb(Main *main, void (*func)(ID *, AnimData *, void *), void *user_data) +/* Whole Database Ops -------------------------------------------- */ + +/* apply the given callback function on all data in main database */ +void BKE_animdata_main_cb (Main *main, ID_AnimData_Edit_Callback func, void *user_data) { ID *id; #define ANIMDATA_IDS_CB(first) \ for (id= first; id; id= id->next) { \ AnimData *adt= BKE_animdata_from_id(id); \ - if(adt) func(id, adt, user_data); \ + if (adt) func(id, adt, user_data); \ } ANIMDATA_IDS_CB(main->nodetree.first); /* nodes */ @@ -450,15 +453,15 @@ void BKE_animdata_main_cb(Main *main, void (*func)(ID *, AnimData *, void *), vo for (id= main->scene.first; id; id= id->next) { AnimData *adt= BKE_animdata_from_id(id); Scene *scene= (Scene *)id; - + /* do compositing nodes first (since these aren't included in main tree) */ if (scene->nodetree) { AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); - if(adt2) func(id, adt2, user_data); + if (adt2) func(id, adt2, user_data); } - + /* now fix scene animation data as per normal */ - if(adt) func((ID *)id, adt, user_data); + if (adt) func((ID *)id, adt, user_data); } } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8512b6315e1..55021ac5e97 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -117,6 +117,7 @@ #include "BKE_idprop.h" #include "BKE_particle.h" #include "BKE_gpencil.h" +#include "BKE_fcurve.h" #define MAX_IDPUP 60 /* was 24 */ @@ -706,16 +707,16 @@ void animdata_dtar_clear_cb(ID *id, AnimData *adt, void *userdata) /* find the driver this belongs to and update it */ for (fcu=adt->drivers.first; fcu; fcu=fcu->next) { driver= fcu->driver; - + if (driver) { DriverVar *dvar; for (dvar= driver->variables.first; dvar; dvar= dvar->next) { - DriverTarget *dtar= &dvar->targets[0]; - int tarIndex= 0; - for (; tarIndex < MAX_DRIVER_TARGETS; tarIndex++, dtar++) { - if(dtar->id == userdata) + DRIVER_TARGETS_USED_LOOPER(dvar) + { + if (dtar->id == userdata) dtar->id= NULL; } + DRIVER_TARGETS_LOOPER_END } } } |