[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11401] trunk/blender/source/blender/ blenkernel/intern/constraint.c: == Constraints - Important Bugfix ==

Joshua Leung aligorith at gmail.com
Sat Jul 28 12:44:03 CEST 2007


Revision: 11401
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11401
Author:   aligorith
Date:     2007-07-28 12:44:03 +0200 (Sat, 28 Jul 2007)

Log Message:
-----------
== Constraints - Important Bugfix ==

At last, the 'Local' option for Armatures works properly! 
Tonight I went through carefully and cross-checked the code once again, and found several bad mistakes I had made. These were:
* the value of one variable from the armatures code was not what I expected it to be, based off the name). 
* Mat4MulSerie swaps the first two args! Grrr...

Note: 
There's only one rig that I've tested that was broken. That was slikdigit's "mancandy", and the part in question was the jaw. It is likely that a few more rigs out there (in particular, their 'local' action constraints) relied on the wacky rotation values that used to be used, so are now broken.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-07-28 09:26:53 UTC (rev 11400)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-07-28 10:44:03 UTC (rev 11401)
@@ -956,32 +956,32 @@
 				/* pose to local */
 				else if (to == CONSTRAINT_SPACE_LOCAL) {
 					if (pchan->bone) {
-						if (pchan->parent && pchan->parent->bone) {
+						if (pchan->parent) {
 							float offs_bone[4][4];
 								
 							/* construct offs_bone the same way it is done in armature.c */
 							Mat4CpyMat3(offs_bone, pchan->bone->bone_mat);
 							VECCOPY(offs_bone[3], pchan->bone->head);
-							offs_bone[3][1]+= pchan->parent->bone->length;
+							offs_bone[3][1]+= pchan->bone->parent->length;
 							
 							if (pchan->bone->flag & BONE_HINGE) {
 								/* pose_mat = par_pose-space_location * chan_mat */
 								float tmat[4][4];
 								
 								/* the rotation of the parent restposition */
-								Mat4CpyMat4(tmat, pchan->parent->bone->arm_mat);
+								Mat4CpyMat4(tmat, pchan->bone->parent->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;
 								Mat4MulVecfl(pchan->parent->pose_mat, tmat[3]);
 								
-								Mat4MulMat4(diff_mat, tmat, offs_bone);
+								Mat4MulMat4(diff_mat, offs_bone, tmat);
 								Mat4Invert(imat, diff_mat);
 							}
 							else {
 								/* pose_mat = par_pose_mat * bone_mat * chan_mat */
-								Mat4MulMat4(diff_mat, pchan->parent->pose_mat, offs_bone);
+								Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat);
 								Mat4Invert(imat, diff_mat);
 							}
 						}
@@ -1017,27 +1017,27 @@
 							/* construct offs_bone the same way it is done in armature.c */
 							Mat4CpyMat3(offs_bone, pchan->bone->bone_mat);
 							VECCOPY(offs_bone[3], pchan->bone->head);
-							offs_bone[3][1]+= pchan->parent->bone->length;
+							offs_bone[3][1]+= pchan->bone->parent->length;
 							
 							if (pchan->bone->flag & BONE_HINGE) {
 								/* pose_mat = par_pose-space_location * chan_mat */
 								float tmat[4][4];
 								
 								/* the rotation of the parent restposition */
-								Mat4CpyMat4(tmat, pchan->parent->bone->arm_mat);
+								Mat4CpyMat4(tmat, pchan->bone->parent->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;
 								Mat4MulVecfl(pchan->parent->pose_mat, tmat[3]);
 								
-								Mat4MulMat4(diff_mat, tmat, offs_bone);
+								Mat4MulMat4(diff_mat, offs_bone, tmat);
 								Mat4CpyMat4(tempmat, mat);
 								Mat4MulMat4(mat, tempmat, diff_mat);
 							}
 							else {
 								/* pose_mat = par_pose_mat * bone_mat * chan_mat */
-								Mat4MulMat4(diff_mat, pchan->parent->pose_mat, offs_bone);
+								Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat);
 								Mat4CpyMat4(tempmat, mat);
 								Mat4MulMat4(mat, tempmat, diff_mat);
 							}





More information about the Bf-blender-cvs mailing list