`QueryBuilder` is largely unusable due to keeping a reference to the `World`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
The documentation of `QueryBuilder` claims it can build a `QueryState` at runtime. However unlike `QueryState`, the builder retains a reference to the `World`. This means it can't be stored. This also means no other query can be done on the world at the same time, for example to resolve another `Entity` returned by the `QueryBuilder` result. This heavily restricts where and how `QueryBuilder` can be used.
## What solution would you like?
Like `QueryState` but dynamic, without a world reference. When actually iterating, then take the target `World` as parameter to a method.
## What alternative(s) have you considered?
There's no alternative I know of.
## Additional context
Currently `bevy_tweening` makes heavy use of generics to be able to define systems and behaviors based on the target component being animated. This has been a source of pain since day one. The hope was to eventually abandon this once dynamic queries are available in Bevy, so that a single animation system can process an heterogeneous list of animation targets. Unfortunately, trying to implement this showed this is impossible due to the `QueryBuilder` limitation of taking a `World` reference; the animator class references a component/entity pair to animate, but once the query builder is in scope it references the world, making it impossible to query and animate (mutate) that target component.
Contributor guide
Research direction
Start by reading the QueryBuilder and QueryState APIs described in the issue, then trace how QueryBuilder retains the World during iteration. The work is done when a dynamic builder can be stored without a World reference and accepts the target World only when iterating, allowing other queries on that World.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100