-
Hi there, I'm just at my beginning of working with EnTT, and am greatly enjoying using it so far. I just have a (probably dumb) question about group ownership that I'm not clear on. If I have Group 1, which has full ownership of components A and B, and I want to have another group, Group 2, which returns entities with components B and C, should Group 2 always be a partially owning group, or is it only during the lifetime of Group 1/if Group 2 is nested in Group 1? For example during my game loop I currently have:
Is the second group allowed to own the transform component? Secondly, is creating the group and iterating each game loop a reasonable way to implement this? Or should I create the group once at creation and just do the iteration each loop. Are the iterators for the group created upon group creation, or can I add and remove components owned by the group and still be able to iterate over the group. Apologies if the answer is in documentation, I don't think I've developed enough understanding of EnTT to properly find it. Thanks for any answers :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unfortunately no, the registry owns the groups and extends their lifetime.
Group creation is super cheap (but for the first time and only if the registry already contains thousands and thousands of entities and components). You don't have to store them aside.
Adding/Removing may invalidate iterators, there is a note in the documentation. However, you don't have to recreate the group to renew iterators. Just... reassign them, as you would do with an As a side note, Discord and Gitter links if you want to have a more direct chat with other devs. 🙂 👍 |
Beta Was this translation helpful? Give feedback.
Unfortunately no, the registry owns the groups and extends their lifetime.
However, my two cents: use a view until you know that you've a bottleneck, than switch to a group. Far easier to reason about in the long term.
Group creation is super cheap (but for the first time and only if the registry already contains thousands and thousands of entities and components). You don't have to store them aside.