diff --git a/csg/src/brush.rs b/csg/src/brush.rs index 1af0949..b8568b7 100644 --- a/csg/src/brush.rs +++ b/csg/src/brush.rs @@ -41,6 +41,8 @@ impl Brush { return vec![]; } + // Test all permutations of brush planes for intersections + let mut intersections = vec![]; let mut vs = vec![]; let len = self.planes.len(); for i in 0..(len - 2) { @@ -51,13 +53,28 @@ impl Brush { self.planes[j].plane, self.planes[k].plane, ) { - // TODO: Validate that the found intersection is within all brush planes - vs.push(intersection.get_intersection_point()) + intersections.push(intersection) } } } } + // Validate intersections against other brush planes + // TODO: No need to check against planes that are part of the intersection + for intersection in intersections { + let mut valid = true; + for bplane in &self.planes { + if !intersection.in_halfspace_mat(&bplane.plane) { + valid = false; + break; + } + } + + if valid { + vs.push(intersection.get_intersection_point()); + } + } + vs } }