-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow entities to store multiple components with the same type #1527
Comments
Relationship to Indexes
|
Naming and Use Cases
|
Archetype Fragmentation
|
One more bit of detail here:
Storing the index in Archetypes wouldn't fragment tables but it would fragment access patterns in those table. Storing the indices in something that doesn't affect archetype identity (ex: a This could be "optimized" by sorting the Entity list according to table order (both in the Archetype impl and in the "separate storage" impl). The benefit of doing that in the Archetype is that you only need to do the sorting once (and it would also improve "untagged" / normal mixed table+sparse set iteration performance) |
I was thinking more along the lines of "flyweight". Back when Legion had tags, in one of the experiments I did with it I've stored immutable data common among kinds of entities in a tag, e.g. a copy of the base mob properties, and handles to sprites and sounds it used. Although, this could very well be a niche case, since I've spawed entities fully-formed with all the components they would ever use, and the archetypes never changed after first being populated. |
What would the usage API look like? How would you query for a specific tagged archetype? |
So you could even have some kind of CoW components, that would be great for Bundles with lots of defaults. |
This could be useful for batching/instancing entities for rendering. If entities that share the same mesh and material can be easily organized into groups, that saves trouble down the line. For reference, the Unity ECS system does exactly this and takes advantage of it for instancing. |
This tracking issue comes out of #1525. This feature is still very much up for debate, and this initial post paraphrases the initial definition by @cart from that PR .
Definition
Tags are archetype-specific by-value data that affects archetype identity
Usage
ArchetypeA could have [A, B, C] table components and [D(1)] "tag" component. ArchetypeB could have [A, B, C] table components and a [D(2)] tag component. The archetypes are different, despite both having D tags because the value inside D is different.
Implementation
Tags could potentially build on top of the
archetype.unique_components
added in #1525 for Resource storage.The text was updated successfully, but these errors were encountered: