ncollide3d/bounding_volume/
aabb_cuboid.rs

1use crate::bounding_volume::{HasBoundingVolume, AABB};
2use crate::math::{Isometry, Point};
3use crate::shape::Cuboid;
4use crate::utils::IsometryOps;
5use na::RealField;
6
7impl<N: RealField + Copy> HasBoundingVolume<N, AABB<N>> for Cuboid<N> {
8    #[inline]
9    fn bounding_volume(&self, m: &Isometry<N>) -> AABB<N> {
10        let center = Point::from(m.translation.vector);
11        let ws_half_extents = m.absolute_transform_vector(&self.half_extents);
12
13        AABB::from_half_extents(center, ws_half_extents)
14    }
15
16    #[inline]
17    fn local_bounding_volume(&self) -> AABB<N> {
18        let half_extents = Point::from(self.half_extents);
19
20        AABB::new(-half_extents, half_extents)
21    }
22}