-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Due to storing components in type-erased byte vectors, Larecs does currently support only trivial types that don't contain any pointers and heap-allocated fields. Here is an idea how to solve that. I did this in the Julia port of Ark, Ark.jl.
There is a "component storage" for every component type C, with a type like
Vector[ Optional[Vector[C]] ]
Component storages are stored in a tuple or another collection for heterogenious (but known) types. This tuple-like type can be generated at compile-time, as components are parameters of the world. This allows us to store component instances with known type.
Archetypes don't have (type-erased) columns anymore, but just contain the list of component IDs they have, and the usual masks.
Arch. ID Component Storages Archetypes
A B C ...
0 V[A] - - [0]
3 V[A] V[B] - [0, 1]
2 - - V[C] [2]
4 V[A] V[B] V[C] [0, 1, 2]
:
: ^
|
Component storage for A
As queries are also parameterized by their component types, they can get their component storages at compile time.