You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should we consider a generic Not<>? I don't know how feasible this is though.
Probably would just be a simple Not<T: ReadOnlyWorldQuery> that just inverts the output on filter_fetch. It probably should be noted that it wouldn't be an archetypal filter and would run against the split between With/Without.
I took a stab at Not<T> in #7271, but ran into some issues I could not resolve. matches_component_set has different "negation behaviours" for With(out) and Added/Changed: for With(out), it must be negated; for Added/Changed, it must not be. If individual implementations were implemented for the four "inner" filters, Or then becomes impossible to generically negate as it's possible to mix With(out) and Added/Changed within an Or. One possible solution moving forward is to have an additional trait that defines the negation behaviour.
My implementation also had Not<Added<T>> imply With<T>, which is not a logical negation of Added<T>.
As a user-story, today I tried to do something like the following in order to filter out all the entities that had a component added in the same frame.
Query<&T,Without<Added<T>>>
I was somewhat surprised that this was not supported.
Having set-like operations defined on Query could also be useful to solve similar problems instead with run-time compositions, i.e.
fnsystem(a:Query<Entity>
b:Query<Added<&T>){// set difference; C is the set of all entities that satisfy A but // with the entities that satisfy B removedlet c:Query<Entity> = a - b;}
NotChanged<T> and NotAdded<T> return all entities that Changed<T> and Added<T> do not.
Changed<T> and Added<T> have an implicit With<T>. Inverting their output won't change that. They'll return the entities that have a T that wasn't recently changed or added. Their inverses should not include entities matched by Without<T>.
My implementation also had Not<Added<T>> imply With<T>, which is not a logical negation of Added<T>.
This would be much clearer if Added<T> and is_added were named New<T> and is_new (which is what it means). IMO if you ask for "entities whose T is not new", it doesn't make any sense to include entities that don't even have T.
It's not the complementary set of entities, but the implied With<T> is intuitive.
Activity
djeedai commentedon Jan 18, 2023
Should we consider a generic
Not<>? I don't know how feasible this is though.james7132 commentedon Jan 18, 2023
Probably would just be a simple
Not<T: ReadOnlyWorldQuery>that just inverts the output onfilter_fetch. It probably should be noted that it wouldn't be an archetypal filter and would run against the split betweenWith/Without.CatThingy commentedon Jan 20, 2023
I took a stab at
Not<T>in #7271, but ran into some issues I could not resolve.matches_component_sethas different "negation behaviours" forWith(out) andAdded/Changed: forWith(out), it must be negated; forAdded/Changed, it must not be. If individual implementations were implemented for the four "inner" filters,Orthen becomes impossible to generically negate as it's possible to mixWith(out) andAdded/Changedwithin anOr. One possible solution moving forward is to have an additional trait that defines the negation behaviour.My implementation also had
Not<Added<T>>implyWith<T>, which is not a logical negation ofAdded<T>.ickk commentedon Aug 10, 2023
As a user-story, today I tried to do something like the following in order to filter out all the entities that had a component added in the same frame.
I was somewhat surprised that this was not supported.
Having set-like operations defined on Query could also be useful to solve similar problems instead with run-time compositions, i.e.
maniwani commentedon Aug 10, 2023
Changed<T>andAdded<T>have an implicitWith<T>. Inverting their output won't change that. They'll return the entities that have aTthat wasn't recently changed or added. Their inverses should not include entities matched byWithout<T>.This would be much clearer if
Added<T>andis_addedwere namedNew<T>andis_new(which is what it means). IMO if you ask for "entities whoseTis not new", it doesn't make any sense to include entities that don't even haveT.It's not the complementary set of entities, but the implied
With<T>is intuitive.