pub fn from_view_projection(
        view_projection: &Mat4,
        view_translation: &Vec3,
        view_backward: &Vec3,
        far: f32,
    ) -> Self {
        let row3 = view_projection.row(3);
        let mut planes = [Plane::default(); 6];
        for (i, plane) in planes.iter_mut().enumerate().take(5) {
            let row = view_projection.row(i / 2);
            plane.normal_d = if (i & 1) == 0 && i != 4 {
                row3 + row
            } else {
                row3 - row
            }
            .normalize();
        }
        let far_center = *view_translation - far * *view_backward;
        planes[5].normal_d = view_backward
            .extend(-view_backward.dot(far_center))
            .normalize();
        Self { planes }
    }
// NOTE: This approach of extracting the frustum planes from the view
// projection matrix is from Foundations of Game Engine Development 2
// Rendering by Lengyel. Slight modification has been made for when
// the far plane is infinite but we still want to cull to a far plane.
This approach of extracting the frustum planes from the view
projection matrix is from Foundations of Game Engine Development 2
Rendering by Lengyel. Slight modification has been made for when
the far plane is infinite but we still want to cull to a far plane.
This approach of extracting the frustum planes from the view projection matrix is from Foundations of Game Engine Development 2 Rendering by Lengyel . Slight modification has been made for when the far plane is infinite but we still want to cull to a far plane .
pub fn from_view_projection(
        view_projection: &Mat4,
        view_translation: &Vec3,
        view_backward: &Vec3,
        far: f32,
    ) -> Self {
        let row3 = view_projection.row(3);
        let mut planes = [Plane::default(); 6];
        for (i, plane) in planes.iter_mut().enumerate().take(5) {
            let row = view_projection.row(i / 2);
            plane.normal_d = if (i & 1) == 0 && i != 4 {
                row3 + row
            } else {
                row3 - row
            }
            .normalize();
        }
        let far_center = *view_translation - far * *view_backward;
        planes[5].normal_d = view_backward
            .extend(-view_backward.dot(far_center))
            .normalize();
        Self { planes }
    }
pub fn from_view_projection ( view_projection : & Mat4 , view_translation : & Vec3 , view_backward : & Vec3 , far : f32 , ) -> Self { let row3 = view_projection . row ( 3 ) ; let mut planes = [ Plane :: default ( ) ; 6 ] ; for ( i , plane ) in planes . iter_mut ( ) . enumerate ( ) . take ( 5 ) { let row = view_projection . row ( i / 2 ) ; plane . normal_d = if ( i & 1 ) == 0 && i != 4 { row3 + row } else { row3 - row } . normalize ( ) ; } let far_center = * view_translation - far * * view_backward ; planes [ 5 ] . normal_d = view_backward . extend ( - view_backward . dot ( far_center ) ) . normalize ( ) ; Self { planes } }
NOTE: This approach of extracting the frustum planes from the view
projection matrix is from Foundations of Game Engine Development 2
Rendering by Lengyel.
NOTE : This approach of extracting the frustum planes from the view projection matrix is from Foundations of Game Engine Development 2 Rendering by Lengyel .
view_projection
&Mat4
view_translation
&Vec3
view_backward
&Vec3
far
f32
view_projection
&Mat4
view_translation
&Vec3
view_backward
&Vec3
far
f32