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

[Merged by Bors] - Fix DetectChanges::last_changed returning the wrong tick #7560

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub trait DetectChanges {
/// Returns `true` if this value was added or mutably dereferenced after the system last ran.
fn is_changed(&self) -> bool;

/// Returns the change tick recording the previous time this data was changed.
/// Returns the change tick recording the time this data was most recently changed.
///
/// Note that components and resources are also marked as changed upon insertion.
///
Expand Down Expand Up @@ -103,7 +103,10 @@ pub trait DetectChangesMut: DetectChanges {
/// **Note**: This operation cannot be undone.
fn set_changed(&mut self);

/// Manually sets the change tick recording the previous time this data was mutated.
/// Manually sets the change tick recording the previous time this data's changed status was checked.
chrisjuchem marked this conversation as resolved.
Show resolved Hide resolved
///
/// Note that this is *not* the same data that is returned by [`last_changed`](DetectChanges::last_changed).
/// Instead, it is the reference tick that is compared to that tick to determine if the change is "new" or not.
///
/// # Warning
/// This is a complex and error-prone operation, primarily intended for use with rollback networking strategies.
Expand Down Expand Up @@ -150,7 +153,7 @@ macro_rules! change_detection_impl {

#[inline]
fn last_changed(&self) -> u32 {
self.ticks.last_change_tick
self.ticks.changed.tick
}
}

Expand Down