Skip to content

QueryBuilder is largely unusable due to keeping a reference to the World #15520

@djeedai

Description

@djeedai

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleC-UsabilityA 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 accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions