mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Fixed single bone IK mixing.
This commit is contained in:
parent
a9a771ba1c
commit
e0ee18a088
@ -130,13 +130,13 @@ public class IkConstraint implements Updatable {
|
|||||||
float id = 1 / (pp.a * pp.d - pp.b * pp.c);
|
float id = 1 / (pp.a * pp.d - pp.b * pp.c);
|
||||||
float x = targetX - pp.worldX, y = targetY - pp.worldY;
|
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 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 (bone.scaleX < 0) rotationIK += 180;
|
||||||
if (rotationIK > 180)
|
if (rotationIK > 180)
|
||||||
rotationIK -= 360;
|
rotationIK -= 360;
|
||||||
else 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.updateWorldTransform(bone.x, bone.y, bone.rotation + rotationIK * alpha, bone.scaleX, bone.scaleY, bone.shearX,
|
||||||
bone.shearX, bone.shearY);
|
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
|
/** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user