From e1688f6841e5026e280bedeb49740e4db1c8a3eb Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Mon, 25 Sep 2023 10:32:38 +0100 Subject: [PATCH] Use faster halfspace method for precise brush intersection --- csg/src/brush.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/csg/src/brush.rs b/csg/src/brush.rs index 817c183..0bded9c 100644 --- a/csg/src/brush.rs +++ b/csg/src/brush.rs @@ -69,17 +69,18 @@ impl Brush { } pub fn planes_intersect_with(&self, other: &Brush) -> bool { - // TODO: Benchmark this // Check our vertices against their planes - for pi in &self.raw_vertices { - if other.planes.iter().all(|bp| pi.in_halfspace_mat(&bp.plane)) { + for v in &self.vertices { + let mut iter = other.planes.iter(); + if iter.all(|bp| bp.plane.point_in_halfspace(*v)) { return true; } } // Check their vertices against our planes - for pi in &other.raw_vertices { - if self.planes.iter().all(|bp| pi.in_halfspace_mat(&bp.plane)) { + for v in &other.vertices { + let mut iter = self.planes.iter(); + if iter.all(|bp| bp.plane.point_in_halfspace(*v)) { return true; } }