Skip to content

Commit

Permalink
bevy_pbr: Do not panic when more than 256 point lights are added the …
Browse files Browse the repository at this point in the history
…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?
  • Loading branch information
superdump authored and cart committed Feb 13, 2022
1 parent df3d100 commit d114090
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d114090

Please sign in to comment.