mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 23:34:53 +08:00
[ts] Fixed IK constraint NaN when a parent bone has zero scale.
This commit is contained in:
parent
5bea236326
commit
22603c3f07
@ -18,7 +18,7 @@
|
||||
</ul>
|
||||
<li>Phaser</li>
|
||||
<ul>
|
||||
<li><a href="/spine-phaser/example/index.html">Example</a></li>
|
||||
<li><a href="/spine-phaser/example/index.html">Examples</a></li>
|
||||
</ul>
|
||||
<li>Player</li>
|
||||
<ul>
|
||||
|
||||
@ -117,7 +117,10 @@ export class IkConstraint implements Updatable {
|
||||
ty = targetY - bone.worldY;
|
||||
break;
|
||||
case TransformMode.NoRotationOrReflection:
|
||||
let s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||
let t = pa * pa + pc * pc;
|
||||
if (t > 0) t = Math.max(0.0001, t);
|
||||
else t = Math.min(-0.0001, t);
|
||||
let s = Math.abs(pa * pd - pb * pc) / t;
|
||||
let sa = pa / bone.skeleton.scaleX;
|
||||
let sc = pc / bone.skeleton.scaleY;
|
||||
pb = -sc * s * bone.skeleton.scaleX;
|
||||
@ -127,6 +130,8 @@ export class IkConstraint implements Updatable {
|
||||
default:
|
||||
let x = targetX - p.worldX, y = targetY - p.worldY;
|
||||
let d = pa * pd - pb * pc;
|
||||
if (d > 0) t = Math.max(0.0001, d);
|
||||
else t = Math.min(-0.0001, d);
|
||||
tx = (x * pd - y * pb) / d - bone.ax;
|
||||
ty = (y * pa - x * pc) / d - bone.ay;
|
||||
}
|
||||
@ -194,7 +199,9 @@ export class IkConstraint implements Updatable {
|
||||
b = pp.b;
|
||||
c = pp.c;
|
||||
d = pp.d;
|
||||
let id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
|
||||
let id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
|
||||
if (id > 0) id = 1 / Math.max(0.0001, id);
|
||||
else id = 1 / Math.min(-0.0001, id);
|
||||
let dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
||||
let l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
||||
if (l1 < 0.0001) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user