-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Don't ignore default query filters for EntityRef
or EntityMut
#20163
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
Don't ignore default query filters for EntityRef
or EntityMut
#20163
Conversation
But do ignore them for `EntityRefExcept` or `EntityMutExcept` that mention the filtered component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit
crates/bevy_ecs/src/query/access.rs
Outdated
@@ -272,6 +272,13 @@ impl<T: SparseSetIndex> Access<T> { | |||
.contains(index.sparse_set_index()) | |||
} | |||
|
|||
/// Returns `true` if this either has bounded access including this component | |||
/// or unbounded access not including this component. | |||
pub(crate) fn has_component_read_exception(&self, index: T) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be something like has_component_read_or_exception
, now it sounds like the component has something called a read_exception, which sounds like a Java error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an has_component_exception would be even cleaner, but probably more tricky because this part of the code is perf sensitive
crates/bevy_ecs/src/query/access.rs
Outdated
/// Returns `true` if this either has bounded access including this component | ||
/// or unbounded access not including this component. | ||
pub(crate) fn has_component_read_exception(&self, index: T) -> bool { | ||
self.component_read_and_writes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here on why this works would be helpful: this is quite mysterious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_component_read_exception
is very unclear to me, but this is simple and seems to work (yay tests). If you can find a better name and improve the docs / comments to clarify why this works I'll approve this :)
I'm having trouble wording things well, but maybe I can simplify it instead. I realized It might work more cleanly if we completely ignore read access and just look at filters and archetypal access. Filters covers That won't count |
Yes, |
Objective
Don't ignore default query filters for
EntityRef
orEntityMut
.Currently,
Query<EntityRef>
will include entities with aDisabled
component, even though queries likeQuery<()>
orQuery<Entity>
would not. This was noticed in #19711 (comment).Solution
Change
Access::contains
to completely ignore read access and just look at filters and archetypal access. Filters coversWith
,Without
,&
, and&mut
, while archetypal coversHas
andAllows
.Note that
Option<&Disabled>
will no longer count as a use ofDisabled
, though.