Fixed single bone IK mixing.

This commit is contained in:
NathanSweet 2016-06-25 22:13:31 +02:00
parent a9a771ba1c
commit e0ee18a088

View File

@ -130,13 +130,13 @@ public class IkConstraint implements Updatable {
float id = 1 / (pp.a * pp.d - pp.b * pp.c);
float x = targetX - pp.worldX, y = targetY - pp.worldY;
float tx = (x * pp.d - y * pp.b) * id - bone.x, ty = (y * pp.a - x * pp.c) * id - bone.y;
float rotationIK = atan2(ty, tx) * radDeg - bone.shearX;
float rotationIK = atan2(ty, tx) * radDeg - bone.shearX - bone.rotation;
if (bone.scaleX < 0) rotationIK += 180;
if (rotationIK > 180)
rotationIK -= 360;
else if (rotationIK < -180) rotationIK += 360;
bone.updateWorldTransform(bone.x, bone.y, bone.rotation + (rotationIK - bone.rotation) * alpha, bone.scaleX, bone.scaleY,
bone.shearX, bone.shearY);
bone.updateWorldTransform(bone.x, bone.y, bone.rotation + rotationIK * alpha, bone.scaleX, bone.scaleY, bone.shearX,
bone.shearY);
}
/** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The