Entt: Is there a reason why you can't do single-component full-owning groups?

Created on 4 Jan 2020  路  6Comments  路  Source: skypjack/entt

I have a group of components I'd like packed together and fully-owned via an entt::group but the API doesn't like that there's only one component in the registry.group<component>() template specifier.

This seems like a deliberate design decision, leading me to believe I'm missing something about groups.

Is what I'm doing an anti-pattern for some reason?

question

All 6 comments

Uhm... I think you misunderstood how groups work. They are meant to arrange components from different pools in such a way that multi-component iterations are then linear, with no jumps nor branches (the so called _perfect SoA_).
Not sure what you're trying to do but it seems to me it's something more on the line of - _I want to group the entities that have component position for which x is within 10 and 100_. Am I wrong?

No, I don't care about filtering based on the component's data.

I have a particular component that is iterated over for _all_ entities (that have it) unconditionally, but is not paired with any other component at all. I want to make iterating over _all_ instances of that component as fast as possible, so I'd like it to be packed into its own list similar to how groups seem to do so.

Now that I'm writing this, I'm realizing that this is probably the default way entt structures instances of components, anyway...

Anyway, I guess the X-Y question is really: _how do I iterate over all instances of a single component in the most efficient way possible_? 馃槄

Well, in this case, a single component view is what you want. It iterates all instances at once with no jumps nor branches. :+1:
If you want even more performance and you don't plan to add or remove instances of the same component during iterations, you can also use the raw access (data<T>, raw<T> and size<T>) to iterate directly the internal arrays of entities and components for the given type.
This is the best you can expect overall, no matter what. You're iterating a plain array from 0 to N-1 in this case. :wink:

That's exactly the information I needed ^^

Thanks for a great library, it has really been a breeze to use. 鉂わ笍

Thank you for using it! I'm looking forward to having your project in the list of showcases. :wink:
Please, feel free to give me your feedback whenever you want. This is what helped to improve EnTT so far. :+1:

Absolutely, will do! :)

Was this page helpful?
0 / 5 - 0 ratings