From 0ab88c101978ebf5f68da2421ca6808beb2f248f Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Wed, 23 Feb 2022 17:04:26 +0100 Subject: [PATCH] bevy_pbr: Fixes for x_planes and remove unnecessary plane negation --- crates/bevy_pbr/src/light.rs | 8 ++++---- crates/bevy_render/src/primitives/mod.rs | 14 +------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index fcff81d66d171..f84c4c74dec49 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -1459,7 +1459,7 @@ pub fn assign_lights_to_clusters( let mut z_light = view_light_sphere.clone(); if z != z_center { let z_plane = if z < z_center { - -z_planes[(z + 1) as usize] + z_planes[(z + 1) as usize] } else { z_planes[z as usize] }; @@ -1475,7 +1475,7 @@ pub fn assign_lights_to_clusters( let y_plane = if y < y_center { y_planes[(y + 1) as usize] } else { - -y_planes[y as usize] + y_planes[y as usize] }; if let Some(projected) = project_to_plane_y(y_light, y_plane) { y_light = projected; @@ -1486,8 +1486,8 @@ pub fn assign_lights_to_clusters( let mut min_x = min_cluster.x; loop { if min_x >= max_cluster.x - || get_distance_x( - -x_planes[(min_x + 1) as usize], + || -get_distance_x( + x_planes[(min_x + 1) as usize], y_light.center, ) + y_light.radius > 0.0 diff --git a/crates/bevy_render/src/primitives/mod.rs b/crates/bevy_render/src/primitives/mod.rs index c979f78cb71c9..575636b53f2d6 100644 --- a/crates/bevy_render/src/primitives/mod.rs +++ b/crates/bevy_render/src/primitives/mod.rs @@ -1,7 +1,5 @@ -use std::ops::Neg; - use bevy_ecs::{component::Component, reflect::ReflectComponent}; -use bevy_math::{Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles}; +use bevy_math::{Mat4, Vec3, Vec3A, Vec4}; use bevy_reflect::Reflect; /// An Axis-Aligned Bounding Box @@ -88,16 +86,6 @@ impl Plane { } } -impl Neg for Plane { - type Output = Self; - - fn neg(self) -> Self::Output { - Self { - normal_d: (-self.normal_d.xyz()).extend(self.normal_d.w), - } - } -} - #[derive(Component, Clone, Copy, Debug, Default, Reflect)] #[reflect(Component)] pub struct Frustum {