bevy/crates/bevy_ecs/src
Periwink 6573887d5c
Fix error in AnyOf (#14027)
# Objective

- Fixes a correctness error introduced in
https://github.com/bevyengine/bevy/pull/14013 ...

## Solution

I've been playing around a lot of with the access code and I realized
that I introduced a soundness error when trying to simplify the code.
When we have a `Or<(With<A>, With<B>)>` filter, we cannot call
```
  let mut intermediate = FilteredAccess::default();
  $name::update_component_access($name, &mut intermediate);
  _new_access.append_or(&intermediate);
```
because that's just equivalent to adding the new components as `Or`
clauses.
For example if the existing `filter_sets` was `vec![With<C>]`, we would
then get `vec![With<C>, With<A>, With<B>]` which translates to `A or B
or C`.
Instead what we want is `(A and B) or (A and C)`, so we need to have
each new OR clause compose with the existing access like so:
```
let mut intermediate = _access.clone();
// if we previously had a With<C> in the filter_set, this will become `With<C> AND With<A>`
$name::update_component_access($name, &mut intermediate);
_new_access.append_or(&intermediate);
```

## Testing

- Added a unit test that is broken in main, but passes in this PR
2024-06-27 20:20:50 +00:00
..
entity Don't show .to_bits in Display impl for Entity (#14011) 2024-06-25 17:08:24 +00:00
event Mark events as read during EventReader::par_read (#13836) 2024-06-25 15:36:06 +00:00
identifier feat: Reflection implementations on Identifier (#13648) 2024-06-03 16:33:14 +00:00
observer Make Observer::with_event (and other variants) unsafe (#13954) 2024-06-21 18:31:01 +00:00
query Fix error in AnyOf (#14027) 2024-06-27 20:20:50 +00:00
reflect Map entities from a resource when written to the world. (#13650) 2024-06-03 16:33:24 +00:00
schedule IntoSystemConfigs::chain_ignore_deferred's return type fix (#13919) 2024-06-18 22:21:58 +00:00
storage Fix lints introduced in Rust beta 1.80 (#13899) 2024-06-17 17:22:01 +00:00
system Fix error in AnyOf (#14027) 2024-06-27 20:20:50 +00:00
world improved error message when forgetting to call system apply function … (#13975) 2024-06-25 12:27:15 +00:00
archetype.rs Update observer archetype flags for sparse components (#13886) 2024-06-17 15:15:30 +00:00
batching.rs Parallel event reader (#12554) 2024-04-22 16:37:42 +00:00
bundle.rs Use a unstable sort to sort component ids in bevy_ecs (#13789) 2024-06-17 14:56:19 +00:00
change_detection.rs Implement WorldQuery and QueryData on Mut. (#13338) 2024-05-14 12:38:31 +00:00
component.rs Fix typo in ComponentId docs: of -> or (#13932) 2024-06-19 18:51:47 +00:00
intern.rs Moves intern and label modules into bevy_ecs (#12772) 2024-04-08 15:34:11 +00:00
label.rs Add mappings to EntityMapper (#13727) 2024-06-08 12:52:23 +00:00
lib.rs Generalised ECS reactivity with Observers (#10839) 2024-06-15 01:33:26 +00:00
removal_detection.rs Remove extra call to clear_trackers (#13762) 2024-06-10 18:06:05 +00:00