bevy
bevy copied to clipboard
Query as Entities
relationship 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.
As SME-ECS, I'm in favor of this plan :)