bevy_rapier3d/geometry/shape_views/
compound.rs1use super::ColliderView;
2use crate::math::{Real, Rot, Vect};
3use rapier::parry::shape::{Compound, CompoundFlags};
4
5#[derive(Copy, Clone)]
7pub struct CompoundView<'a> {
8 pub raw: &'a Compound,
10}
11
12macro_rules! impl_ref_methods(
13 ($View: ident) => {
14 impl<'a> $View<'a> {
15 #[inline]
17 pub fn shapes(&self) -> impl ExactSizeIterator<Item = (Vect, Rot, ColliderView<'_>)> {
18 self.raw.shapes().iter().map(|(pos, shape)| {
19 #[cfg(feature = "dim2")]
20 let rot = pos.rotation.angle();
21 #[cfg(feature = "dim3")]
22 let rot = pos.rotation;
23 (pos.translation, rot, shape.as_typed_shape().into())
24 })
25 }
26
27 pub fn flags(&self) -> CompoundFlags {
29 self.raw.flags()
30 }
31 }
32 }
33);
34
35impl_ref_methods!(CompoundView);
36
37pub struct CompoundViewMut<'a> {
41 pub raw: &'a mut Compound,
43}
44
45impl_ref_methods!(CompoundViewMut);
46
47impl CompoundViewMut<'_> {
48 pub fn set_flags(&mut self, flags: CompoundFlags, weld_tolerance: Option<Real>) {
54 self.raw.set_flags(flags, weld_tolerance)
55 }
56}