star-entity
star-entity copied to clipboard
Component storage
Currently, components are limited to being classes
; the EntityManager
defines a member
Object[][] _components;
enabling it to store a generic object deriving from Object (essentially, classes
, not structs
).
However, this conflicts with the cache-friendly layout of having contiguous data, instead containing references to objects allocated on the heap rather than on the stack; this nullifies the speed performance boost enabled by ECS.
The idea is to reimplement the _components
member variable as an object pool, allowing space to be reused and contiguous in memory.
New idea: define _components
as follows:
void[][] _components;
and storing the component-to-index mapping in a
size_t[string] _componentTypes;
where the string key is obtained by std.traits.fullyQualifiedName
or the .mangleof
property.