Skip to content

Commit

Permalink
fix: recalculate bad triangles
Browse files Browse the repository at this point in the history
In some rare cases the result bad triangles could contain duplicates.
  • Loading branch information
andywiecko committed Nov 6, 2023
1 parent 54d6034 commit a677bf3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Runtime/Triangulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@ private int UnsafeInsertPoint(float2 p, int initTriangle, NativeList<int> heQueu

trianglesQueue.Enqueue(initTriangle);
badTriangles.Add(initTriangle);
visitedTriangles[initTriangle] = true;
RecalculateBadTriangles(p);

ProcessBadTriangles(pId, heQueue, tQueue);
Expand All @@ -1902,8 +1903,6 @@ private void RecalculateBadTriangles(float2 p)
{
while (trianglesQueue.TryDequeue(out var tId))
{
visitedTriangles[tId] = true;

VisitEdge(p, 3 * tId + 0, 3 * tId + 1);
VisitEdge(p, 3 * tId + 1, 3 * tId + 2);
VisitEdge(p, 3 * tId + 2, 3 * tId + 0);
Expand Down Expand Up @@ -1935,6 +1934,7 @@ private void VisitEdge(float2 p, int t0, int t1)
{
badTriangles.Add(otherId);
trianglesQueue.Enqueue(otherId);
visitedTriangles[otherId] = true;
}
}

Expand Down

0 comments on commit a677bf3

Please sign in to comment.