-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Implement ExactSizeIterator
for queries that are only filtered by With and Without
#3142
Comments
I don't think we need something like |
Rather than using global terms like dynamic and static, could we think about more specific terms? Maybe ArchetypeFilter for static, and StatusFilter for dynamic? |
Right, that's a valid point. Edited the initial message to reflect this improved terminology. |
…Without) (bevyengine#5124) # Objective - Fixes bevyengine#3142 ## Solution - Done according to bevyengine#3142 - Created new marker trait `ArchetypeFilter` - Implement said trait to: - `With<T>` - `Without<T>` - tuples containing only types that implement `ArchetypeFilter`, from 0 to 15 elements - `Or<T>` where T is a tuple as described previously - Changed `ExactSizeIterator` impl to include a new generic that must implement `WorldQuery` and `ArchetypeFilter` - Added new tests --- ## Changelog ### Added - `Query`s with archetypal filters can now use `.iter().len()` to get the exact size of the iterator.
…Without) (bevyengine#5124) # Objective - Fixes bevyengine#3142 ## Solution - Done according to bevyengine#3142 - Created new marker trait `ArchetypeFilter` - Implement said trait to: - `With<T>` - `Without<T>` - tuples containing only types that implement `ArchetypeFilter`, from 0 to 15 elements - `Or<T>` where T is a tuple as described previously - Changed `ExactSizeIterator` impl to include a new generic that must implement `WorldQuery` and `ArchetypeFilter` - Added new tests --- ## Changelog ### Added - `Query`s with archetypal filters can now use `.iter().len()` to get the exact size of the iterator.
…Without) (bevyengine#5124) # Objective - Fixes bevyengine#3142 ## Solution - Done according to bevyengine#3142 - Created new marker trait `ArchetypeFilter` - Implement said trait to: - `With<T>` - `Without<T>` - tuples containing only types that implement `ArchetypeFilter`, from 0 to 15 elements - `Or<T>` where T is a tuple as described previously - Changed `ExactSizeIterator` impl to include a new generic that must implement `WorldQuery` and `ArchetypeFilter` - Added new tests --- ## Changelog ### Added - `Query`s with archetypal filters can now use `.iter().len()` to get the exact size of the iterator.
…Without) (bevyengine#5124) # Objective - Fixes bevyengine#3142 ## Solution - Done according to bevyengine#3142 - Created new marker trait `ArchetypeFilter` - Implement said trait to: - `With<T>` - `Without<T>` - tuples containing only types that implement `ArchetypeFilter`, from 0 to 15 elements - `Or<T>` where T is a tuple as described previously - Changed `ExactSizeIterator` impl to include a new generic that must implement `WorldQuery` and `ArchetypeFilter` - Added new tests --- ## Changelog ### Added - `Query`s with archetypal filters can now use `.iter().len()` to get the exact size of the iterator.
What problem does this solve or what need does it fill?
The
ExactSizeIterator
is useful on queries for learning the exact length of queries.It's currently implemented for unfiltered queries, but not filtered queries.
What solution would you like?
Separate query filters into "entity-level filters" (
Added
,Changed
) and "archetype-level filters" (With
,Without
).Implement
ArchetypeFilter
for filter tuples that only have archetype-level filters. Do the same forOr
.Implement
ExactSizeIterator
for queries that only containArchetypeFilter
filters.What alternative(s) have you considered?
Clone the query and then count it slowly :(
Use
With
andWithout
in the firstQuery
type parameter and discard the bools returned 😱Additional context
We can't comfortably do this for all filtered queries, as the length of a query that includes
Changed
etc. is slow to compute.Idea credit to @Davier and @TheRawMeatball. I just write the tickets!
The text was updated successfully, but these errors were encountered: