[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24895] trunk/blender: Pose Bone Local Location: now also works for non-connected bones with parents.

Brecht Van Lommel brecht at blender.org
Wed Nov 25 19:48:29 CET 2009


Revision: 24895
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24895
Author:   blendix
Date:     2009-11-25 19:48:29 +0100 (Wed, 25 Nov 2009)

Log Message:
-----------
Pose Bone Local Location: now also works for non-connected bones with parents.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_data_bone.py
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/release/scripts/ui/properties_data_bone.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_bone.py	2009-11-25 18:20:46 UTC (rev 24894)
+++ trunk/blender/release/scripts/ui/properties_data_bone.py	2009-11-25 18:48:29 UTC (rev 24895)
@@ -189,8 +189,10 @@
         sub.prop(bone, "connected")
         sub.prop(bone, "hinge", text="Inherit Rotation")
         sub.prop(bone, "inherit_scale", text="Inherit Scale")
+        sub = col.column()
+        sub.active = (not bone.parent or not bone.connected)
+        sub.prop(bone, "local_location", text="Local Location")
 
-
 class BONE_PT_display(BoneButtonsPanel):
     bl_label = "Display"
 

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2009-11-25 18:20:46 UTC (rev 24894)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2009-11-25 18:48:29 UTC (rev 24895)
@@ -2220,39 +2220,43 @@
 			
 			/* the rotation of the parent restposition */
 			copy_m4_m4(tmat, parbone->arm_mat);
-			
-			/* the location of actual parent transform */
-			VECCOPY(tmat[3], offs_bone[3]);
-			offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
-			mul_m4_v3(parchan->pose_mat, tmat[3]);
-			
 			mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
 		}
 		else if(bone->flag & BONE_NO_SCALE) {
 			float orthmat[4][4];
 			
-			/* get the official transform, but we only use the vector from it (optimize...) */
-			mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
-			VECCOPY(vec, pchan->pose_mat[3]);
-			
-			/* do this again, but with an ortho-parent matrix */
+			/* do transform, with an ortho-parent matrix */
 			copy_m4_m4(orthmat, parchan->pose_mat);
 			normalize_m4(orthmat);
 			mul_serie_m4(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
-			
-			/* copy correct transform */
-			VECCOPY(pchan->pose_mat[3], vec);
 		}
-		else 
+		else
 			mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
+		
+		/* in these cases we need to compute location separately */
+		if(bone->flag & (BONE_HINGE|BONE_NO_SCALE|BONE_NO_LOCAL_LOCATION)) {
+			float bone_loc[3], chan_loc[3];
+
+			mul_v3_m4v3(bone_loc, parchan->pose_mat, offs_bone[3]);
+			copy_v3_v3(chan_loc, pchan->chan_mat[3]);
+
+			/* no local location is not transformed by bone matrix */
+			if(!(bone->flag & BONE_NO_LOCAL_LOCATION))
+				mul_mat3_m4_v3(offs_bone, chan_loc);
+
+			/* for hinge we use armature instead of pose mat */
+			if(bone->flag & BONE_HINGE) mul_m4_v3(parbone->arm_mat, chan_loc);
+			else mul_m4_v3(parchan->pose_mat, chan_loc);
+
+			add_v3_v3v3(pchan->pose_mat[3], bone_loc, chan_loc);
+		}
 	}
 	else {
-		if(bone->flag & BONE_NO_LOCAL_LOCATION) {
-			mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
+		mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
+
+		/* optional location without arm_mat rotation */
+		if(bone->flag & BONE_NO_LOCAL_LOCATION)
 			add_v3_v3v3(pchan->pose_mat[3], bone->arm_mat[3], pchan->chan_mat[3]);
-		}
-		else
-			mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
 		
 		/* only rootbones get the cyclic offset (unless user doesn't want that) */
 		if ((bone->flag & BONE_NO_CYCLICOFFSET) == 0)

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-11-25 18:20:46 UTC (rev 24894)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-11-25 18:48:29 UTC (rev 24895)
@@ -604,6 +604,11 @@
 	/* proper way to get parent transform + own transform + constraints transform */
 	copy_m3_m4(omat, ob->obmat);
 
+	if (t->mode==TFM_TRANSLATION && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION))
+		unit_m3(bmat);
+	else
+		copy_m3_m3(bmat, pchan->bone->bone_mat);
+
 	if (pchan->parent) {
 		if(pchan->bone->flag & BONE_HINGE)
 			copy_m3_m4(pmat, pchan->parent->bone->arm_mat);
@@ -613,17 +618,12 @@
 		if (constraints_list_needinv(t, &pchan->constraints)) {
 			copy_m3_m4(tmat, pchan->constinv);
 			invert_m3_m3(cmat, tmat);
-			mul_serie_m3(td->mtx, pchan->bone->bone_mat, pmat, omat, cmat, 0,0,0,0);    // dang mulserie swaps args
+			mul_serie_m3(td->mtx, bmat, pmat, omat, cmat, 0,0,0,0);    // dang mulserie swaps args
 		}
 		else
-			mul_serie_m3(td->mtx, pchan->bone->bone_mat, pmat, omat, 0,0,0,0,0);    // dang mulserie swaps args
+			mul_serie_m3(td->mtx, bmat, pmat, omat, 0,0,0,0,0);    // dang mulserie swaps args
 	}
 	else {
-		if (t->mode==TFM_TRANSLATION && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION))
-			unit_m3(bmat);
-		else
-			copy_m3_m3(bmat, pchan->bone->bone_mat);
-
 		if (constraints_list_needinv(t, &pchan->constraints)) {
 			copy_m3_m4(tmat, pchan->constinv);
 			invert_m3_m3(cmat, tmat);





More information about the Bf-blender-cvs mailing list