parry3d/query/intersection_test/
intersection_test_ball_point_query.rs1use crate::math::Pose;
2use crate::query::{PointQuery, ShapeIntersection};
3use crate::shape::Ball;
4
5pub fn intersection_test_ball_point_query<P: ?Sized + PointQuery>(
7 pos12: &Pose,
8 ball1: &Ball,
9 point_query2: &P,
10) -> ShapeIntersection {
11 intersection_test_point_query_ball(&pos12.inverse(), point_query2, ball1).swapped()
12}
13
14pub fn intersection_test_point_query_ball<P: ?Sized + PointQuery>(
16 pos12: &Pose,
17 point_query1: &P,
18 ball2: &Ball,
19) -> ShapeIntersection {
20 let local_p2_1 = pos12.translation;
21 let proj = point_query1.project_local_point(local_p2_1, true);
22 let intersecting =
23 proj.is_inside || (local_p2_1 - proj.point).length_squared() <= ball2.radius * ball2.radius;
24 ShapeIntersection::new(intersecting).with_subshapes(proj.subshape, 0)
26}