From 20a8e09cb28ad83c6f0b0c9d7b43353088367c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Wed, 15 Jun 2022 14:38:50 +0200 Subject: [PATCH] do not reset is_visible for each view_query --- crates/bevy_render/src/view/visibility/mod.rs | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 4f8a456486a19..d68acf6f1b9fe 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -149,21 +149,29 @@ pub fn update_frusta( pub fn check_visibility( mut view_query: Query<(&mut VisibleEntities, &Frustum, Option<&RenderLayers>), With>, - mut visible_entity_query: Query<( - Entity, - &Visibility, - &mut ComputedVisibility, - Option<&RenderLayers>, - Option<&Aabb>, - Option<&NoFrustumCulling>, - Option<&GlobalTransform>, + mut visible_entity_query: ParamSet<( + Query<&mut ComputedVisibility>, + Query<( + Entity, + &Visibility, + &mut ComputedVisibility, + Option<&RenderLayers>, + Option<&Aabb>, + Option<&NoFrustumCulling>, + Option<&GlobalTransform>, + )>, )>, ) { + // Reset the computed visibility to false + for mut computed_visibility in visible_entity_query.p0().iter_mut() { + computed_visibility.is_visible = false; + } + for (mut visible_entities, frustum, maybe_view_mask) in view_query.iter_mut() { let view_mask = maybe_view_mask.copied().unwrap_or_default(); let (visible_entity_sender, visible_entity_receiver) = crossbeam_channel::unbounded(); - visible_entity_query.par_for_each_mut( + visible_entity_query.p1().par_for_each_mut( 1024, |( entity, @@ -174,9 +182,6 @@ pub fn check_visibility( maybe_no_frustum_culling, maybe_transform, )| { - // Reset visibility - computed_visibility.is_visible = false; - if !visibility.is_visible { return; }