bevy_rapier3d/geometry/shape_views/
ball.rs

1use crate::math::Real;
2use rapier::parry::shape::Ball;
3
4/// Read-only access to the properties of a ball.
5#[derive(Copy, Clone)]
6pub struct BallView<'a> {
7    /// The raw shape from Rapier.
8    pub raw: &'a Ball,
9}
10
11macro_rules! impl_ref_methods(
12    ($View: ident) => {
13        impl<'a> $View<'a> {
14            /// The radius of the ball.
15            pub fn radius(&self) -> Real {
16                self.raw.radius
17            }
18        }
19    }
20);
21
22impl_ref_methods!(BallView);
23
24/// Read-write access to the properties of a ball.
25pub struct BallViewMut<'a> {
26    /// The raw shape from Rapier.
27    pub raw: &'a mut Ball,
28}
29
30impl_ref_methods!(BallViewMut);
31
32impl BallViewMut<'_> {
33    /// Set the radius of the ball.
34    pub fn set_radius(&mut self, radius: Real) {
35        self.raw.radius = radius;
36    }
37}