[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11355] trunk/blender/source/blender/ blenkernel: == Constraints - Important Bugfix ==
Joshua Leung
aligorith at gmail.com
Tue Jul 24 07:08:55 CEST 2007
Revision: 11355
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11355
Author: aligorith
Date: 2007-07-24 07:08:55 +0200 (Tue, 24 Jul 2007)
Log Message:
-----------
== Constraints - Important Bugfix ==
I've finally fixed the bug with the Constraint Space Conversion. It was a single matrix multiplication in the wrong order (for local->pose).
Also, there is more code added for the space conversion process when bones have 'hinge' on. (NOTE: this stuff for hinge bones may still not work really nice yet)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_constraint.h
trunk/blender/source/blender/blenkernel/intern/constraint.c
Modified: trunk/blender/source/blender/blenkernel/BKE_constraint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_constraint.h 2007-07-23 21:54:10 UTC (rev 11354)
+++ trunk/blender/source/blender/blenkernel/BKE_constraint.h 2007-07-24 05:08:55 UTC (rev 11355)
@@ -25,7 +25,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): 2007 - Joshua Leung (major recode)
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c 2007-07-23 21:54:10 UTC (rev 11354)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c 2007-07-24 05:08:55 UTC (rev 11355)
@@ -1017,9 +1017,30 @@
VECCOPY(offs_bone[3], pchan->bone->head);
offs_bone[3][1]+= pchan->parent->bone->length;
- Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat);
- Mat4CpyMat4(tempmat, mat);
- Mat4MulMat4(mat, tempmat, diff_mat);
+ 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);
+
+ /* 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, offs_bone, tmat);
+
+ Mat4MulMat4(diff_mat, pchan->parent->pose_mat, offs_bone);
+ 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);
+ Mat4CpyMat4(tempmat, mat);
+ Mat4MulMat4(mat, tempmat, diff_mat);
+ }
}
else {
Mat4CpyMat4(diff_mat, pchan->bone->arm_mat);
More information about the Bf-blender-cvs
mailing list