ECS
Posted: June 12th, 2019, 8:13 am
Hi there!
I am trying to implement an ECS (Entity Component System). Maybe someone has experience with that. And here comes the part I do not really get:
You have some kind of manager to store systems and components "ordered" by their type. And in the systems, you go through all components that the system needs to get its job done and it manipulates the components. If the system only uses one component type its fine in terms of cache, because the compoents that belong to that type are all stored "together". But if you use more then one, you constantly have to switch between component vectors because you get the first one of the first component type, the first one of the second and so one. Thats bad of the cache, isnt it? Another approach is to store the components for a system packed, in an AOS fashion. If a system uses for example a pos and move component, the vector would like this: pos0, move0, pos1, move1, ... and not like pos0, pos1, ... and move0, move1. But now the problem is that if two systems use the same component, this falls apart, because you cannot pack them together like that, because the same component is needed in different arrays and that does not work, because the data has to be the same to all systems. So I do not really get it. Maybe someone can clarify!
Thanks,
Florian
I am trying to implement an ECS (Entity Component System). Maybe someone has experience with that. And here comes the part I do not really get:
You have some kind of manager to store systems and components "ordered" by their type. And in the systems, you go through all components that the system needs to get its job done and it manipulates the components. If the system only uses one component type its fine in terms of cache, because the compoents that belong to that type are all stored "together". But if you use more then one, you constantly have to switch between component vectors because you get the first one of the first component type, the first one of the second and so one. Thats bad of the cache, isnt it? Another approach is to store the components for a system packed, in an AOS fashion. If a system uses for example a pos and move component, the vector would like this: pos0, move0, pos1, move1, ... and not like pos0, pos1, ... and move0, move1. But now the problem is that if two systems use the same component, this falls apart, because you cannot pack them together like that, because the same component is needed in different arrays and that does not work, because the data has to be the same to all systems. So I do not really get it. Maybe someone can clarify!
Thanks,
Florian