parry3d/bounding_volume/
bounding_sphere_voxels.rs

1use crate::bounding_volume::BoundingSphere;
2use crate::math::{Isometry, Real, Translation};
3use crate::shape::{Cuboid, Voxels};
4
5impl Voxels {
6    /// Computes the world-space bounding sphere of this set of voxels, transformed by `pos`.
7    #[inline]
8    pub fn bounding_sphere(&self, pos: &Isometry<Real>) -> BoundingSphere {
9        let shift = Translation::from(self.domain_center().coords);
10        Cuboid::new(self.extents() / 2.0).bounding_sphere(&(pos * shift))
11    }
12
13    /// Computes the local-space bounding sphere of this set of voxels.
14    #[inline]
15    pub fn local_bounding_sphere(&self) -> BoundingSphere {
16        Cuboid::new(self.extents() / 2.0)
17            .local_bounding_sphere()
18            .translated(&(self.domain_center().coords))
19    }
20}