use alga::general::Id; use query::{Ray, RayCast, RayIntersection}; use shape::Ball; use bounding_volume::BoundingSphere; use math::{Isometry, Point}; impl> RayCast for BoundingSphere

{ #[inline] fn toi_with_ray(&self, m: &M, ray: &Ray

, solid: bool) -> Option { let centered_ray = ray.translate_by(-m.transform_point(self.center()).coordinates()); Ball::new(self.radius()).toi_with_ray(m, ¢ered_ray, solid) } #[inline] fn toi_and_normal_with_ray( &self, m: &M, ray: &Ray

, solid: bool, ) -> Option> { let centered_ray = ray.translate_by(-m.transform_point(self.center()).coordinates()); Ball::new(self.radius()).toi_and_normal_with_ray(&Id::new(), ¢ered_ray, solid) } #[inline] fn toi_and_normal_and_uv_with_ray( &self, m: &M, ray: &Ray

, solid: bool, ) -> Option> { let centered_ray = ray.translate_by(-m.transform_point(self.center()).coordinates()); Ball::new(self.radius()).toi_and_normal_and_uv_with_ray(&Id::new(), ¢ered_ray, solid) } #[inline] fn intersects_ray(&self, m: &M, ray: &Ray

) -> bool { let centered_ray = ray.translate_by(-m.transform_point(self.center()).coordinates()); Ball::new(self.radius()).intersects_ray(&Id::new(), ¢ered_ray) } }