Skip to content

Commit

Permalink
fix: throws "not associated with a rigid body" when steps with tiny s…
Browse files Browse the repository at this point in the history
…ize shapes
  • Loading branch information
labbbirder committed May 30, 2024
1 parent bbc6c41 commit 9b53043
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Jitter2/LinearMath/JMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ public readonly float Determinant()
public static bool Inverse(in JMatrix matrix, out JMatrix result)
{
float det = matrix.Determinant();
float idet = 1.0f / det;

if (float.IsNaN(det) || float.IsInfinity(det))
if (float.IsNaN(det) || float.IsInfinity(det) || float.IsNaN(idet) || float.IsInfinity(idet))
{
result = new JMatrix();
return false;
Expand All @@ -353,8 +354,6 @@ public static bool Inverse(in JMatrix matrix, out JMatrix result)
float num32 = matrix.M12 * matrix.M31 - matrix.M32 * matrix.M11;
float num33 = matrix.M11 * matrix.M22 - matrix.M21 * matrix.M12;

float idet = 1.0f / det;

result.M11 = num11 * idet;
result.M12 = num12 * idet;
result.M13 = num13 * idet;
Expand Down

0 comments on commit 9b53043

Please sign in to comment.