From 8d7d626e911990d19d98a08ea85ef2855deeea81 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Sun, 16 Jan 2022 14:30:54 +0100 Subject: [PATCH] bevy_pbr: Do not panic when more than 256 point lights are added to the scene --- crates/bevy_pbr/src/render/light.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 13991a23263a5..d939be0b593b1 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -641,7 +641,7 @@ pub fn prepare_lights( } let mut gpu_point_lights = [GpuPointLight::default(); MAX_POINT_LIGHTS]; - for (index, &(entity, light)) in point_lights.iter().enumerate() { + for (index, &(entity, light)) in point_lights.iter().enumerate().take(MAX_POINT_LIGHTS) { let mut flags = PointLightFlags::NONE; // Lights are sorted, shadow enabled lights are first if light.shadows_enabled && index < MAX_POINT_LIGHT_SHADOW_MAPS {