bevy_rapier2d/geometry/shape_views/
compound.rs

1use super::ColliderView;
2use crate::math::{Rot, Vect};
3use rapier::parry::shape::Compound;
4
5/// Read-only access to the properties of a compound shape.
6#[derive(Copy, Clone)]
7pub struct CompoundView<'a> {
8    /// The raw shape from Rapier.
9    pub raw: &'a Compound,
10}
11
12impl CompoundView<'_> {
13    /// The shapes of this compound shape.
14    #[inline]
15    pub fn shapes(&self) -> impl ExactSizeIterator<Item = (Vect, Rot, ColliderView<'_>)> {
16        self.raw.shapes().iter().map(|(pos, shape)| {
17            let (tra, rot) = (*pos).into();
18            (tra, rot, shape.as_typed_shape().into())
19        })
20    }
21}