1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::math::Vect;
use rapier::geometry::Cuboid;

/// Read-only access to the properties of a cuboid.
#[derive(Copy, Clone)]
pub struct CuboidView<'a> {
    /// The raw shape from Rapier.
    pub raw: &'a Cuboid,
}

macro_rules! impl_ref_methods(
    ($View: ident) => {
        impl<'a> $View<'a> {
            /// The half-extents of the cuboid.
            pub fn half_extents(&self) -> Vect {
                self.raw.half_extents.into()
            }
        }
    }
);

impl_ref_methods!(CuboidView);

/// Read-write access to the properties of a cuboid.
pub struct CuboidViewMut<'a> {
    /// The raw shape from Rapier.
    pub raw: &'a mut Cuboid,
}

impl_ref_methods!(CuboidViewMut);

impl<'a> CuboidViewMut<'a> {
    /// Set the half-extents of the cuboid.
    pub fn set_half_extents(&mut self, half_extents: Vect) {
        self.raw.half_extents = half_extents.into();
    }
}