use na::{Identity, Transform, Rotate, Translate}; use ray::{Ray, RayCast, RayIntersection}; use entities::shape::Ball; use entities::bounding_volume::BoundingSphere; use math::{Point, Vector}; impl RayCast for BoundingSphere

where P: Point, M: Transform

+ Translate

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

, solid: bool) -> Option<::Scalar> { let centered_ray = Ray::new(ray.origin + (-*m.transform(self.center()).as_vector()), ray.dir); 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::new(ray.origin + (-*m.transform(self.center()).as_vector()), ray.dir); Ball::new(self.radius()).toi_and_normal_with_ray(&Identity::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::new(ray.origin + (-*m.transform(self.center()).as_vector()), ray.dir); Ball::new(self.radius()).toi_and_normal_and_uv_with_ray(&Identity::new(), ¢ered_ray, solid) } #[inline] fn intersects_ray(&self, m: &M, ray: &Ray

) -> bool { let centered_ray = Ray::new(ray.origin + (-*m.transform(self.center()).as_vector()), ray.dir); Ball::new(self.radius()).intersects_ray(&Identity::new(), ¢ered_ray) } }