Skip to content

Commit d114090

Browse files
superdumpcart
authored andcommitted
bevy_pbr: Do not panic when more than 256 point lights are added the scene (#3697)
# Objective - Do not panic when mroe than 256 point lights are added the scene - Fixes #3682 ## Solution - Only iterate the first `MAX_POINT_LIGHTS` lights instead of as many as there are ## Open questions - Should we warn that there are more than the maximum allowed number of point lights in the scene?
1 parent df3d100 commit d114090

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/bevy_pbr/src/render/light.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ pub fn prepare_lights(
641641
}
642642

643643
let mut gpu_point_lights = [GpuPointLight::default(); MAX_POINT_LIGHTS];
644-
for (index, &(entity, light)) in point_lights.iter().enumerate() {
644+
for (index, &(entity, light)) in point_lights.iter().enumerate().take(MAX_POINT_LIGHTS) {
645645
let mut flags = PointLightFlags::NONE;
646646
// Lights are sorted, shadow enabled lights are first
647647
if light.shadows_enabled && index < MAX_POINT_LIGHT_SHADOW_MAPS {

0 commit comments

Comments
 (0)