[Bf-blender-cvs] [b3a7a75a266] master: Cleanup: remove moar G.main usages.

Bastien Montagne noreply at git.blender.org
Thu Jun 7 12:48:34 CEST 2018


Commit: b3a7a75a266de6765d8c04953c0dabce3c30c359
Author: Bastien Montagne
Date:   Thu Jun 7 12:47:00 2018 +0200
Branches: master
https://developer.blender.org/rBb3a7a75a266de6765d8c04953c0dabce3c30c359

Cleanup: remove moar G.main usages.

Notes:
* Really need to address RNA setters case, end up adding way too much
G.main here these days... :/
* Added Main pointer into bAnimContext, helps a lot in anim code ;)

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

M	source/blender/collada/AnimationImporter.cpp
M	source/blender/collada/AnimationImporter.h
M	source/blender/collada/DocumentImporter.cpp
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_deps.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/animation/keyframes_general.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/animation/keyingsets.c
M	source/blender/editors/armature/armature_naming.c
M	source/blender/editors/armature/armature_relations.c
M	source/blender/editors/armature/pose_edit.c
M	source/blender/editors/armature/pose_lib.c
M	source/blender/editors/armature/pose_transform.c
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/include/ED_armature.h
M	source/blender/editors/include/ED_keyframing.h
M	source/blender/editors/interface/interface_anim.c
M	source/blender/editors/object/object_constraint.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/space_action/action_edit.c
M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/makesrna/intern/rna_armature.c
M	source/blender/makesrna/intern/rna_pose.c
M	source/blender/python/intern/bpy_rna_anim.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c
M	source/gameengine/Converter/KX_BlenderSceneConverter.cpp

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

diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 31dbef998d9..13bd5c16053 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -180,11 +180,11 @@ void AnimationImporter::fcurve_is_used(FCurve *fcu)
 }
 
 
-void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
+void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
 {
 	bAction *act;
 	
-	if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
+	if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1);
 	else act = ob->adt->action;
 	
 	std::vector<FCurve *>::iterator it;
@@ -725,7 +725,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid
 	}
 }
 
-void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node,
+void AnimationImporter::apply_matrix_curves(Main *bmain, Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node,
                                             COLLADAFW::Transformation *tm)
 {
 	bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
@@ -840,7 +840,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& a
 				add_bezt(newcu[i], fra, scale[i - 7]);
 		}
 	}
-	verify_adt_action((ID *)&ob->id, 1);
+	verify_adt_action(bmain, (ID *)&ob->id, 1);
 
 	ListBase *curves = &ob->adt->action->curves;
 
@@ -897,18 +897,18 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
 	return aspect;
 }
 
-static ListBase &get_animation_curves(Material *ma)
+static ListBase &get_animation_curves(Main *bmain, Material *ma)
 {
 	bAction *act;
 	if (!ma->adt || !ma->adt->action)
-		act = verify_adt_action((ID *)&ma->id, 1);
+		act = verify_adt_action(bmain, (ID *)&ma->id, 1);
 	else
 		act = ma->adt->action;
 
 	return act->curves;
 }
 
-void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
+void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node,
                                              std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
                                              std::multimap<COLLADAFW::UniqueId, Object *>& object_map,
                                              std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map,
@@ -941,7 +941,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
 			armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
 
 
-		if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
+		if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1);
 		else act = ob->adt->action;
 
 		//Get the list of animation curves of the object
