|
|
|
|
|
by cepacked
905 days ago
|
|
In a context where you have thousands of entities, it's very rare that you'll loop all over them from 0 to N.
In such context entities are always partitioned in space. You interact with one entity and you update the entities around it. For which you'll query the spatial partition to get list of entities around, and they won't be contigious in memory. You may have one loop to update all entities but that's it. And will you even update all of them ? What about the ones that are not visible ? Maybe you want to update only the visible ones .. in that case you query the partition to get the ones visible around your camera So practically you never query the ecs registry to loop over all of them |
|
I've written about the details here: https://taintedcoders.com/bevy/archetypes/
The gist is that instead of partitioning by type you sub partition by usage. Bevy does this by optimizing your storage based on the bundles (groups of components) you create. Flecs does the same but I'm not sure of the exact mechanism.