Don't ignore default query filters for EntityRef or EntityMut#20163
Don't ignore default query filters for EntityRef or EntityMut#20163alice-i-cecile merged 2 commits intobevyengine:mainfrom
EntityRef or EntityMut#20163Conversation
But do ignore them for `EntityRefExcept` or `EntityMutExcept` that mention the filtered component.
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 { |
There was a problem hiding this comment.
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.
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.
A comment here on why this works would be helpful: this is quite mysterious.
alice-i-cecile
left a comment
There was a problem hiding this comment.
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
EntityReforEntityMut.Currently,
Query<EntityRef>will include entities with aDisabledcomponent, even though queries likeQuery<()>orQuery<Entity>would not. This was noticed in #19711 (comment).Solution
Change
Access::containsto completely ignore read access and just look at filters and archetypal access. Filters coversWith,Without,&, and&mut, while archetypal coversHasandAllows.Note that
Option<&Disabled>will no longer count as a use ofDisabled, though.