diff --git a/src/AcDream.App/Rendering/Wb/WbDrawDispatcher.cs b/src/AcDream.App/Rendering/Wb/WbDrawDispatcher.cs index 15d0e6e..33bb863 100644 --- a/src/AcDream.App/Rendering/Wb/WbDrawDispatcher.cs +++ b/src/AcDream.App/Rendering/Wb/WbDrawDispatcher.cs @@ -113,7 +113,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable // instead of allocating a fresh List<(WorldEntity, int)> per frame. At // ~10K entities × ~3 mesh refs = ~30K tuples × 16 bytes = ~480 KB / frame // of GC pressure on the render thread under the original T17 shape. - private readonly List<(WorldEntity Entity, int MeshRefIndex)> _walkScratch = new(); + private readonly List<(WorldEntity Entity, int MeshRefIndex, uint LandblockId)> _walkScratch = new(); // Per-entity-cull AABB radius. Conservative — covers most entities; large // outliers (long banners, tall columns) are still landblock-culled. @@ -189,7 +189,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable public struct WalkResult { public int EntitiesWalked; - public List<(WorldEntity Entity, int MeshRefIndex)> ToDraw; + public List<(WorldEntity Entity, int MeshRefIndex, uint LandblockId)> ToDraw; } /// @@ -224,7 +224,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable HashSet? visibleCellIds, HashSet? animatedEntityIds) { - var scratch = new List<(WorldEntity Entity, int MeshRefIndex)>(); + var scratch = new List<(WorldEntity Entity, int MeshRefIndex, uint LandblockId)>(); var result = new WalkResult { ToDraw = scratch }; WalkEntitiesInto( landblockEntries, frustum, neverCullLandblockId, @@ -244,7 +244,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable uint? neverCullLandblockId, HashSet? visibleCellIds, HashSet? animatedEntityIds, - List<(WorldEntity Entity, int MeshRefIndex)> scratch, + List<(WorldEntity Entity, int MeshRefIndex, uint LandblockId)> scratch, ref WalkResult result) { scratch.Clear(); @@ -271,7 +271,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable && !visibleCellIds.Contains(entity.ParentCellId.Value)) continue; result.EntitiesWalked++; for (int i = 0; i < entity.MeshRefs.Count; i++) - scratch.Add((entity, i)); + scratch.Add((entity, i, entry.LandblockId)); } continue; } @@ -297,7 +297,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable result.EntitiesWalked++; for (int i = 0; i < entity.MeshRefs.Count; i++) - scratch.Add((entity, i)); + scratch.Add((entity, i, entry.LandblockId)); } } } @@ -364,7 +364,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable _walkScratch, ref walkResult); - foreach (var (entity, partIdx) in _walkScratch) + foreach (var (entity, partIdx, landblockId) in _walkScratch) { if (diag) _entitiesSeen++;