From 74228a2851d64f3f3ad472607a570b28af48da26 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 4 Jan 2025 21:03:57 +0000 Subject: [PATCH] Fix incorrect loop back logic in recursive section --- KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs b/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs index 5f18eef..96b49ca 100644 --- a/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs +++ b/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs @@ -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); } }