Skip to content

Commit

Permalink
update doc comment for new_archetype in query-state (bevyengine#7241)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
cbournhonesque-sc authored and ItsDoot committed Feb 1, 2023
1 parent 6fbfd88 commit 78feae9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/bevy_ecs/src/query/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
}

/// 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
///
Expand All @@ -166,7 +166,8 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
);
}

/// 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))
Expand Down

0 comments on commit 78feae9

Please sign in to comment.