fix EcsGroup pages managment

This commit is contained in:
DCFApixels 2024-12-04 16:48:54 +08:00
parent 7db238709c
commit 914dfb52a6

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -402,21 +401,23 @@ namespace DCFApixels.DragonECS
_dense[_count] = entityID; _dense[_count] = entityID;
//_sparse[entityID] = _count; //_sparse[entityID] = _count;
//_count == new index
ref PageSlot page = ref _sparsePages[entityID >> PageSlot.SHIFT]; ref PageSlot page = ref _sparsePages[entityID >> PageSlot.SHIFT];
if(page.Count++ == 1) page.Count++;
// page.Count != 0
if (page.Count == 1)
{ {
int* x = _nullPage; page.IndexesXOR = _count;
if (page.Indexes != x)
{
} }
else // page.Count > 1
{
if (page.Count == 2)
{
page.Indexes = _source.TakePage(); page.Indexes = _source.TakePage();
page.Indexes[_dense[page.IndexesXOR] & PageSlot.MASK] = page.IndexesXOR;
} }
if(page.Count != 1)
{
page.Indexes[entityID & PageSlot.MASK] = _count;
page.IndexesXOR ^= _count; page.IndexesXOR ^= _count;
page.Indexes[entityID & PageSlot.MASK] = _count;
} }
//if ((page.Count == 0 && page.IndexesXOR != 0) || //if ((page.Count == 0 && page.IndexesXOR != 0) ||