Skip to content

Commit

Permalink
RayCast/PointTest: Fix exit condition (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
notgiven688 authored Feb 18, 2024
1 parent 1850ae5 commit da8903d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Jitter2/Collision/NarrowPhase/NarrowPhase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public bool PointTest(ISupportMap supportA, in JVector origin)
return false;
}

if (!convexPolytope.AddPoint(w)) return false;
if (!convexPolytope.AddPoint(w))
{
goto converged;
}

v = convexPolytope.GetClosestTriangle().ClosestToOrigin;

Expand All @@ -78,6 +81,8 @@ public bool PointTest(ISupportMap supportA, in JVector origin)
distSq = v.LengthSquared();
}

converged:

return true;
}

Expand Down Expand Up @@ -129,13 +134,18 @@ public bool RayCast(ISupportMap supportA, in JVector origin, in JVector directio
normal = v;
}

convexPolytope.AddPoint(w);
if (!convexPolytope.AddPoint(w))
{
goto converged;
}

v = convexPolytope.GetClosestTriangle().ClosestToOrigin;

distSq = v.LengthSquared();
}

converged:

fraction = lambda;

float nlen2 = normal.LengthSquared();
Expand Down

0 comments on commit da8903d

Please sign in to comment.