From d6bfd44f8f48af92c727a42ca7fe43f32a2ab747 Mon Sep 17 00:00:00 2001 From: Charles Bournhonesque Date: Wed, 18 Jan 2023 14:26:07 +0000 Subject: [PATCH] update doc comment for new_archetype in query-state (#7241) # Objective I was reading through the bevy_ecs code, trying to understand how everything works. I was getting a bit confused when reading the doc comment for the `new_archetype` function; it looks like it doesn't create a new archetype but instead updates some internal state in the SystemParam to facility QueryIteration. (I still couldn't find where a new archetype was actually created) ## Solution - Adding a doc comment with a more correct explanation. If it's deemed correct, I can also update the doc-comment for the other `new_archetype` calls --- crates/bevy_ecs/src/query/state.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index c96dbca393..ca44e44d98 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -140,7 +140,7 @@ impl QueryState { } /// Takes a query for the given [`World`], checks if the given world is the same as the query, and - /// generates new archetypes for the given world. + /// updates the [`QueryState`]'s view of the [`World`] with any newly-added archetypes. /// /// # Panics /// @@ -166,7 +166,8 @@ impl QueryState { ); } - /// Creates a new [`Archetype`]. + /// Update the current [`QueryState`] with information from the provided [`Archetype`] + /// (if applicable, i.e. if the archetype has any intersecting [`ComponentId`] with the current [`QueryState`]). pub fn new_archetype(&mut self, archetype: &Archetype) { if Q::matches_component_set(&self.fetch_state, &|id| archetype.contains(id)) && F::matches_component_set(&self.filter_state, &|id| archetype.contains(id))