diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-07-24 09:08:55 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-07-24 09:08:55 +0400 |
commit | 65f4cb14c1b657b2b6d0c53d23ef0e5973598953 (patch) | |
tree | 90927008603f2d1e2799e8c99bb60131d1d6a769 /source/blender/blenkernel | |
parent | e7ad09f8b5daa9220fea7462aa4a3ce70b759ab9 (diff) |
== 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)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_constraint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 27 |
2 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 6a11159645c..02084b49716 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -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 ***** */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index ad1e4d10cd3..95359a22711 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1017,9 +1017,30 @@ static void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float 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); |