mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[csharp] Port of commit e04e7b5. Adjusted fix for IK constraint NaN when parent has zero scale.
This commit is contained in:
parent
463e18596c
commit
210dc04109
@ -182,9 +182,14 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||||
float d = Math.Max(0.0001f, pa * pd - pb * pc);
|
float d = pa * pd - pb * pc;
|
||||||
|
if (Math.Abs(d) <= 0.0001f) {
|
||||||
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
tx = (x * pd - y * pb) / d - bone.ax;
|
tx = (x * pd - y * pb) / d - bone.ax;
|
||||||
ty = (y * pa - x * pc) / d - bone.ay;
|
ty = (y * pa - x * pc) / d - bone.ay;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,7 +261,8 @@ namespace Spine {
|
|||||||
b = pp.b;
|
b = pp.b;
|
||||||
c = pp.c;
|
c = pp.c;
|
||||||
d = pp.d;
|
d = pp.d;
|
||||||
float id = 1 / Math.Max(0.0001f, a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
|
float id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
|
||||||
|
id = Math.Abs(id) <= 0.0001f ? 0 : 1 / id;
|
||||||
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
||||||
float l1 = (float)Math.Sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
float l1 = (float)Math.Sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
||||||
if (l1 < 0.0001f) {
|
if (l1 < 0.0001f) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user