Always create a new edge to the portal graph

This commit is contained in:
Jarrod Doyle 2025-01-04 21:12:54 +00:00
parent c5cbeddcd5
commit 74283f976d
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 14 additions and 20 deletions

View File

@ -77,11 +77,8 @@ public class PotentiallyVisibleSet
var other = poly.Destination;
// If there's already an existing edge between the two cells then we just need to add a reference to it
// otherwise we need to actually build the edge
var edgeIndex = _edges.FindIndex(e => (e.Left == i && e.Right == other) || (e.Left == other && e.Right == i));
if (edgeIndex == -1)
{
// Checking if there's already an edge is super slow. It's much faster to just add a new edge, even with
// the duplicated poly
var vs = new Vector3[poly.VertexCount];
for (var vIdx = 0; vIdx < poly.VertexCount; vIdx++)
{
@ -95,10 +92,7 @@ public class PotentiallyVisibleSet
Poly = new Poly(vs, cell.Planes[poly.PlaneId]),
};
_edges.Add(edge);
edgeIndex = _edges.Count - 1;
}
_portalGraph[i].Add(edgeIndex);
_portalGraph[i].Add(_edges.Count - 1);
indicesOffset += poly.VertexCount;
}
}