Fix incorrect loop back logic in recursive section

This commit is contained in:
Jarrod Doyle 2025-01-04 21:03:57 +00:00
parent f0cec24cf6
commit 74228a2851
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 4 additions and 3 deletions

View File

@ -179,18 +179,19 @@ public class PotentiallyVisibleSet
foreach (var edgeIndex in _portalGraph[currentCellIdx])
{
var edge = _edges[edgeIndex];
var destination = edge.Left == previousCellIdx ? edge.Right : edge.Left;
if (destination == previousCellIdx || previousPoly.IsCoplanar(edge.Poly))
var loopsBack = edge.Left == previousCellIdx || edge.Right == previousCellIdx;
if (loopsBack || previousPoly.IsCoplanar(edge.Poly))
{
continue;
}
var poly = separators.Aggregate(edge.Poly, ClipPolygonByPlane);
if (poly.Vertices.Length == 0)
{
continue;
}
var destination = edge.Left == currentCellIdx ? edge.Right : edge.Left;
ComputeClippedVisibility(visible, sourcePoly, poly, currentCellIdx, destination, depth + 1);
}
}