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