From 69952bca72b5fb7cb296d458c1cef3abee340398 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 20 Dec 2021 21:43:55 +0000 Subject: [PATCH] Fixes minimization crash because of cluster updates. (#3369) # Objective Fixes: #3368 Issue was caused by screen size being: `(0, 0)`. ## Solution Don't update clusters if the screen size is zero. A better solution might be to not render when minimized, but this works in the meantime. Co-authored-by: John --- crates/bevy_pbr/src/light.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index e196e4b0df71a..81455eea85d8f 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -362,6 +362,10 @@ pub fn update_clusters(windows: Res, mut views: Query<(&Camera, &mut Cl let inverse_projection = camera.projection_matrix.inverse(); let window = windows.get(camera.window).unwrap(); let screen_size_u32 = UVec2::new(window.physical_width(), window.physical_height()); + // Don't update clusters if screen size is 0. + if screen_size_u32.x == 0 || screen_size_u32.y == 0 { + continue; + } *clusters = Clusters::from_screen_size_and_z_slices(screen_size_u32, clusters.axis_slices.z); let screen_size = screen_size_u32.as_vec2();