Re:ECS, Finally
by GenericCanadian on Sunday December 31, 2023 @07:03PM
(#38828574)
In a naive ECS system this might be true, but mature ECS systems use archetypes which partition based on usage to maintain the contiguous memory.
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.
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