Skip to content

Commit

Permalink
[libgdx] Fix NaN in IKConstraint due to fp precision.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Aug 7, 2024
1 parent b17595d commit 877e705
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ static public void apply (Bone parent, Bone child, float targetX, float targetY,
q = -(c1 + q) * 0.5f;
float r0 = q / c2, r1 = c / q;
float r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
if (r * r <= dd) {
y = (float)Math.sqrt(dd - r * r) * bendDir;
r0 = dd - r * r;
if (r0 >= 0) {
y = (float)Math.sqrt(r0) * bendDir;
a1 = ta - atan2(y, r);
a2 = atan2(y / psy, (r - l1) / psx);
break outer;
Expand Down

0 comments on commit 877e705

Please sign in to comment.