mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[csharp] port of bugfix commit 5cab7e9: Fixed 1-bone IK for transform mode noRotationOrReflection when skeleton scale is applied.
This commit is contained in:
parent
c54745cbc7
commit
85dd60bf57
@ -170,18 +170,16 @@ namespace Spine {
|
||||
ty = targetY - bone.worldY;
|
||||
break;
|
||||
case TransformMode.NoRotationOrReflection: {
|
||||
rotationIK += (float)Math.Atan2(pc, pa) * MathUtils.RadDeg;
|
||||
float ps = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||
pb = -pc * ps;
|
||||
pd = pa * ps;
|
||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||
float d = pa * pd - pb * pc;
|
||||
tx = (x * pd - y * pb) / d - bone.ax;
|
||||
ty = (y * pa - x * pc) / d - bone.ay;
|
||||
break;
|
||||
}
|
||||
float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||
float sa = pa / bone.skeleton.ScaleX;
|
||||
float sc = pc / bone.skeleton.ScaleY;
|
||||
pb = -sc * s * bone.skeleton.ScaleX;
|
||||
pd = sa * s * bone.skeleton.ScaleY;
|
||||
rotationIK += (float)Math.Atan2(pc, pa) * MathUtils.RadDeg;
|
||||
goto default; // Fall through.
|
||||
}
|
||||
default: {
|
||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||
float d = pa * pd - pb * pc;
|
||||
tx = (x * pd - y * pb) / d - bone.ax;
|
||||
ty = (y * pa - x * pc) / d - bone.ay;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user