Open newobj opened 7 years ago
With the default storage implementation, that is correct, yes.
Thanks Alec. So, taking this a bit further, am I correct in understanding that iterating (EM::each) over a particular component type is linear in the number of entities, not in the number of component type instances?
I'm curious whether this strategy was the simplest thing that worked generally, and/or if you put a lot of effort into other approaches that didn't pan out? I'm writing my own ECS framework as a learning exercise and trying to keep scale of component instances separate from entity instances. The exercise is a bit silly since EntityX is so awesome, but never the less... :P
Reading the code, it seems to me like components share the index of their Entity, e.g. the Position Component for Entity #1,000,000 will the 1,000,000th Position Component in the Position Component Pool.
Am I understanding this correctly? If I have 1,000,000 entities, and there is one instance of the Foobar component, but it happens to be on entity 999,999, then we'll have to eat the memory of unused 999,998 unused components in the Foobar pool?
Am I reading the code correctly? If I'm wrong, can you help me understand how?
I'm mainly looking at EntityManager::assign to make this determination, specifically in the placement new:
where
pool
is the component pool, andid
is the entity id.