parry3d/bounding_volume/bounding_volume.rs
1use crate::math::{Point, Real};
2
3/// Trait of bounding volumes.
4///
5/// Bounding volumes are coarse approximations of shapes. It usually have constant time
6/// intersection, inclusion test. Two bounding volume must also be mergeable into a bigger bounding
7/// volume.
8pub trait BoundingVolume {
9 // TODO: keep that ? What about non-spacial bounding volumes (e.g. bounding cones, curvature
10 // bounds, etc.) ?
11 /// Returns a point inside of this bounding volume. This is ideally its center.
12 fn center(&self) -> Point<Real>;
13
14 /// Checks if this bounding volume intersect with another one.
15 fn intersects(&self, _: &Self) -> bool;
16
17 /// Checks if this bounding volume contains another one.
18 fn contains(&self, _: &Self) -> bool;
19
20 /// Merges this bounding volume with another one. The merge is done in-place.
21 fn merge(&mut self, _: &Self);
22
23 /// Merges this bounding volume with another one.
24 fn merged(&self, _: &Self) -> Self;
25
26 /// Enlarges this bounding volume.
27 fn loosen(&mut self, _: Real);
28
29 /// Creates a new, enlarged version, of this bounding volume.
30 fn loosened(&self, _: Real) -> Self;
31
32 /// Tighten this bounding volume.
33 fn tighten(&mut self, _: Real);
34
35 /// Creates a new, tightened version, of this bounding volume.
36 fn tightened(&self, _: Real) -> Self;
37}