Command to efficiently drop matched archetypes and their tables
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Currently there is no way to clear all entities from an archetype/table efficiently. Each entity has to be despawned individually. This is not ideal ergonomically but also much slower than it could be performance wise.
```rs
fn sys(mut cmds: Commands, to_clear: Query, With)>) {
for entity in to_clear.iter() {
cmds.entity(entity).despawn();
}
}
```
## What solution would you like?
A command that efficiently drops anything that matches a query.
```rs
fn sys(mut cmds: Commands) {
cmds.add(Clear::new::<(With, With)>());
}
```
## What alternative(s) have you considered?
Using my own storage in a resource but this loses all the benefits of the ECS.
## Additional context
Change detection will have to be ignored. At least until [archetype level change detection](https://github.com/bevyengine/bevy/issues/5097) is a thing.
Contributor guide
Assessment
This issue has not been assessed yet.