bevyengine / bevyengine/bevy

Query as Entities

Open
#19,454 1 comment 1 reaction 0 assignees View on GitHub
A-ECS C-Feature D-Complex S-Ready-For-Implementation X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

[relationship](https://github.com/james-j-obrien/rfcs/blob/minimal-fragmenting-relationships/rfcs/79-minimal-fragmenting-relationships.md#query-and-system-caches) requires a more performant and powerful way to manage query's state, as archetype fragmentation becomes prevalent when relationships are used.

This goal can be achieved through 'Query as Entities' – a pattern that selectively exposes new/deleted archetypes only to affected queries requiring iteration over them.

There are some excellent PRs that have tried to implement it for Bevy: #14668 , #18860

Implementation Steps:

- [x] Trigger an event when a new archetype is created.
- [ ] Componentize system-internal QueryState.
- [ ] Use Observer to manage query entities.
- [ ] Type-erased QueryState Component.
- [ ] (optional) Provide users with a more ergonomic way to use managed QueryState.
- [ ] (optional) To optimize, only notify observers of impacted query entities instead of iterating over every query entity.

Contributor guide

Open the contributing guide

Research direction

Start with the linked relationship RFC and the earlier Bevy PRs #14668 and #18860 to understand the proposed Query-as-Entities design. Then inspect the existing event for new archetypes and the system-internal QueryState and Observer entry points. Done means the remaining implementation steps are addressed, including componentized and type-erased QueryState and observer-managed query entities.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.