Skip to content

Commit

Permalink
bevy_pbr: Fix frustum plane construction
Browse files Browse the repository at this point in the history
The normals should be unit normals, not the entire normal_d.
  • Loading branch information
superdump committed Feb 24, 2022
1 parent 3493bb7 commit 34d134d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions crates/bevy_render/src/primitives/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::{Mat4, Vec3, Vec3A, Vec4};
use bevy_math::{Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles};
use bevy_reflect::Reflect;

/// An Axis-Aligned Bounding Box
Expand Down Expand Up @@ -112,13 +112,12 @@ impl Frustum {
row3 + row
} else {
row3 - row
}
.normalize();
};
plane.normal_d *= 1.0 / plane.normal_d.xyz().length();
}
let far_center = *view_translation - far * *view_backward;
planes[5].normal_d = view_backward
.extend(-view_backward.dot(far_center))
.normalize();
planes[5].normal_d = view_backward.extend(-view_backward.dot(far_center));
planes[5].normal_d *= 1.0 / planes[5].normal_d.xyz().length();
Self { planes }
}

Expand Down

0 comments on commit 34d134d

Please sign in to comment.