[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39706] trunk/blender/source/blender/ editors/armature/editarmature.c: when applying armature object transform now transform the bone roll too.

Campbell Barton ideasman42 at gmail.com
Fri Aug 26 08:22:13 CEST 2011


Revision: 39706
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39706
Author:   campbellbarton
Date:     2011-08-26 06:22:12 +0000 (Fri, 26 Aug 2011)
Log Message:
-----------
when applying armature object transform now transform the bone roll too.

This means you can import a BVH, rotate 90d and apply the rotation, the animation will still work as expected - thanks to Benjy's script for showing how obvious it is that this works :)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/editarmature.c

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c	2011-08-26 04:00:55 UTC (rev 39705)
+++ trunk/blender/source/blender/editors/armature/editarmature.c	2011-08-26 06:22:12 UTC (rev 39706)
@@ -494,15 +494,32 @@
 	EditBone *ebone;
 	bArmature *arm= ob->data;
 	float scale = mat4_to_scale(mat);	/* store the scale of the matrix here to use on envelopes */
-	
+	float mat3[3][3];
+
+	copy_m3_m4(mat3, mat);
+	normalize_m3(mat3);
+
 	/* Put the armature into editmode */
 	ED_armature_to_edit(ob);
 
 	/* Do the rotations */
-	for (ebone = arm->edbo->first; ebone; ebone=ebone->next){
+	for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+		float	delta[3], tmat[3][3];
+
+		/* find the current bone's roll matrix */
+		sub_v3_v3v3(delta, ebone->tail, ebone->head);
+		vec_roll_to_mat3(delta, ebone->roll, tmat);
+
+		/* transform the roll matrix */
+		mul_m3_m3m3(tmat, mat3, tmat);
+
+		/* transform the bone */
 		mul_m4_v3(mat, ebone->head);
 		mul_m4_v3(mat, ebone->tail);
-		
+
+		/* apply the transfiormed roll back */
+		mat3_to_vec_roll(tmat, delta, &ebone->roll);
+
 		ebone->rad_head	*= scale;
 		ebone->rad_tail	*= scale;
 		ebone->dist		*= scale;




More information about the Bf-blender-cvs mailing list