Precalculate edge list capacity

This commit is contained in:
Jarrod Doyle 2025-01-28 17:21:17 +00:00
parent 1f0b87f3de
commit 3040914afb
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Numerics; using System.Numerics;
using KeepersCompound.LGS.Database.Chunks; using KeepersCompound.LGS.Database.Chunks;
using Serilog;
namespace KeepersCompound.Lightmapper; namespace KeepersCompound.Lightmapper;
@ -98,7 +99,6 @@ public class PotentiallyVisibleSet
public PotentiallyVisibleSet(WorldRep.Cell[] cells) public PotentiallyVisibleSet(WorldRep.Cell[] cells)
{ {
_graph = new Node[cells.Length]; _graph = new Node[cells.Length];
_edges = [];
var portalCount = 0; var portalCount = 0;
foreach (var cell in cells) foreach (var cell in cells)
@ -106,6 +106,9 @@ public class PotentiallyVisibleSet
portalCount += cell.PortalPolyCount; portalCount += cell.PortalPolyCount;
} }
_edges = new List<Edge>(portalCount);
Log.Information("Mission contains {PortalCount} portals.", portalCount);
for (var i = 0; i < cells.Length; i++) for (var i = 0; i < cells.Length; i++)
{ {
var cell = cells[i]; var cell = cells[i];