-removed LinearLayout switch (from now it's default behaviour)

This commit is contained in:
Mergul 2018-09-29 20:49:07 +02:00
parent 783ef72eae
commit bb3f07ac70
4 changed files with 140 additions and 348 deletions

View file

@ -6,11 +6,6 @@ struct EntityID
{
uint id;
uint counter;
/*int opCmp(ref const EntityID s) const
{
return id < s.id;
}*/
}
struct Entity
@ -28,18 +23,12 @@ struct Entity
EntityManager.EntityInfo* info = block.type_info;
if (T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0)
return null;
version (LinearLayout)
{
static if (EntityID.sizeof == 8)
uint ind = cast(uint)((cast(void*)&this - block.dataBegin()) >> 3);
else
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);
}
static if (EntityID.sizeof == 8)
uint ind = cast(uint)((cast(void*)&this - block.dataBegin()) >> 3);
else
{
return cast(T*)(cast(void*)&this + info.deltas[T.component_id]);
}
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);
}
}
@ -50,16 +39,7 @@ export struct EntityTemplate
T* getComponent(T)()
{
version(LinearLayout)
{
if(T.component_id >= info.tmpl_deltas.length)return null;
return cast(T*)(entity_data.ptr + info.tmpl_deltas[T.component_id]);
}
else
{
if(T.component_id >= info.deltas.length)return null;
return cast(T*)(entity_data.ptr + info.deltas[T.component_id]);
}
if(T.component_id >= info.tmpl_deltas.length)return null;
return cast(T*)(entity_data.ptr + info.tmpl_deltas[T.component_id]);
}
}