ncollide3d/bounding_volume/
bounding_sphere_convex.rs

1use crate::bounding_volume;
2use crate::bounding_volume::{BoundingSphere, HasBoundingVolume};
3use crate::math::Isometry;
4use crate::shape::ConvexHull;
5use na::RealField;
6
7impl<N: RealField + Copy> HasBoundingVolume<N, BoundingSphere<N>> for ConvexHull<N> {
8    #[inline]
9    fn bounding_volume(&self, m: &Isometry<N>) -> BoundingSphere<N> {
10        let bv: BoundingSphere<N> = self.local_bounding_volume();
11        bv.transform_by(m)
12    }
13
14    #[inline]
15    fn local_bounding_volume(&self) -> BoundingSphere<N> {
16        let (center, radius) = bounding_volume::point_cloud_bounding_sphere(self.points());
17
18        BoundingSphere::new(center, radius)
19    }
20}