Fix for bug #7368: flipping issue with dual quaternions and scaled bones.

This commit is contained in:
2008-04-01 21:16:24 +00:00
parent cf12557c5b
commit c68588ea98

View File

@@ -1727,9 +1727,13 @@ void DQuatToMat4(DualQuat *dq, float mat[][4])
void DQuatAddWeighted(DualQuat *dqsum, DualQuat *dq, float weight)
{
int flipped= 0;
/* make sure we interpolate quats in the right direction */
if (QuatDot(dq->quat, dqsum->quat) < 0)
weight = -weight;
if (QuatDot(dq->quat, dqsum->quat) < 0) {
flipped= 1;
weight= -weight;
}
/* interpolate rotation and translation */
dqsum->quat[0] += weight*dq->quat[0];
@@ -1746,6 +1750,9 @@ void DQuatAddWeighted(DualQuat *dqsum, DualQuat *dq, float weight)
if (dq->scale_weight) {
float wmat[4][4];
if(flipped) /* we don't want negative weights for scaling */
weight= -weight;
Mat4CpyMat4(wmat, dq->scale);
Mat4MulFloat((float*)wmat, weight);
Mat4AddMat4(dqsum->scale, dqsum->scale, wmat);