Remove slow unused plane intersection halfplane check

This commit is contained in:
Jarrod Doyle 2023-09-25 10:39:52 +01:00
parent 93266ed328
commit 700ad4b8ba
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 16 additions and 19 deletions

View File

@ -126,10 +126,6 @@ impl PlaneIntersection {
dist < math::EPSILON dist < math::EPSILON
} }
pub fn in_halfspace(&self, plane: &Plane) -> bool {
plane.normal.dot(self.get_intersection_point()) - plane.offset <= math::EPSILON
}
fn get_matrix(&self) -> Mat3 { fn get_matrix(&self) -> Mat3 {
glam::mat3( glam::mat3(
self.planes[0].normal, self.planes[0].normal,
@ -153,6 +149,22 @@ mod plane_tests {
assert_eq!(Plane::from_point_normal(point, normal), expected); assert_eq!(Plane::from_point_normal(point, normal), expected);
} }
#[test]
fn point_in_halfspace() {
let intersection = PlaneIntersection::from_planes(
Plane::from_point_normal(Vec3::X, Vec3::X),
Plane::from_point_normal(Vec3::Y, Vec3::Y),
Plane::from_point_normal(Vec3::Z, Vec3::Z),
)
.unwrap();
let point = intersection.get_intersection_point();
let p1 = Plane::from_point_normal(Vec3::NEG_ONE, Vec3::NEG_ONE);
let p2 = Plane::from_point_normal(Vec3::ZERO, Vec3::ONE);
assert!(p1.point_in_halfspace(point));
assert!(!p2.point_in_halfspace(point));
}
} }
#[cfg(test)] #[cfg(test)]
@ -207,19 +219,4 @@ mod plane_intersection_tests {
assert!(intersection.in_halfspace_mat(&p1)); assert!(intersection.in_halfspace_mat(&p1));
assert!(!intersection.in_halfspace_mat(&p2)); assert!(!intersection.in_halfspace_mat(&p2));
} }
#[test]
fn in_half_space() {
let intersection = PlaneIntersection::from_planes(
Plane::from_point_normal(Vec3::X, Vec3::X),
Plane::from_point_normal(Vec3::Y, Vec3::Y),
Plane::from_point_normal(Vec3::Z, Vec3::Z),
)
.unwrap();
let p1 = Plane::from_point_normal(Vec3::NEG_ONE, Vec3::NEG_ONE);
let p2 = Plane::from_point_normal(Vec3::ZERO, Vec3::ONE);
assert!(intersection.in_halfspace(&p1));
assert!(!intersection.in_halfspace(&p2));
}
} }