bevyengine / bevyengine/bevy

Add a `query_read_only` that can be accessed through &World

Open
#10,898 0 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Feature
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?

For something like a UI tree, it can be useful to pass around a &World to allow read only access to the world to populate the tree in multiple places. But currently you can't get a `QueryState` out of `&World` as it requires `&mut World` to initialize the components in the query.

## What solution would you like?

Have a panicking `query_read_only` that can be used from `&World`.

A lot of the foundational work for this has been done in #9774 which adds a `get_state` to SystemParam, which allows building a QueryState from &World. So this should probably be built on top of that work.

Contributor guide

Open the contributing guide

Research direction

Start by reading the SystemParam and QueryState changes in issue #9774, then trace how a QueryState is currently built from &mut World. Define the read-only query entry point on &World with the requested panicking behavior, and verify that it can populate a UI tree without mutable world access.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.