Skip to content
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

Implement QueryData for &Archetype #12393

Closed
urben1680 opened this issue Mar 9, 2024 · 1 comment · Fixed by #12398
Closed

Implement QueryData for &Archetype #12393

urben1680 opened this issue Mar 9, 2024 · 1 comment · Fixed by #12398
Labels
A-ECS Entities, components, systems, and events A-Networking Sending data between clients, servers and machines C-Feature A new feature, making something new possible

Comments

@urben1680
Copy link
Contributor

urben1680 commented Mar 9, 2024

Description of the feature request

&Archetype is a reference that can be accessed with EntityRef and EntityMut in a query. These latter two however hurt parallization when queried. If one does that only to get &Archetype, that restriction is needless as the archetype reference alone does not require further access to the component data.
It would make sense to offer this type as a QueryData that can also be freely added to a query with Query::transmute_lense.
Also, since the number of archetypes a query accesses is most likely much smaller than the number of matched entites, one could consider giving Query a new method that returns an Iterator over &Archetypes.

What problem does this solve or what need does it fill?

I have no personal use case, I just noticed that when looking through the docs to answer someone's question, what else than components can be queried. If someone can come up with an actual use case, please share it in this issue.

@urben1680 urben1680 added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Mar 9, 2024
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events A-Networking Sending data between clients, servers and machines and removed S-Needs-Triage This issue needs to be labelled labels Mar 9, 2024
@alice-i-cecile
Copy link
Member

I've seen this type of pattern used for efficient networking-based serialization and deserialization of entities.

github-merge-queue bot pushed a commit that referenced this issue Mar 29, 2024
# Objective
Fixes #12392, fixes #12393, and fixes #11387. Implement QueryData for
Archetype and EntityLocation.

## Solution
Add impls for both of the types.

---

## Changelog
Added: `&Archetype` now implements `QueryData`
Added: `EntityLocation` now implements `QueryData`

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-Networking Sending data between clients, servers and machines C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants