Remove slow unused plane intersection halfplane check
This commit is contained in:
parent
93266ed328
commit
700ad4b8ba
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue