Skip to content

Commit f47198a

Browse files
committed
fix typos + consistency + update filter docs
why is dereferenced so hard to spell
1 parent 9384cc9 commit f47198a

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

crates/bevy_ecs/src/change_detection.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,18 @@ pub const MAX_CHANGE_AGE: u32 = u32::MAX - (2 * CHECK_TICK_THRESHOLD - 1);
4343
/// ```
4444
///
4545
pub trait DetectChanges {
46-
/// Returns true if (and only if) this value been added since the last execution of this
47-
/// system.
46+
/// Returns `true` if this value was added after the system last ran, `false` otherwise.
4847
fn is_added(&self) -> bool;
4948

50-
/// Returns true if (and only if) this value been changed since the last execution of this
51-
/// system.
49+
/// Returns `true` if this value was added or mutably dereferenced after the system last ran, `false` otherwise.
5250
fn is_changed(&self) -> bool;
5351

54-
/// Manually flags this value as having been changed. This normally isn't
55-
/// required because accessing this pointer mutably automatically flags this
56-
/// value as "changed".
52+
/// Flags this value as having been changed.
53+
///
54+
/// Mutably accessing this smart pointer will automatically flag this value as having been changed.
55+
/// However, mutation through interior mutability requires manual reporting.
5756
///
58-
/// **Note**: This operation is irreversible.
57+
/// **Note**: This operation cannot be undone.
5958
fn set_changed(&mut self);
6059
}
6160

crates/bevy_ecs/src/component.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl Components {
339339
}
340340
}
341341

342-
/// Stores two [`World`](crate::world::World) "ticks" denoting when the component was added and when it was last changed (added or mutably-deferenced).
342+
/// Records when a component was added and when it was last mutably dereferenced (or added).
343343
#[derive(Clone, Debug)]
344344
pub struct ComponentTicks {
345345
pub(crate) added: u32,
@@ -364,7 +364,7 @@ impl ComponentTicks {
364364
}
365365

366366
#[inline]
367-
/// Returns `true` if the component was added or mutably-dereferenced after the system last ran, `false` otherwise.
367+
/// Returns `true` if the component was added or mutably dereferenced after the system last ran, `false` otherwise.
368368
pub fn is_changed(&self, last_change_tick: u32, change_tick: u32) -> bool {
369369
// This works even with wraparound because the world tick (`change_tick`) is always "newer" than
370370
// `last_change_tick` and `self.changed`, and we scan periodically to clamp `ComponentTicks` values

crates/bevy_ecs/src/query/filter.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -593,17 +593,12 @@ macro_rules! impl_tick_filter {
593593
}
594594

595595
impl_tick_filter!(
596-
/// Filter that retrieves components of type `T` that have been added since the last execution
597-
/// of this system.
596+
/// A filter on a component that only retains results added after the system last ran.
598597
///
599-
/// This filter is useful to do one-time post-processing on components.
598+
/// A common use for this filter is one-time initialization.
600599
///
601-
/// Because the ordering of systems can change and this filter is only effective on changes
602-
/// before the query executes you need to use explicit dependency ordering or ordered stages to
603-
/// avoid frame delays.
604-
///
605-
/// If instead behavior is meant to change on whether the component changed or not
606-
/// [`ChangeTrackers`](crate::query::ChangeTrackers) may be used.
600+
/// To retain all results without filtering but still check whether they were added after the
601+
/// system last ran, use [`ChangeTrackers<T>`](crate::query::ChangeTrackers).
607602
///
608603
/// # Examples
609604
///
@@ -633,18 +628,15 @@ impl_tick_filter!(
633628
);
634629

635630
impl_tick_filter!(
636-
/// Filter that retrieves components of type `T` that have been changed since the last
637-
/// execution of this system.
638-
///
639-
/// This filter is useful for synchronizing components, and as a performance optimization as it
640-
/// means that the query contains fewer items for a system to iterate over.
631+
/// A filter on a component that only retains results added or mutably dereferenced after the system last ran.
632+
///
633+
/// A common use for this filter is avoiding redundant work when values have not changed.
641634
///
642-
/// Because the ordering of systems can change and this filter is only effective on changes
643-
/// before the query executes you need to use explicit dependency ordering or ordered
644-
/// stages to avoid frame delays.
635+
/// **Note** that simply *mutably dereferencing* a component is considered a change ([`DerefMut`](std::ops::DerefMut)).
636+
/// Bevy does not compare components to their previous values.
645637
///
646-
/// If instead behavior is meant to change on whether the component changed or not
647-
/// [`ChangeTrackers`](crate::query::ChangeTrackers) may be used.
638+
/// To retain all results without filtering but still check whether they were changed after the
639+
/// system last ran, use [`ChangeTrackers<T>`](crate::query::ChangeTrackers).
648640
///
649641
/// # Examples
650642
///

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<'w, T: Resource> Res<'w, T> {
225225
self.ticks.is_added(self.last_change_tick, self.change_tick)
226226
}
227227

228-
/// Returns `true` if the resource was added or mutably-dereferenced after the system last ran, `false` otherwise.
228+
/// Returns `true` if the resource was added or mutably dereferenced after the system last ran, `false` otherwise.
229229
pub fn is_changed(&self) -> bool {
230230
self.ticks
231231
.is_changed(self.last_change_tick, self.change_tick)
@@ -780,7 +780,7 @@ impl<'w, T: 'static> NonSend<'w, T> {
780780
self.ticks.is_added(self.last_change_tick, self.change_tick)
781781
}
782782

783-
/// Returns `true` if the resource was added or mutably-dereferenced after the system last ran, `false` otherwise.
783+
/// Returns `true` if the resource was added or mutably dereferenced after the system last ran, `false` otherwise.
784784
pub fn is_changed(&self) -> bool {
785785
self.ticks
786786
.is_changed(self.last_change_tick, self.change_tick)

0 commit comments

Comments
 (0)