ncollide3d/shape/
composite_shape.rs

1use crate::bounding_volume::AABB;
2use crate::math::Isometry;
3use crate::partitioning::BVHImpl;
4use crate::query::{ContactPrediction, ContactPreprocessor};
5use crate::shape::Shape;
6use na::RealField;
7
8/// Trait implemented by shapes composed of multiple simpler shapes.
9///
10/// A composite shape is composed of several shapes. Typically, it is a convex decomposition of
11/// a concave shape.
12pub trait CompositeShape<N: RealField + Copy> {
13    /// The number of sub-shape in this composide shape.
14    fn nparts(&self) -> usize;
15
16    /// Applies a transformation matrix and a function to each sub-shape of this concave
17    /// shape.
18    fn map_part_at(
19        &self,
20        _: usize,
21        m: &Isometry<N>,
22        _: &mut dyn FnMut(&Isometry<N>, &dyn Shape<N>),
23    );
24
25    /// Applies a transformation matrix and a function to each sub-shape of this concave
26    /// shape.
27    fn map_part_and_preprocessor_at(
28        &self,
29        _: usize,
30        m: &Isometry<N>,
31        prediction: &ContactPrediction<N>,
32        _: &mut dyn FnMut(&Isometry<N>, &dyn Shape<N>, &dyn ContactPreprocessor<N>),
33    );
34
35    // FIXME: the following two methods are not generic enough.
36    /// Gets the AABB of the shape identified by the index `i`.
37    fn aabb_at(&self, i: usize) -> AABB<N>;
38
39    /// Gets the acceleration structure of the concave shape.
40    fn bvh(&self) -> BVHImpl<N, usize, AABB<N>>;
41}