Fixed IK mix rotating the wrong direction.

This commit is contained in:
NathanSweet 2016-05-25 01:16:11 +02:00
parent a84e3379d8
commit c976f8038b

View File

@ -243,18 +243,18 @@ public class IkConstraint implements Updatable {
} }
} }
float os = atan2(cy, cx) * s2; float os = atan2(cy, cx) * s2;
a1 = (a1 - os) * radDeg + os1; float rotation = parent.rotation;
a2 = ((a2 + os) * radDeg - child.shearX) * s2 + os2; a1 = (a1 - os) * radDeg + os1 - rotation;
if (a1 > 180) if (a1 > 180)
a1 -= 360; a1 -= 360;
else if (a1 < -180) a1 += 360; else if (a1 < -180) a1 += 360;
parent.updateWorldTransform(px, py, rotation + a1 * alpha, parent.appliedScaleX, parent.appliedScaleY, 0, 0);
rotation = child.rotation;
a2 = ((a2 + os) * radDeg - child.shearX) * s2 + os2 - rotation;
if (a2 > 180) if (a2 > 180)
a2 -= 360; a2 -= 360;
else if (a2 < -180) a2 += 360; else if (a2 < -180) a2 += 360;
float rotation = parent.rotation; child.updateWorldTransform(cx, cy, rotation + a2 * alpha, child.appliedScaleX, child.appliedScaleY, child.shearX,
parent.updateWorldTransform(px, py, rotation + (a1 - rotation) * alpha, parent.appliedScaleX, parent.appliedScaleY, 0, 0); child.shearY);
rotation = child.rotation;
child.updateWorldTransform(cx, cy, rotation + (a2 - rotation) * alpha, child.appliedScaleX, child.appliedScaleY,
child.shearX, child.shearY);
} }
} }