Commit: 5508b572ea9bb2d3b758cae6898035005e8ebb2a
Author: Bastien Montagne
Date:   Tue Jun 12 12:28:14 2018 +0200
Branches: master
https://developer.blender.org/rB5508b572ea9bb2d3b758cae6898035005e8ebb2a

Cleanup: remove some G.main from ED's animsys.

The easy ones - there some much, much trickier to tackle there...

===================================================================

M       source/blender/blenkernel/BKE_animsys.h
M       source/blender/blenkernel/intern/anim_sys.c
M       source/blender/blenkernel/intern/library.c
M       source/blender/editors/armature/armature_relations.c
M       source/blender/editors/object/object_add.c
M       source/blender/editors/object/object_relations.c
M       source/blender/editors/space_node/node_group.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_animsys.h 
b/source/blender/blenkernel/BKE_animsys.h
index d25d9c7c2d6..b25f57b4be2 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -74,7 +74,7 @@ struct AnimData *BKE_animdata_copy(struct Main *bmain, struct 
AnimData *adt, con
 bool BKE_animdata_copy_id(struct Main *bmain, struct ID *id_to, struct ID 
*id_from, const bool do_action);
 
 /* Copy AnimData Actions */
-void BKE_animdata_copy_id_action(struct ID *id, const bool set_newid);
+void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id, const bool 
set_newid);
 
 /* Merge copies of data from source AnimData block */
 typedef enum eAnimData_MergeCopy_Modes {
@@ -88,7 +88,9 @@ typedef enum eAnimData_MergeCopy_Modes {
        ADT_MERGECOPY_SRC_REF  = 2
 } eAnimData_MergeCopy_Modes;
 
-void BKE_animdata_merge_copy(struct ID *dst_id, struct ID *src_id, 
eAnimData_MergeCopy_Modes action_mode, bool fix_drivers);
+void BKE_animdata_merge_copy(
+        struct Main *bmain, struct ID *dst_id, struct ID *src_id,
+        eAnimData_MergeCopy_Modes action_mode, bool fix_drivers);
 
 /* ************************************* */
 /* KeyingSets API */
@@ -139,7 +141,8 @@ void BKE_animdata_fix_paths_remove(struct ID *id, const 
char *path);
 /* -------------------------------------- */
 
 /* Move animation data from src to destination if it's paths are based on 
basepaths */
-void BKE_animdata_separate_by_basepath(struct ID *srcID, struct ID *dstID, 
struct ListBase *basepaths);
+void BKE_animdata_separate_by_basepath(
+        struct Main *bmain, struct ID *srcID, struct ID *dstID, struct 
ListBase *basepaths);
 
 /* Move F-Curves from src to destination if it's path is based on basepath */
 void action_move_fcurves_by_basepath(struct bAction *srcAct, struct bAction 
*dstAct, const char basepath[]);
diff --git a/source/blender/blenkernel/intern/anim_sys.c 
b/source/blender/blenkernel/intern/anim_sys.c
index b94bce9baee..96914c8d639 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -314,25 +314,27 @@ bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID 
*id_from, const bool do_act
        return true;
 }
 
