-
-
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
[Merged by Bors] - Deprecate ChangeTrackers<T>
in favor of Ref<T>
#7306
Conversation
) { | ||
for (entity, component, trackers) in &query { | ||
info!("{:?}: {:?} -> {:?}", entity, component, trackers); | ||
// By using `Ref`, the query is not filtered but the information is available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems incorrect. I'm not sure that it was ever correct however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original intended meaning is that the query is not filtered based on change detection, but you can still access the change detection info. I tried to preserve that meaning when rewriting this section of code.
A potentially more controversial option is just to have |
A nice thing about making |
Yeah, I think I'm sold on doing that, but it should be in a new PR. Are you two sold on deprecating |
I was a bit concerned that someone might re-add this I do think we should avoid actually removing the |
I guess there is also a code clarity question, is |
It's a bit clearer, but it also adds yet another concept to learn. |
I'd like to consider this for 0.10 so we don't miss out on a deprecation cycle. Obviously it's not super important, though. |
I want this tbh. Better symmetry. Once we separate |
That's two SMEs: merging :) bors r+ |
# Objective `ChangeTrackers<>` is a `WorldQuery` type that lets you access the change ticks for a component. #7097 has added `Ref<>`, which gives access to a component's value in addition to its change ticks. Since bevy's access model does not separate a component's value from its change ticks, there is no benefit to using `ChangeTrackers<T>` over `Ref<T>`. ## Solution Deprecate `ChangeTrackers<>`. --- ## Changelog * `ChangeTrackers<T>` has been deprecated. It will be removed in Bevy 0.11. ## Migration Guide `ChangeTrackers<T>` has been deprecated, and will be removed in the next release. Any usage should be replaced with `Ref<T>`. ```rust // Before (0.9) fn my_system(q: Query<(&MyComponent, ChangeTrackers<MyComponent>)>) { for (value, trackers) in &q { if trackers.is_changed() { // Do something with `value`. } } } // After (0.10) fn my_system(q: Query<Ref<MyComponent>>) { for value in &q { if value.is_changed() { // Do something with `value`. } } } ```
Pull request successfully merged into main. Build succeeded:
|
ChangeTrackers<T>
in favor of Ref<T>
ChangeTrackers<T>
in favor of Ref<T>
`ChangeTrackers<>` is a `WorldQuery` type that lets you access the change ticks for a component. bevyengine#7097 has added `Ref<>`, which gives access to a component's value in addition to its change ticks. Since bevy's access model does not separate a component's value from its change ticks, there is no benefit to using `ChangeTrackers<T>` over `Ref<T>`. Deprecate `ChangeTrackers<>`. --- * `ChangeTrackers<T>` has been deprecated. It will be removed in Bevy 0.11. `ChangeTrackers<T>` has been deprecated, and will be removed in the next release. Any usage should be replaced with `Ref<T>`. ```rust // Before (0.9) fn my_system(q: Query<(&MyComponent, ChangeTrackers<MyComponent>)>) { for (value, trackers) in &q { if trackers.is_changed() { // Do something with `value`. } } } // After (0.10) fn my_system(q: Query<Ref<MyComponent>>) { for value in &q { if value.is_changed() { // Do something with `value`. } } } ```
Objective
ChangeTrackers<>
is aWorldQuery
type that lets you access the change ticks for a component. #7097 has addedRef<>
, which gives access to a component's value in addition to its change ticks. Since bevy's access model does not separate a component's value from its change ticks, there is no benefit to usingChangeTrackers<T>
overRef<T>
.Solution
Deprecate
ChangeTrackers<>
.Changelog
ChangeTrackers<T>
has been deprecated. It will be removed in Bevy 0.11.Migration Guide
ChangeTrackers<T>
has been deprecated, and will be removed in the next release. Any usage should be replaced withRef<T>
.