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 all commits
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
10 changes: 6 additions & 4 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,7 @@ 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 time when this data was last mutated.
///
/// # Warning
/// This is a complex and error-prone operation, primarily intended for use with rollback networking strategies.
Expand Down Expand Up @@ -150,7 +150,7 @@ macro_rules! change_detection_impl {

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

Expand Down Expand Up @@ -186,7 +186,9 @@ macro_rules! change_detection_mut_impl {

#[inline]
fn set_last_changed(&mut self, last_change_tick: u32) {
self.ticks.last_change_tick = last_change_tick
self.ticks
.changed
.set_changed(last_change_tick);
}

#[inline]
Expand Down