perf(physics): pool collision cell snapshots
Preserve the fixed per-cell collision walk across nested registry mutations while replacing the repeated List allocation with an explicitly owned pooled snapshot. Capture cardinality once, return storage on every exit, and pin live-list mutation behavior with a focused regression test. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
f9736ece6c
commit
4f1c067a21
3 changed files with 77 additions and 3 deletions
|
|
@ -16,6 +16,25 @@ public class ShadowObjectRegistryTests
|
|||
private const float OffX = 0f;
|
||||
private const float OffY = 0f;
|
||||
|
||||
[Fact]
|
||||
public void ShadowEntrySnapshot_LiveListMutation_DoesNotChangeCapturedWalk()
|
||||
{
|
||||
var first = new ShadowEntry(1u, 0u, Vector3.Zero, Quaternion.Identity, 1f);
|
||||
var second = new ShadowEntry(2u, 0u, Vector3.One, Quaternion.Identity, 1f);
|
||||
var replacement = new ShadowEntry(3u, 0u, Vector3.UnitX, Quaternion.Identity, 1f);
|
||||
var liveEntries = new List<ShadowEntry> { first, second };
|
||||
|
||||
using var snapshot = ShadowEntrySnapshot.Capture(liveEntries);
|
||||
|
||||
liveEntries.RemoveAt(0);
|
||||
liveEntries.Add(replacement);
|
||||
liveEntries.Add(first);
|
||||
|
||||
Assert.Equal(
|
||||
new uint[] { first.EntityId, second.EntityId },
|
||||
snapshot.Entries.ToArray().Select(entry => entry.EntityId));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Register / TotalRegistered
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue