[Bf-blender-cvs] [339d0170d1] master: collada: Simplify reading Node Matrix

Gaia Clary noreply at git.blender.org
Thu Mar 23 15:03:23 CET 2017


Commit: 339d0170d1843e6a67217cfc4085af8725708eca
Author: Gaia Clary
Date:   Tue Mar 21 18:05:10 2017 +0100
Branches: master
https://developer.blender.org/rB339d0170d1843e6a67217cfc4085af8725708eca

collada: Simplify reading Node Matrix

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

M	source/blender/collada/ArmatureImporter.cpp
M	source/blender/collada/TransformReader.cpp
M	source/blender/collada/TransformReader.h

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

diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 13196c4a15..398c4a2c10 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -132,18 +132,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
 
 	// create a bone even if there's no joint data for it (i.e. it has no influence)
 	if (!bone_is_skinned) {
-		float obmat[4][4];
-		// bone-space
-		get_node_mat(obmat, node, NULL, NULL);
-
-		// get world-space
-		if (parent) {
-			mul_m4_m4m4(mat, parent_mat, obmat);
-		}
-		else {
-			copy_m4_m4(mat, obmat);
-		}
-
+		get_node_mat(mat, node, NULL, NULL, parent_mat);
 	}
 
 	if (parent) bone->parent = parent;
diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp
index f8f31304d2..7f742be7e3 100644
--- a/source/blender/collada/TransformReader.cpp
+++ b/source/blender/collada/TransformReader.cpp
@@ -34,7 +34,21 @@ TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv)
 	/* pass */
 }
 
-void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob)
+void TransformReader::get_node_mat(
+	float mat[4][4],
+	COLLADAFW::Node *node,
+	std::map<COLLADAFW::UniqueId, Animation> *animation_map,
+	Object *ob)
+{
+	get_node_mat(mat, node, animation_map, ob, NULL);
+}
+
+void TransformReader::get_node_mat(
+	float mat[4][4],
+	COLLADAFW::Node *node,
+	std::map<COLLADAFW::UniqueId, Animation> *animation_map,
+	Object *ob,
+	float parent_mat[4][4])
 {
 	float cur[4][4];
 	float copy[4][4];
@@ -52,6 +66,9 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::
 				// then this is considered as redundant information.
 				// So if we find a Matrix we use that and return.
 				dae_matrix_to_mat4(tm, mat);
+				if (parent_mat) {
+					mul_m4_m4m4(mat, parent_mat, mat);
+				}
 				return;
 			case COLLADAFW::Transformation::TRANSLATE:
 				dae_translate_to_mat4(tm, cur);
@@ -80,6 +97,10 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::
 			(*animation_map)[anim_list_id] = anim;
 		}
 	}
+
+	if (parent_mat) {
+		mul_m4_m4m4(mat, parent_mat, mat);
+	}
 }
 
 void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4])
diff --git a/source/blender/collada/TransformReader.h b/source/blender/collada/TransformReader.h
index ab974b9ba8..c598c466c9 100644
--- a/source/blender/collada/TransformReader.h
+++ b/source/blender/collada/TransformReader.h
@@ -59,7 +59,8 @@ public:
 	TransformReader(UnitConverter *conv);
 
 	void get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob);
-	
+	void get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob, float parent_mat[4][4]);
+
 	void dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);
 	void dae_translate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);
 	void dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);




More information about the Bf-blender-cvs mailing list