Skip to content

Commit

Permalink
Rename empty and provide variant for TRUE
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiFire13 committed Jul 19, 2024
1 parent a0cbf00 commit 2a23d74
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions crates/bevy_ecs/src/query/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,7 @@ pub struct FilteredAccess<T: SparseSetIndex> {

impl<T: SparseSetIndex> Default for FilteredAccess<T> {
fn default() -> Self {
Self {
access: Access::default(),
required: FixedBitSet::default(),
filter_sets: vec![AccessFilters::default()],
}
Self::matches_everything()
}
}

Expand All @@ -353,9 +349,19 @@ impl<T: SparseSetIndex> From<FilteredAccess<T>> for FilteredAccessSet<T> {
}

impl<T: SparseSetIndex> FilteredAccess<T> {
/// Returns a `FilteredAccess` with no access and matching nothing.
/// Returns a `FilteredAccess` which has no access and matches everything.
/// This is the equivalent of a `TRUE` logic atom.
pub fn matches_everything() -> Self {
Self {
access: Access::default(),
required: FixedBitSet::default(),
filter_sets: vec![AccessFilters::default()],
}
}

/// Returns a `FilteredAccess` which has no access and matches nothing.
/// This is the equivalent of a `FALSE` logic atom.
pub fn empty() -> Self {
pub fn matches_nothing() -> Self {
Self {
access: Access::default(),
required: FixedBitSet::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ macro_rules! impl_anytuple_fetch {
// update the filters (Or<(With<$name>,)>)
let ($($name,)*) = state;

let mut _new_access = FilteredAccess::empty();
let mut _new_access = FilteredAccess::matches_nothing();

$(
// Create an intermediate because `access`'s value needs to be preserved
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ macro_rules! impl_or_query_filter {
fn update_component_access(state: &Self::State, access: &mut FilteredAccess<ComponentId>) {
let ($($filter,)*) = state;

let mut _new_access = FilteredAccess::empty();
let mut _new_access = FilteredAccess::matches_nothing();

$(
// Create an intermediate because `access`'s value needs to be preserved
Expand Down

0 comments on commit 2a23d74

Please sign in to comment.