Some preformance tests and added EntityMeta structure
This commit is contained in:
parent
4bd5a37b5d
commit
f6e7af1014
4 changed files with 385 additions and 20 deletions
|
|
@ -45,6 +45,28 @@ struct Entity
|
|||
uint ind = cast(uint)((cast(void*)&this - block.dataBegin()) / EntityID.sizeof());
|
||||
return cast(T*)(cast(void*)block + info.deltas[T.component_id] + ind * T.sizeof);
|
||||
}
|
||||
|
||||
EntityMeta getMeta()
|
||||
{
|
||||
EntityMeta meta;
|
||||
meta.block = gEM.getMetaData(&this);
|
||||
static if (EntityID.sizeof == 8)
|
||||
meta.index = cast(ushort)((cast(void*)&this - meta.block.dataBegin()) >> 3);
|
||||
else
|
||||
meta.index = cast(ushort)((cast(void*)&this - meta.block.dataBegin()) / EntityID.sizeof());
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
|
||||
struct EntityMeta
|
||||
{
|
||||
EntityManager.EntitiesBlock* block;
|
||||
ushort index;
|
||||
|
||||
T* getComponent(T)() const
|
||||
{
|
||||
return cast(T*)(cast(void*)block + block.type_info.deltas[T.component_id] + index * T.sizeof);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue