== 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.
This commit is contained in:
Joshua Leung
2007-07-28 10:44:03 +00:00
parent 48b07b7f15
commit e765fbf126

View File

@@ -956,32 +956,32 @@ static void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float
/* 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 @@ static void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float
/* 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);
}