Use faster halfspace method for precise brush intersection

This commit is contained in:
Jarrod Doyle 2023-09-25 10:32:38 +01:00
parent dc749aa7be
commit e1688f6841
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 6 additions and 5 deletions

View File

@ -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;
}
}