From 0ca66e853b2fd38a1740e68a3c4f1cba9b62bedf Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 26 Nov 2024 02:25:15 +0800 Subject: [PATCH] add page.xor --- src/Collections/EcsGroup.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Collections/EcsGroup.cs b/src/Collections/EcsGroup.cs index ca3a040..8ac039d 100644 --- a/src/Collections/EcsGroup.cs +++ b/src/Collections/EcsGroup.cs @@ -402,7 +402,13 @@ namespace DCFApixels.DragonECS //} } page->Indexes[entityID & PageSlot.MASK] = _count; + page->IndexesXOR ^= _count; page->Count++; + + //if (page->Count == 1) + //{ + // ReadOnlySpan pageSpan = new ReadOnlySpan(page->Indexes, PageSlot.SIZE); + //} } public void RemoveUnchecked(int entityID) @@ -441,10 +447,18 @@ namespace DCFApixels.DragonECS if (--page->Count == 0) { _source.ReturnPage(page->Indexes); + page->Indexes = null; + page->IndexesXOR = 0; } else { + page->IndexesXOR ^= page->Indexes[localEntityID]; page->Indexes[localEntityID] = 0; + + if (page->Count == 1) + { + ReadOnlySpan pageSpan = new ReadOnlySpan(page->Indexes, PageSlot.SIZE); + } } } @@ -484,6 +498,7 @@ namespace DCFApixels.DragonECS _source.ReturnPage(page->Indexes); page->Indexes = null; } + page->IndexesXOR = 0; page->Count = 0; } @@ -1497,6 +1512,7 @@ namespace DCFApixels.DragonECS public const int MASK = SIZE - 1; public int* Indexes; + public int IndexesXOR; public byte Count; } #endregion