diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 1a799999d4c3b..cc5c8d2a81f17 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -359,6 +359,7 @@ pub fn queue_sprites( mut extracted_sprites: ResMut, mut views: Query<(&VisibleEntities, &mut RenderPhase)>, events: Res, + mut visible_entities_map: Local>, ) { // If an image has changed, the GpuImage has (probably) changed for event in &events.images { @@ -403,7 +404,8 @@ pub fn queue_sprites( let extracted_sprites = &mut extracted_sprites.sprites; let image_bind_groups = &mut *image_bind_groups; - let visible_entities = HashSet::from_iter(visible_entities.iter().cloned()); + visible_entities_map.clear(); + visible_entities_map.extend(visible_entities.iter().copied()); transparent_phase.items.reserve(extracted_sprites.len()); @@ -433,7 +435,7 @@ pub fn queue_sprites( // Batches are merged later (in `batch_phase_system()`), so that they can be interrupted // by any other phase item (and they can interrupt other items from batching). for extracted_sprite in extracted_sprites.iter() { - if !visible_entities.contains(&extracted_sprite.entity) { + if !visible_entities_map.contains(&extracted_sprite.entity) { continue; } let new_batch = SpriteBatch {