@@ -972,12 +972,11 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
 				for (unsigned int j = 0; j < bindings.getCount(); j++) {
 					animcurves = curve_map[bindings[j].animation];
 					if (is_matrix) {
-						apply_matrix_curves(ob, animcurves, root, node,  transform);
+						apply_matrix_curves(bmain, ob, animcurves, root, node,  transform);
 					}
-					else {				
-
+					else {
 						if (is_joint) {
-							add_bone_animation_sampled(ob, animcurves, root, node, transform);
+							add_bone_animation_sampled(bmain, ob, animcurves, root, node, transform);
 						}
 						else {
 							//calculate rnapaths and array index of fcurves according to transformation and animation class
@@ -1005,7 +1004,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
 	if ((animType->light) != 0) {
 		Lamp *lamp  = (Lamp *) ob->data;
 
-		if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID *)&lamp->id, 1);
+		if (!lamp->adt || !lamp->adt->action) act = verify_adt_action(bmain, (ID *)&lamp->id, 1);
 		else act = lamp->adt->action;
 
 		ListBase *AnimCurves = &(act->curves);
@@ -1039,7 +1038,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
 	if (animType->camera != 0) {
 		Camera *cam  = (Camera *) ob->data;
 		if (!cam->adt || !cam->adt->action)
-			act = verify_adt_action((ID *)&cam->id, 1);
+			act = verify_adt_action(bmain, (ID *)&cam->id, 1);
 		else
 			act = cam->adt->action;
 
@@ -1103,7 +1102,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
 						fprintf(stderr, "Collada: Node %s refers to undefined material\n", node->getName().c_str());
 						continue;
 					}
-					ListBase &AnimCurves = get_animation_curves(ma);
+					ListBase &AnimCurves = get_animation_curves(bmain, ma);
 					const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects();
 					COLLADAFW::EffectCommon *efc = commonEffects[0];
 					if ((animType->material & MATERIAL_SHININESS) != 0) {
@@ -1137,7 +1136,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
 	delete animType;
 }
 
-void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
+void AnimationImporter::add_bone_animation_sampled(Main *bmain, Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
 {
 	const char *bone_name = bc_get_joint_name(node);
 	char joint_path[200];
@@ -1260,7 +1259,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurv
 				add_bezt(newcu[i], fra, scale[i - 7]);
 		}
 	}
-	verify_adt_action((ID *)&ob->id, 1);
+	verify_adt_action(bmain, (ID *)&ob->id, 1);
 
 	// add curves
 	for (int i = 0; i < totcu; i++) {
@@ -1436,7 +1435,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::N
 // prerequisites:
 // animlist_map - map animlist id -> animlist
 // curve_map - map anim id -> curve(s)
-Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
+Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node *node,
                                                    std::map<COLLADAFW::UniqueId, Object *>& object_map,
                                                    std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
                                                    COLLADAFW::Transformation::TransformationType tm_type,
@@ -1659,7 +1658,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
 #endif
 	}
 
-	verify_adt_action((ID *)&ob->id, 1);
+	verify_adt_action(bmain, (ID *)&ob->id, 1);
 
 	ListBase *curves = &ob->adt->action->curves;
 
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index e25116cac9f..0957b1e6e06 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -87,7 +87,7 @@ private:
 
 	void fcurve_is_used(FCurve *fcu);
 
-	void add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
+	void add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
 
 	
 	int typeFlag;
@@ -153,7 +153,7 @@ public:
 	virtual void change_eul_to_quat(Object *ob, bAction *act);
 #endif
 
-	void translate_Animations(COLLADAFW::Node * Node,
+	void translate_Animations(Main *bmain, COLLADAFW::Node * Node,
 	                          std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
 	                          std::multimap<COLLADAFW::UniqueId, Object*>& object_map,
 	                          std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map,
@@ -161,10 +161,10 @@ public:
 
 	AnimMix* get_animation_type( const COLLADAFW::Node * node, std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map );
 
-	void apply_matrix_curves(Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
+	void apply_matrix_curves(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
 	                         COLLADAFW::Transformation * tm );
 	
-	void add_bone_animation_sampled(Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm);
+	void add_bone_animation_sampled(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm);
 
 	void Assign_transform_animations(COLLADAFW::Transformation* transform,
 	                                 const COLLADAFW::AnimationList::AnimationBinding *binding,
@@ -181,7 +181,7 @@ public:
 	// prerequisites:
 	// animlist_map - map animlist id -> animlist
 	// curve_map - map anim id -> curve(s)
-	Object * translate_animation_OLD(COLLADAFW::Node *node,
+	Object * translate_animation_OLD(Main *bmain, COLLADAFW::Node *node,
 	                                 std::map<COLLADAFW::UniqueId, Object*>& object_map,
 	                                 std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
 	                                 COLLADAFW::Transformation::TransformationType tm_type,
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index ce0d296843b..03fcc2e5037 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -285,7 +285,7 @@ void DocumentImporter::finish()
 
 void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL)
 {
-
+	Main *bmain = CTX_data_main(mContext);
 	// The split in #29246, rootmap must point at actual root when
 	// calculating bones in apply_curves_as_matrix. - actual root is the root node.
 	// This has to do with inverse bind poses being world space
@@ -320,7 +320,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLL

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list