bevyengine / bevyengine/bevy

Separate Changed<T> and Added<T>, readding `Mutated` query filter

Open
#15,070 6 comments 0 reactions 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 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

The confusion and added complexity of having a Query filter performing multiple filters.
Currently the `Changed` filter is set up to "only retains results the first time after they have been added **OR** mutably dereferenced."
If I am querying for Changed components I want to only know when they are changed not added.

## What solution would you like?

I propose removing the "first time after they have been added" condition on the Changed filter. If users wanted first time added then they can use the `Added` filter, or if they want to keep the keep both conditions they can use `Or<(Changed, Added)>`

## What alternative(s) have you considered?

The only other work around to this problem is to use `Ref` to then filter out components that were just changed. But this in an unnecessary burden to have to put on users. It seems silly to have to do the below amount of work to get only changed entities.

```rust
pub fn simplified_example(q_maybe_changed: Query<(Entity, Ref) {
let changed: Vec = q_entities
.iter()
.filter_map(|(e, r)| if r.is_changed() { Some(e) } else { None })
.collect();
if changed.is_empty() {
return;
}

// now do what I want with changed only entities
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.