parry3d/query/ray/
ray_bounding_sphere.rs1use crate::bounding_volume::BoundingSphere;
2use crate::math::Real;
3use crate::query::{Ray, RayCast, RayIntersection};
4use crate::shape::Ball;
5
6impl RayCast for BoundingSphere {
7 #[inline]
8 fn cast_local_ray(&self, ray: &Ray, max_time_of_impact: Real, solid: bool) -> Option<Real> {
9 let centered_ray = ray.translate_by(-self.center().coords);
10 Ball::new(self.radius()).cast_local_ray(¢ered_ray, max_time_of_impact, solid)
11 }
12
13 #[inline]
14 fn cast_local_ray_and_get_normal(
15 &self,
16 ray: &Ray,
17 max_time_of_impact: Real,
18 solid: bool,
19 ) -> Option<RayIntersection> {
20 let centered_ray = ray.translate_by(-self.center().coords);
21 Ball::new(self.radius()).cast_local_ray_and_get_normal(
22 ¢ered_ray,
23 max_time_of_impact,
24 solid,
25 )
26 }
27
28 #[inline]
29 fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: Real) -> bool {
30 let centered_ray = ray.translate_by(-self.center().coords);
31 Ball::new(self.radius()).intersects_local_ray(¢ered_ray, max_time_of_impact)
32 }
33}