Skip to content

Commit

Permalink
perf: only recalc frusta of changed lights
Browse files Browse the repository at this point in the history
  • Loading branch information
dataphract committed Mar 3, 2022
1 parent b6a647c commit e07fd6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/bevy_pbr/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,10 @@ pub(crate) fn assign_lights_to_clusters(
}

pub fn update_directional_light_frusta(
mut views: Query<(&GlobalTransform, &DirectionalLight, &mut Frustum)>,
mut views: Query<
(&GlobalTransform, &DirectionalLight, &mut Frustum),
Or<(Changed<GlobalTransform>, Changed<DirectionalLight>)>,
>,
) {
for (transform, directional_light, mut frustum) in views.iter_mut() {
// The frustum is used for culling meshes to the light for shadow mapping
Expand All @@ -723,7 +726,10 @@ pub fn update_directional_light_frusta(
// NOTE: Run this after assign_lights_to_clusters!
pub fn update_point_light_frusta(
global_lights: Res<VisiblePointLights>,
mut views: Query<(Entity, &GlobalTransform, &PointLight, &mut CubemapFrusta)>,
mut views: Query<
(Entity, &GlobalTransform, &PointLight, &mut CubemapFrusta),
Or<(Changed<GlobalTransform>, Changed<PointLight>)>,
>,
) {
let projection =
Mat4::perspective_infinite_reverse_rh(std::f32::consts::FRAC_PI_2, 1.0, POINT_LIGHT_NEAR_Z);
Expand Down

0 comments on commit e07fd6e

Please sign in to comment.