Bugfix #3422
When using 'protection flags' for XYZ rotations, inserting keys in Poses resulted in wrong interpolations (doing -270 degrees instead of +90 for example). This caused by converting quaternion to euler and back... Solved it by correcting the quaternion in the end for the rotation sign of the original quaternion. NOTE: Pose animators should be aware that inserting rotations keys of 180 degrees or larger will still make the key rotate along the shortest path.
This commit is contained in:
@@ -1043,8 +1043,9 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
|
||||
/* this function only does the delta rotation */
|
||||
|
||||
if(protectflag) {
|
||||
float eul[3], oldeul[3];
|
||||
float eul[3], oldeul[3], quat1[4];
|
||||
|
||||
QUATCOPY(quat1, quat);
|
||||
QuatToEul(quat, eul);
|
||||
QuatToEul(oldquat, oldeul);
|
||||
|
||||
@@ -1056,6 +1057,10 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
|
||||
eul[2]= oldeul[2];
|
||||
|
||||
EulToQuat(eul, quat);
|
||||
/* quaternions flip w sign to accumulate rotations correctly */
|
||||
if( (quat1[0]<0.0f && quat[0]>0.0f) || (quat1[0]>0.0f && quat[0]<0.0f) ) {
|
||||
QuatMulf(quat, -1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user