parry2d/bounding_volume/
aabb_capsule.rs

1use crate::bounding_volume::Aabb;
2use crate::math::{Pose, Vector};
3use crate::shape::Capsule;
4
5impl Capsule {
6    /// The axis-aligned bounding box of this capsule.
7    #[inline]
8    pub fn aabb(&self, pos: &Pose) -> Aabb {
9        self.transform_by(pos).local_aabb()
10    }
11
12    /// The axis-aligned bounding box of this capsule.
13    #[inline]
14    pub fn local_aabb(&self) -> Aabb {
15        let a = self.segment.a;
16        let b = self.segment.b;
17        let mins = a.min(b) - Vector::splat(self.radius);
18        let maxs = a.max(b) + Vector::splat(self.radius);
19        Aabb::new(mins, maxs)
20    }
21}