diff --git a/csg/src/plane.rs b/csg/src/plane.rs index ac8d678..dbc4635 100644 --- a/csg/src/plane.rs +++ b/csg/src/plane.rs @@ -1,7 +1,8 @@ -use glam::{Mat3, Vec3}; +use glam::{Mat3, Vec3, Vec4}; use crate::math; +//? Should this be normalised or does that risk introducing fpp errors #[derive(Clone, Copy, Debug)] pub struct Plane { pub normal: Vec3, @@ -12,9 +13,13 @@ impl Plane { pub fn from_point_normal(point: Vec3, normal: Vec3) -> Self { Self { 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 {