-
-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Planes and Culling Frustums #1337
Comments
I think |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any thoughts about adding in planes and culling frustums (or just frustums with the right functions.) I'm using nalgebra for a game I'm working on and planes + frustums are nice for optimizations, so others might desire them.
I basically made my own and if you think this is something useful, feel free to use my code if it's up to your standards, at least as a start. Otherwise, it's not hard to create, just something that could get wrapped into your lib and be one less piece of code I'm maintaining.
If you already have this and I somehow missed it, I apologize for the issue!
Plane:
`
use num_traits::real::Real;
use nalgebra::*;
pub struct Plane<T: Real> {
pub a: T,
pub b: T,
pub c: T,
pub d: T
}
impl<T: Real + std::fmt::Debug + 'static> Plane {
pub fn new(
a: T,
b: T,
c: T,
d: T
) -> Self {
Self {
a,
b,
c,
d
}
}
}
impl<T: Real + std::fmt::Debug + 'static> Default for Plane {
fn default() -> Self {
Self {
a: num_traits::zero(),
b: num_traits::zero(),
c: num_traits::zero(),
d: num_traits::zero()
}
}
}
`
Culling Frustum:
`
use num_traits::real::Real;
use nalgebra::*;
use crate::game::view_plane::Plane;
pub struct CullingFrustum<T: Real> {
pub left: Plane,
pub right: Plane,
pub top: Plane,
pub bottom: Plane,
pub near: Plane,
pub far: Plane,
}
impl<T: Real + std::fmt::Debug + 'static> CullingFrustum {
pub fn new(
perspective_matrix: &Matrix4,
view_matrix: &Matrix4
) -> Self {
let mut clip_plane: [T; 16] = [num_traits::zero(); 16];
}
impl<T: Real + std::fmt::Debug + 'static> Default for CullingFrustum {
fn default() -> Self {
Self {
left: Plane::default(),
right: Plane::default(),
top: Plane::default(),
bottom: Plane::default(),
near: Plane::default(),
far: Plane::default(),
}
}
}
`
The text was updated successfully, but these errors were encountered: