Implement WorldQuery for MainWorld and RenderWorld components#15745
Merged
alice-i-cecile merged 15 commits intobevyengine:mainfrom Oct 13, 2024
Merged
Implement WorldQuery for MainWorld and RenderWorld components#15745alice-i-cecile merged 15 commits intobevyengine:mainfrom
WorldQuery for MainWorld and RenderWorld components#15745alice-i-cecile merged 15 commits intobevyengine:mainfrom
Conversation
Trashtalk217
approved these changes
Oct 8, 2024
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
chescock
reviewed
Oct 9, 2024
bushrat011899
approved these changes
Oct 9, 2024
Contributor
bushrat011899
left a comment
There was a problem hiding this comment.
The implementation is valid, but I agree with @chescock on adjusting the implementation to explicitly forward to the underlying implementation in all cases.
Contributor
There was a problem hiding this comment.
This doc comment should be adjusted to mention the new impl instead.
SpecificProtagonist
approved these changes
Oct 13, 2024
bushrat011899
approved these changes
Oct 13, 2024
chescock
approved these changes
Oct 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
#15320 is a particularly painful breaking change, and the new
RenderEntityin particular is very noisy, with a lot oflet entity = entity.id()spam.Solution
Implement
WorldQuery,QueryDataandReadOnlyQueryDataforRenderEntityandWorldEntity.These work the same as the
Entityimpls from a user-facing perspective: they simply return an owned (copied)Entityidentifier. This dramatically reduces noise and eases migration.Under the hood, these impls defer to the implementations for
&Tfor everything other than the "call .id() for the user" bit, as they involve read-only access to component data. Doing it this way (as opposed to implementing a custom fetch, as tried in the first commit) dramatically reduces the maintenance risk of complex unsafe code outside ofbevy_ecs.To make this easier (and encourage users to do this themselves!), I've made
ReadFetchandWriteFetchslightly more public: they're no longerdoc(hidden). This is a good change, since trying to vendor the logic is much worse than just deferring to the existing tested impls.Testing
I've run a handful of rendering examples (breakout, alien_cake_addict, auto_exposure, fog_volumes, box_shadow) and nothing broke.
Follow-up
We should lint for the uses of
&RenderEntityand&MainEntityin queries: this is just less nice for no reason.