Skip to content

Commit d6bc414

Browse files
committed
check for duplicate archetypes in QueryState::new_archetype (#1789)
Fixes #1788 See discussion in that issue for details.
1 parent 9193fc5 commit d6bc414

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

crates/bevy_ecs/src/query/state.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,20 @@ where
8080
}
8181

8282
pub fn new_archetype(&mut self, archetype: &Archetype) {
83-
let table_index = archetype.table_id().index();
8483
if self.fetch_state.matches_archetype(archetype)
8584
&& self.filter_state.matches_archetype(archetype)
8685
{
8786
self.fetch_state
8887
.update_archetype_component_access(archetype, &mut self.archetype_component_access);
8988
self.filter_state
9089
.update_archetype_component_access(archetype, &mut self.archetype_component_access);
91-
self.matched_archetypes.grow(archetype.id().index() + 1);
92-
self.matched_archetypes.set(archetype.id().index(), true);
93-
self.matched_archetype_ids.push(archetype.id());
90+
let archetype_index = archetype.id().index();
91+
if !self.matched_archetypes.contains(archetype_index) {
92+
self.matched_archetypes.grow(archetype_index + 1);
93+
self.matched_archetypes.set(archetype_index, true);
94+
self.matched_archetype_ids.push(archetype.id());
95+
}
96+
let table_index = archetype.table_id().index();
9497
if !self.matched_tables.contains(table_index) {
9598
self.matched_tables.grow(table_index + 1);
9699
self.matched_tables.set(table_index, true);

0 commit comments

Comments
 (0)