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

Improve docs for WorldQuery #17654

Merged

Conversation

alice-i-cecile
Copy link
Member

Objective

While working on #17649, I found the docs for WorldQuery and the related traits frustratingly vague.

Solution

Clarify them and add some more tangible advice.

Also fix a copy-pasted typo in related comments.

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-ECS Entities, components, systems, and events D-Complex Quite challenging from either a design or technical perspective. Ask for help! D-Unsafe Touches with unsafe code in some way S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 3, 2025
crates/bevy_ecs/src/query/world_query.rs Outdated Show resolved Hide resolved
/// For `QueryFilter` this will be either `()`, or a `bool` indicating whether the entity should be included
/// or a tuple of such things.
/// Archetypal query filters (like `With`) set this to `()`, as the filtering is done by selecting the archetypes to iterate over,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of weird that QueryFilters even have an Item. I think it's mostly because they used to be a single trait, and the change to separate them tried to minimize changes.

Would be more clear if we moved Item and fetch from WorldQuery to QueryData, and then did all the filtering in filter_fetch? (Not in this PR, of course.) It doesn't look like fetch is ever called on a QueryFilter outside its own implementation, so that might work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spun out into #17662. Fully agree.

crates/bevy_ecs/src/query/filter.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Carter0 Carter0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good stuff!

Co-authored-by: James O'Brien <[email protected]>
@alice-i-cecile alice-i-cecile removed the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Feb 3, 2025
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 3, 2025
@alice-i-cecile
Copy link
Member Author

Really excellent suggestions; thank you all. Waiting on one re-review before merging.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 3, 2025
Merged via the queue into bevyengine:main with commit 0ca9d69 Feb 3, 2025
29 checks passed
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
# Objective

While working on bevyengine#17649, I found the docs for `WorldQuery` and the
related traits frustratingly vague.

## Solution

Clarify them and add some more tangible advice.

Also fix a copy-pasted typo in related comments.

---------

Co-authored-by: James O'Brien <[email protected]>
joshua-holmes pushed a commit to joshua-holmes/bevy that referenced this pull request Feb 5, 2025
# Objective

While working on bevyengine#17649, I found the docs for `WorldQuery` and the
related traits frustratingly vague.

## Solution

Clarify them and add some more tangible advice.

Also fix a copy-pasted typo in related comments.

---------

Co-authored-by: James O'Brien <[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 C-Docs An addition or correction to our documentation D-Complex Quite challenging from either a design or technical perspective. Ask for help! D-Unsafe Touches with unsafe code in some way S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants