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 <startoaster23@gmail.com>
This commit is contained in:
John 2021-12-20 21:43:55 +00:00
parent c61fbcb7db
commit 3443cc77cb

View file

@ -359,6 +359,10 @@ pub fn update_clusters(windows: Res<Windows>, mut views: Query<(&Camera, &mut Cl
let inverse_projection = camera.projection_matrix.inverse(); let inverse_projection = camera.projection_matrix.inverse();
let window = windows.get(camera.window).unwrap(); let window = windows.get(camera.window).unwrap();
let screen_size_u32 = UVec2::new(window.physical_width(), window.physical_height()); 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 =
Clusters::from_screen_size_and_z_slices(screen_size_u32, clusters.axis_slices.z); Clusters::from_screen_size_and_z_slices(screen_size_u32, clusters.axis_slices.z);
let screen_size = screen_size_u32.as_vec2(); let screen_size = screen_size_u32.as_vec2();