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] - Rename Tick::is_older_than to Tick::is_newer_than #7561

Closed
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ macro_rules! change_detection_impl {
fn is_added(&self) -> bool {
self.ticks
.added
.is_older_than(self.ticks.last_change_tick, self.ticks.change_tick)
.is_newer_than(self.ticks.last_change_tick, self.ticks.change_tick)
}

#[inline]
fn is_changed(&self) -> bool {
self.ticks
.changed
.is_older_than(self.ticks.last_change_tick, self.ticks.change_tick)
.is_newer_than(self.ticks.last_change_tick, self.ticks.change_tick)
}

#[inline]
Expand Down Expand Up @@ -653,14 +653,14 @@ impl<'a> DetectChanges for MutUntyped<'a> {
fn is_added(&self) -> bool {
self.ticks
.added
.is_older_than(self.ticks.last_change_tick, self.ticks.change_tick)
.is_newer_than(self.ticks.last_change_tick, self.ticks.change_tick)
}

#[inline]
fn is_changed(&self) -> bool {
self.ticks
.changed
.is_older_than(self.ticks.last_change_tick, self.ticks.change_tick)
.is_newer_than(self.ticks.last_change_tick, self.ticks.change_tick)
}

#[inline]
Expand Down
10 changes: 6 additions & 4 deletions crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,10 @@ impl Tick {
}

#[inline]
/// Returns `true` if the tick is older than the system last's run.
pub fn is_older_than(&self, last_change_tick: u32, change_tick: u32) -> bool {
/// Returns `true` if this `Tick` occurred since the system's `last_change_tick`.
///
/// `change_tick` is the current tick of the system, used as a reference to help deal with wraparound.
pub fn is_newer_than(&self, last_change_tick: u32, change_tick: u32) -> bool {
// This works even with wraparound because the world tick (`change_tick`) is always "newer" than
// `last_change_tick` and `self.tick`, and we scan periodically to clamp `ComponentTicks` values
// so they never get older than `u32::MAX` (the difference would overflow).
Expand Down Expand Up @@ -670,13 +672,13 @@ impl ComponentTicks {
#[inline]
/// Returns `true` if the component was added after the system last ran.
pub fn is_added(&self, last_change_tick: u32, change_tick: u32) -> bool {
self.added.is_older_than(last_change_tick, change_tick)
self.added.is_newer_than(last_change_tick, change_tick)
}

#[inline]
/// Returns `true` if the component was added or mutably dereferenced after the system last ran.
pub fn is_changed(&self, last_change_tick: u32, change_tick: u32) -> bool {
self.changed.is_older_than(last_change_tick, change_tick)
self.changed.is_newer_than(last_change_tick, change_tick)
}

pub(crate) fn new(change_tick: u32) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ macro_rules! impl_tick_filter {
.debug_checked_unwrap()
.get(table_row.index())
.deref()
.is_older_than(fetch.last_change_tick, fetch.change_tick)
.is_newer_than(fetch.last_change_tick, fetch.change_tick)
}
StorageType::SparseSet => {
let sparse_set = &fetch
Expand All @@ -518,7 +518,7 @@ macro_rules! impl_tick_filter {
$get_sparse_set(sparse_set, entity)
.debug_checked_unwrap()
.deref()
.is_older_than(fetch.last_change_tick, fetch.change_tick)
.is_newer_than(fetch.last_change_tick, fetch.change_tick)
}
}
}
Expand Down