diff --git a/csg/src/brush.rs b/csg/src/brush.rs index cb54be5..4feab17 100644 --- a/csg/src/brush.rs +++ b/csg/src/brush.rs @@ -89,6 +89,46 @@ impl Brush { false } + pub fn planes_intersect_with_mat(&self, other: &Brush) -> bool { + // Check our vertices against their planes + for i in &self.raw_vertices { + let mut iter = other.planes.iter(); + if iter.all(|bp| i.in_halfspace_mat(&bp.plane)) { + return true; + } + } + + // Check their vertices against our planes + for i in &other.raw_vertices { + let mut iter = self.planes.iter(); + if iter.all(|bp| i.in_halfspace_mat(&bp.plane)) { + return true; + } + } + + false + } + + pub fn planes_intersect_with_gauss(&self, other: &Brush) -> bool { + // Check our vertices against their planes + for i in &self.raw_vertices { + let mut iter = other.planes.iter(); + if iter.all(|bp| i.in_halfspace_gauss(&bp.plane)) { + return true; + } + } + + // Check their vertices against our planes + for i in &other.raw_vertices { + let mut iter = self.planes.iter(); + if iter.all(|bp| i.in_halfspace_gauss(&bp.plane)) { + return true; + } + } + + false + } + pub fn get_vertices(&self) -> Vec { self.vertices.clone() }