-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
QueryBuilder is largely unusable due to keeping a reference to the World #15520
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
Activity
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
What problem does this solve or what need does it fill?
The documentation of
QueryBuilderclaims it can build aQueryStateat runtime. However unlikeQueryState, the builder retains a reference to theWorld. 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 anotherEntityreturned by theQueryBuilderresult. This heavily restricts where and howQueryBuildercan be used.What solution would you like?
Like
QueryStatebut dynamic, without a world reference. When actually iterating, then take the targetWorldas parameter to a method.What alternative(s) have you considered?
There's no alternative I know of.
Additional context
Currently
bevy_tweeningmakes 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 theQueryBuilderlimitation of taking aWorldreference; 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.