mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-13 02:28:44 +08:00
[cpp] Fix NaN in IKConstraint due to fp precision.
dd - r * r might result in a negative value, even if dd == r * r, depending on compiler optimizations and operation order.
This commit is contained in:
parent
1716baae68
commit
853b5ee165
@ -213,7 +213,7 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
||||
r0 = q / c2;
|
||||
r1 = c0 / q;
|
||||
r = MathUtil::abs(r0) < MathUtil::abs(r1) ? r0 : r1;
|
||||
if (r * r <= dd) {
|
||||
if (dd - r * r >= 0) {
|
||||
y = MathUtil::sqrt(dd - r * r) * bendDir;
|
||||
a1 = ta - MathUtil::atan2(y, r);
|
||||
a2 = MathUtil::atan2(y / psy, (r - l1) / psx);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user