bevy/crates/bevy_ecs/src
Giacomo Stevanato 7de271f992
Add FilteredAccess::empty and simplify the implementatin of update_component_access for AnyOf/Or (#14352)
# Objective

- The implementation of `update_component_access` for `AnyOf`/`Or` is
kinda weird due to special casing the first filter, let's simplify it;
- Fundamentally we want to fold/reduce the various filters using an OR
operation, however in order to do a proper fold we need a neutral
element for the initial accumulator, which for OR is FALSE. However we
didn't have a way to create a `FilteredAccess` value corresponding to
FALSE and thus the only option was reducing, which special cases the
first element as being the initial accumulator.

This is an alternative to https://github.com/bevyengine/bevy/pull/14026

## Solution

- Introduce `FilteredAccess::empty` as a way to create a
`FilteredAccess` corresponding to the logical proposition FALSE;
- Use it as the initial accumulator for the above operations, allowing
to handle all the elements to fold in the same way.

---

## Migration Guide

- The behaviour of `AnyOf<()>` and `Or<()>` has been changed to match no
archetypes rather than all archetypes to naturally match the
corresponding logical operation. Consider replacing them with `()`
instead.
2024-07-29 23:20:06 +00:00
..
entity Fix intra-doc links and make CI test them (#14076) 2024-07-11 13:08:31 +00:00
event Minimal Bubbling Observers (#13991) 2024-07-15 13:39:41 +00:00
identifier feat: Reflection implementations on Identifier (#13648) 2024-06-03 16:33:14 +00:00
observer Fix typo in World::observe (#14492) 2024-07-27 13:55:44 +00:00
query Add FilteredAccess::empty and simplify the implementatin of update_component_access for AnyOf/Or (#14352) 2024-07-29 23:20:06 +00:00
reflect Fixed #14248 and other URL issues (#14276) 2024-07-11 12:01:49 +00:00
schedule Simplify run conditions (#14441) 2024-07-22 19:21:47 +00:00
storage Apply Clippy lints regarding lazy evaluation and closures (#14015) 2024-07-01 15:54:40 +00:00
system Add FilteredAccess::empty and simplify the implementatin of update_component_access for AnyOf/Or (#14352) 2024-07-29 23:20:06 +00:00
world Add intradoc links for observer triggers (#14458) 2024-07-24 18:41:23 +00:00
archetype.rs Component Lifecycle Hook & Observer Trigger for replaced values (#14212) 2024-07-15 15:24:15 +00:00
batching.rs Parallel event reader (#12554) 2024-04-22 16:37:42 +00:00
bundle.rs Update trigger_observers to operate over slices of data (#14354) 2024-07-17 13:01:52 +00:00
change_detection.rs Simplify run conditions (#14441) 2024-07-22 19:21:47 +00:00
component.rs Component Lifecycle Hook & Observer Trigger for replaced values (#14212) 2024-07-15 15:24:15 +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 Component Lifecycle Hook & Observer Trigger for replaced values (#14212) 2024-07-15 15:24:15 +00:00
removal_detection.rs Created an EventMutator for when you want to mutate an event before reading (#13818) 2024-07-08 14:53:06 +00:00
traversal.rs Minimal Bubbling Observers (#13991) 2024-07-15 13:39:41 +00:00