-void BKE_animdata_copy_id_action(ID *id, const bool set_newid)
+void BKE_animdata_copy_id_action(Main *bmain, ID *id, const bool set_newid)
 {
        AnimData *adt = BKE_animdata_from_id(id);
        if (adt) {
                if (adt->action) {
                        id_us_min((ID *)adt->action);
-                       adt->action = set_newid ? ID_NEW_SET(adt->action, 
BKE_action_copy(G.main, adt->action)) :
-                                                 BKE_action_copy(G.main, 
adt->action);
+                       adt->action = set_newid ? ID_NEW_SET(adt->action, 
BKE_action_copy(bmain, adt->action)) :
+                                                 BKE_action_copy(bmain, 
adt->action);
                }
                if (adt->tmpact) {
                        id_us_min((ID *)adt->tmpact);
-                       adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, 
BKE_action_copy(G.main, adt->tmpact)) :
-                                                 BKE_action_copy(G.main, 
adt->tmpact);
+                       adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, 
BKE_action_copy(bmain, adt->tmpact)) :
+                                                 BKE_action_copy(bmain, 
adt->tmpact);
                }
        }
 }
 
 /* Merge copies of the data from the src AnimData into the destination 
AnimData */
-void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes 
action_mode, bool fix_drivers)
+void BKE_animdata_merge_copy(
+        Main *bmain, ID *dst_id, ID *src_id,
+        eAnimData_MergeCopy_Modes action_mode, bool fix_drivers)
 {
        AnimData *src = BKE_animdata_from_id(src_id);
        AnimData *dst = BKE_animdata_from_id(dst_id);
@@ -350,8 +352,8 @@ void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, 
eAnimData_MergeCopy_Modes a
        /* handle actions... */
        if (action_mode == ADT_MERGECOPY_SRC_COPY) {
                /* make a copy of the actions */
-               dst->action = BKE_action_copy(G.main, src->action);
-               dst->tmpact = BKE_action_copy(G.main, src->tmpact);
+               dst->action = BKE_action_copy(bmain, src->action);
+               dst->tmpact = BKE_action_copy(bmain, src->tmpact);
        }
        else if (action_mode == ADT_MERGECOPY_SRC_REF) {
                /* make a reference to it */
@@ -366,7 +368,7 @@ void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, 
eAnimData_MergeCopy_Modes a
        if (src->nla_tracks.first) {
                ListBase tracks = {NULL, NULL};
                
-               BKE_nla_tracks_copy(G.main, &tracks, &src->nla_tracks);
+               BKE_nla_tracks_copy(bmain, &tracks, &src->nla_tracks);
                BLI_movelisttolist(&dst->nla_tracks, &tracks);
        }
        
@@ -503,7 +505,8 @@ void action_move_fcurves_by_basepath(bAction *srcAct, 
bAction *dstAct, const cha
  * animation data is based off "basepath", creating new AnimData and
  * associated data as necessary
  */
-void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase 
*basepaths)
+void BKE_animdata_separate_by_basepath(
+        Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths)
 {
        AnimData *srcAdt = NULL, *dstAdt = NULL;
        LinkData *ld;
@@ -529,7 +532,7 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID 
*dstID, ListBase *basepaths
        if (srcAdt->action) {
                /* set up an action if necessary, and name it in a similar way 
so that it can be easily found again */
                if (dstAdt->action == NULL) {
-                       dstAdt->action = BKE_action_add(G.main, 
srcAdt->action->id.name + 2);
+                       dstAdt->action = BKE_action_add(bmain, 
srcAdt->action->id.name + 2);
                }
                else if (dstAdt->action == srcAdt->action) {
                        printf("Argh! Source and Destination share animation! 
('%s' and '%s' both use '%s') Making new empty action\n",
@@ -537,7 +540,7 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID 
*dstID, ListBase *basepaths
                        
                        /* TODO: review this... */
                        id_us_min(&dstAdt->action->id);
-                       dstAdt->action = BKE_action_add(G.main, 
dstAdt->action->id.name + 2);
+                       dstAdt->action = BKE_action_add(bmain, 
dstAdt->action->id.name + 2);
                }
                        
                /* loop over base paths, trying to fix for each one... */
@@ -1074,20 +1077,20 @@ static void adt_apply_all_fcurves_cb(ID *id, AnimData 
*adt, void *wrapper_data)
 }
 
 /* apply the given callback function on all F-Curves attached to data in main 
database */
-void BKE_fcurves_main_cb(Main *mainptr, ID_FCurve_Edit_Callback func, void 
*user_data)
+void BKE_fcurves_main_cb(Main *bmain, ID_FCurve_Edit_Callback func, void 
*user_data)
 {
        /* Wrap F-Curve operation stuff to pass to the general AnimData-level 
func */
        AllFCurvesCbWrapper wrapper = {func, user_data};
        
        /* Use the AnimData-based function so that we don't have to reimplement 
all that stuff */
-       BKE_animdata_main_cb(mainptr, adt_apply_all_fcurves_cb, &wrapper);
+       BKE_animdata_main_cb(bmain, adt_apply_all_fcurves_cb, &wrapper);
 }
 
 
 /* Whole Database Ops -------------------------------------------- */
 
 /* apply the given callback function on all data in main database */
-void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void 
*user_data)
+void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void 
*user_data)
 {
        ID *id;
 
@@ -1111,67 +1114,67 @@ void BKE_animdata_main_cb(Main *mainptr, 
ID_AnimData_Edit_Callback func, void *u
        } (void)0
        
        /* nodes */
-       ANIMDATA_IDS_CB(mainptr->nodetree.first);
+       ANIMDATA_IDS_CB(bmain->nodetree.first);
        
        /* textures */
-       ANIMDATA_NODETREE_IDS_CB(mainptr->tex.first, Tex);
+       ANIMDATA_NODETREE_IDS_CB(bmain->tex.first, Tex);
        
        /* lamps */
-       ANIMDATA_NODETREE_IDS_CB(mainptr->lamp.first, Lamp);
+       ANIMDATA_NODETREE_IDS_CB(bmain->lamp.first, Lamp);
        
        /* materials */
-       ANIMDATA_NODETREE_IDS_CB(mainptr->mat.first, Material);
+       ANIMDATA_NODETREE_IDS_CB(bmain->mat.first, Material);
        
        /* cameras */
-       ANIMDATA_IDS_CB(mainptr->camera.first);
+       ANIMDATA_IDS_CB(bmain->camera.first);
        
        /* shapekeys */
-       ANIMDATA_IDS_CB(mainptr->key.first);
+       ANIMDATA_IDS_CB(bmain->key.first);
        
        /* metaballs */
-       ANIMDATA_IDS_CB(mainptr->mball.first);
+       ANIMDATA_IDS_CB(bmain->mball.first);
        
        /* curves */
-       ANIMDATA_IDS_CB(mainptr->curve.first);
+       ANIMDATA_IDS_CB(bmain->curve.first);
        
        /* armatures */
-       ANIMDATA_IDS_CB(mainptr->armature.first);
+       ANIMDATA_IDS_CB(bmain->armature.first);
        
        /* lattices */
-       ANIMDATA_IDS_CB(mainptr->latt.first);
+       ANIMDATA_IDS_CB(bmain->latt.first);
        
        /* meshes */
-       ANIMDATA_IDS_CB(mainptr->mesh.first);
+       ANIMDATA_IDS_CB(bmain->mesh.first);
        
        /* particles */
-       ANIMDATA_IDS_CB(mainptr->particle.first);
+       ANIMDATA_IDS_CB(bmain->particle.first);
 
        /* speakers */
-       ANIMDATA_IDS_CB(mainptr->speaker.first);
+       ANIMDATA_IDS_CB(bmain->speaker.first);
 
        /* movie clips */
-       ANIMDATA_IDS_CB(mainptr->movieclip.first);
+       ANIMDATA_IDS_CB(bmain->movieclip.first);
 
        /* objects */
-       ANIMDATA_IDS_CB(mainptr->object.first);
+       ANIMDATA_IDS_CB(bmain->object.first);
 
        /* masks */
-       ANIMDATA_IDS_CB(mainptr->mask.first);
+       ANIMDATA_IDS_CB(bmain->mask.first);
        
        /* worlds */
-       ANIMDATA_NODETREE_IDS_CB(mainptr->world.first, World);
+       ANIMDATA_NODETREE_IDS_CB(bmain->world.first, World);
 
        /* scenes */
-       ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene);
+       ANIMDATA_NODETREE_IDS_CB(bmain->scene.first, Scene);
 
        /* line styles */
-       ANIMDATA_IDS_CB(mainptr->linestyle.first);
+       ANIMDATA_IDS_CB(bmain->linestyle.first);
        
        /* grease pencil */
-       ANIMDATA_IDS_CB(mainptr->gpencil.first);
+       ANIMDATA_IDS_CB(bmain->gpencil.first);
 
        /* cache files */
-       ANIMDATA_IDS_CB(mainptr->cachefiles.first);
+       ANIMDATA_IDS_CB(bmain->cachefiles.first);
 }
 
 /* Fix all RNA-Paths throughout the database (directly access the Global.main 
version)
@@ -1181,7 +1184,7 @@ void BKE_animdata_main_cb(Main *mainptr, 
ID_AnimData_Edit_Callback func, void *u
 /* TODO: use BKE_animdata_main_cb for looping over all data  */
 void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const 
char *oldName, const char *newName)
 {
-       Main *mainptr = G.main;
+       Main *bmain = G.main;  /* XXX UGLY! */
        ID *id;
        
        /* macro for less typing 
@@ -1207,67 +1210,67 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, 
const char *prefix, const cha
        } (void)0
        
        /* nodes */
-       RENAMEFIX_ANIM_IDS(mainptr->nodetree.first);
+       RENAMEFIX_ANIM_IDS(bmain->nodetree.first);
        
        /* textures */
-       RENAMEFIX_ANIM_NODETREE_IDS(mainptr->tex.first, Tex);
+       RENAMEFIX_ANIM_NODETREE_IDS(bm

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to