Store the positive offset in planes
This commit is contained in:
parent
9dbcb2b811
commit
c57d94230e
|
@ -1,7 +1,8 @@
|
||||||
use glam::{Mat3, Vec3};
|
use glam::{Mat3, Vec3, Vec4};
|
||||||
|
|
||||||
use crate::math;
|
use crate::math;
|
||||||
|
|
||||||
|
//? Should this be normalised or does that risk introducing fpp errors
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Plane {
|
pub struct Plane {
|
||||||
pub normal: Vec3,
|
pub normal: Vec3,
|
||||||
|
@ -12,9 +13,13 @@ impl Plane {
|
||||||
pub fn from_point_normal(point: Vec3, normal: Vec3) -> Self {
|
pub fn from_point_normal(point: Vec3, normal: Vec3) -> Self {
|
||||||
Self {
|
Self {
|
||||||
normal,
|
normal,
|
||||||
offset: -point.dot(normal),
|
offset: point.dot(normal),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_vec4(&self) -> Vec4 {
|
||||||
|
glam::vec4(self.normal.x, self.normal.y, self.normal.z, -self.offset)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PlaneIntersection {
|
pub struct PlaneIntersection {
|
||||||
|
|
Loading…
Reference in New Issue