-EntityAllocator fixed issue with not initialized block pointer
-deffered adding entities -deffered adding and removeing components
This commit is contained in:
parent
b3dce6560a
commit
cb0f56b0fb
3 changed files with 214 additions and 77 deletions
|
|
@ -11,19 +11,24 @@ struct EntityAllocator
|
|||
|
||||
void* getBlock()
|
||||
{
|
||||
if(next_block is null)allocBlock();
|
||||
if (next_block is null)
|
||||
allocBlock();
|
||||
void* ret = next_block;
|
||||
next_block = *cast(void**)next_block;
|
||||
next_block = *cast(void**) next_block;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void allocBlock()
|
||||
{
|
||||
next_block = cast(void*)AlignedMallocator.instance.alignedAllocate(EntityManager.page_size * EntityManager.pages_in_block, EntityManager.page_size);
|
||||
foreach(i;0..EntityManager.pages_in_block-1)
|
||||
next_block = cast(void*) AlignedMallocator.instance.alignedAllocate(
|
||||
EntityManager.page_size * EntityManager.pages_in_block, EntityManager.page_size);
|
||||
foreach (i; 0 .. EntityManager.pages_in_block - 1)
|
||||
{
|
||||
void** pointer = cast(void**)(next_block + i * EntityManager.page_size);
|
||||
*pointer = next_block + (i+1) * EntityManager.page_size;
|
||||
*pointer = next_block + (i + 1) * EntityManager.page_size;
|
||||
}
|
||||
void** pointer = cast(void**)(
|
||||
next_block + (EntityManager.pages_in_block - 1) * EntityManager.page_size);
|
||||
*pointer = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue