From 70b9cc4068e1a33a57d89be3064277446c440302 Mon Sep 17 00:00:00 2001 From: Ellen Date: Fri, 6 May 2022 11:57:39 +0100 Subject: [PATCH] filtered access docs --- crates/bevy_ecs/src/query/access.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index 99abaa77003cd9..d56bc09f1e42c3 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -131,6 +131,22 @@ impl Access { } #[derive(Clone, Eq, PartialEq, Debug)] +/// Subtle: a `read` or `write` in `access` should not be considered to imply a +/// `with` access. +/// +/// For example consider `Query>` this only has a `read` of `T` as doing +/// otherwise would allow for queriess to be considered disjoint that actually arent: +/// - `Query<(&mut T, Option<&U>)>` read/write `T`, read `U`, with `U` +/// - `Query<&mut T, Without>` read/write `T`, without `U` +/// from this we could reasonably conclude that the queries are disjoint but they aren't. +/// +/// In order to solve this the actual access that `Query<(&mut T, Option<&U>)>` has +/// is read/write `T`, read `U`. It must still have a read `U` access otherwise the following +/// queries would be incorrectly considered disjoint: +/// - `Query<&mut T>` read/write `T` +/// - `Query` accesses nothing +/// +/// See comments the `WorldQuery` impls of `AnyOf`/`Option`/`Or` for more information. pub struct FilteredAccess { access: Access, with: FixedBitSet,