Skip to content

Commit

Permalink
[csharp] Port of commit 853b5ee. Fix NaN in IKConstraint due to fp pr…
Browse files Browse the repository at this point in the history
…ecision.

dd - r * r might result in a negative value, even if dd == r * r, depending on compiler optimizations and operation order.
  • Loading branch information
HaraldCsaszar committed Aug 6, 2024
1 parent 853b5ee commit b17595d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spine-csharp/src/IkConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ 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) {
if (dd - r * r >= 0) {
y = (float)Math.Sqrt(dd - r * r) * bendDir;
a1 = ta - (float)Math.Atan2(y, r);
a2 = (float)Math.Atan2(y / psy, (r - l1) / psx);
Expand Down
2 changes: 1 addition & 1 deletion spine-csharp/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.",
"version": "4.2.28",
"version": "4.2.29",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
Expand Down

0 comments on commit b17595d

Please sign in to comment.