star-entity icon indicating copy to clipboard operation
star-entity copied to clipboard

Component storage

Open jameslzhu opened this issue 10 years ago • 1 comments

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.

jameslzhu avatar Jul 10 '14 04:07 jameslzhu

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.

jameslzhu avatar Nov 05 '14 01:11 jameslzhu