Skip to content

Commit

Permalink
Skip origin enclosed checks if origin had been enclosed before
Browse files Browse the repository at this point in the history
  • Loading branch information
notgiven688 committed Apr 1, 2024
1 parent c5f8900 commit f215fad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/GJKEPA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public bool Solve(out JVector point1, out JVector point2, out JVector normal, ou
// search for the closest triangle and check if the origin is enclosed
int closestIndex = -1;
double currentMin = double.MaxValue;
bool skipTest = originEnclosed;

originEnclosed = true;

for (int i = 0; i < tCount; i++)
Expand All @@ -320,7 +322,7 @@ public bool Solve(out JVector point1, out JVector point2, out JVector normal, ou
closestIndex = i;
}

if(!Triangles[i].FacingOrigin) originEnclosed = false;
if(!Triangles[i].FacingOrigin) originEnclosed = skipTest;
}

ctri = Triangles[closestIndex];
Expand Down

0 comments on commit f215fad

Please sign in to comment.