-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Query::get_component
does not respect filters
#9904
Comments
As the filters can be used to ensure mutual exclusion, this is a soundness bug, and we should address this as soon as possible. I'm actually strongly tempted to say we should remove |
How does |
The component can be in an arbitrary position or nested deep in a worldquery. You can't solve this with metaprogramming either in the case where |
I think we should remove it too. It's rarely useful as well. |
Removing the unsoundness tag as it's only unsound if this ignores Even with this in mind, I'm still in support of removing the API since it's often a performance footgun to use over |
Removal is discussed more in #9910 |
…9920) # Objective - (Partially) Fixes #9904 - Acts on #9910 ## Solution - Deprecated the relevant methods from `Query`, cascading changes as required across Bevy. --- ## Changelog - Deprecated `QueryState::get_component_unchecked_mut` method - Deprecated `Query::get_component` method - Deprecated `Query::get_component_mut` method - Deprecated `Query::component` method - Deprecated `Query::component_mut` method - Deprecated `Query::get_component_unchecked_mut` method ## Migration Guide ### `QueryState::get_component_unchecked_mut` Use `QueryState::get_unchecked_manual` and select for the exact component based on the structure of the exact query as required. ### `Query::(get_)component(_unchecked)(_mut)` Use `Query::get` and select for the exact component based on the structure of the exact query as required. - For mutable access (`_mut`), use `Query::get_mut` - For unchecked access (`_unchecked`), use `Query::get_unchecked` - For panic variants (non-`get_`), add `.unwrap()` ## Notes - `QueryComponentError` can be removed once these deprecated methods are also removed. Due to an interaction with `thiserror`'s derive macro, it is not marked as deprecated.
…evyengine#9920) # Objective - (Partially) Fixes bevyengine#9904 - Acts on bevyengine#9910 ## Solution - Deprecated the relevant methods from `Query`, cascading changes as required across Bevy. --- ## Changelog - Deprecated `QueryState::get_component_unchecked_mut` method - Deprecated `Query::get_component` method - Deprecated `Query::get_component_mut` method - Deprecated `Query::component` method - Deprecated `Query::component_mut` method - Deprecated `Query::get_component_unchecked_mut` method ## Migration Guide ### `QueryState::get_component_unchecked_mut` Use `QueryState::get_unchecked_manual` and select for the exact component based on the structure of the exact query as required. ### `Query::(get_)component(_unchecked)(_mut)` Use `Query::get` and select for the exact component based on the structure of the exact query as required. - For mutable access (`_mut`), use `Query::get_mut` - For unchecked access (`_unchecked`), use `Query::get_unchecked` - For panic variants (non-`get_`), add `.unwrap()` ## Notes - `QueryComponentError` can be removed once these deprecated methods are also removed. Due to an interaction with `thiserror`'s derive macro, it is not marked as deprecated.
Bevy version
0.11.2
What you did
Created a system query:
query: Query<&Transform, Changed<Transform>>
and then usedquery.get_component(entity_with_unchanging_transform)
.What went wrong
I expected to get no result since the query has the Changed filter.
I got a result.
Additional information
theories about what might be going wrong
From looking at the source it seems like the
Query::get_component[_mut]()
variants are missing logic to respect the filter of the query.Or the name of the method fails to clarify its use. Perhaps
get_component_ignore_filter()
is more suitable if this is the intended behaviour.links to related bugs, PRs or discussions
Clarify how
Query::get_component
works #9523Query::get_component
should mention that the compenent must be part of the query #9011The text was updated successfully, but these errors were encountered: