You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
I think nalgebra's built-in geometric types tend to be constrained to more algebraic types that are related to vectors/matrices -- however, I think the HalfSpace structure from nalgebra's sister library parry could be what you're looking for! It has a focus specifically on collision detection and so could be useful for your use-case. I don't think parry currently has a structure for a 6-plane frustum, though.
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: