Skip to content

Commit

Permalink
bevy_pbr: Fixes for x_planes and remove unnecessary plane negation
Browse files Browse the repository at this point in the history
  • Loading branch information
superdump committed Feb 23, 2022
1 parent e13890b commit 0ab88c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_pbr/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
};
Expand All @@ -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;
Expand All @@ -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
Expand Down
14 changes: 1 addition & 13 deletions crates/bevy_render/src/primitives/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0ab88c1

Please sign in to comment.