bevy_rapier3d/geometry/shape_views/
cone.rs

1use crate::math::Real;
2use rapier::parry::shape::Cone;
3
4/// Read-only access to the properties of a cone.
5#[derive(Copy, Clone)]
6pub struct ConeView<'a> {
7    /// The raw shape from Rapier.
8    pub raw: &'a Cone,
9}
10
11macro_rules! impl_ref_methods(
12    ($View: ident) => {
13        impl<'a> $View<'a> {
14            /// The half-height of the cone.
15            pub fn half_height(&self) -> Real {
16                self.raw.half_height
17            }
18
19            /// The base radius of the cone.
20            pub fn radius(&self) -> Real {
21                self.raw.radius
22            }
23        }
24    }
25);
26
27impl_ref_methods!(ConeView);
28
29/// Read-write access to the properties of a cone.
30pub struct ConeViewMut<'a> {
31    /// The raw shape from Rapier.
32    pub raw: &'a mut Cone,
33}
34
35impl_ref_methods!(ConeViewMut);
36
37impl ConeViewMut<'_> {
38    /// Set the half-height of the cone.
39    pub fn set_half_height(&mut self, half_height: Real) {
40        self.raw.half_height = half_height;
41    }
42
43    /// Set the radius of the basis of the cone.
44    pub fn set_radius(&mut self, radius: Real) {
45        self.raw.radius = radius;
46    }
47}