bevy_rapier2d/geometry/shape_views/
halfspace.rs1use crate::math::Vect;
2use rapier::parry::shape::HalfSpace;
3
4#[derive(Copy, Clone)]
6pub struct HalfSpaceView<'a> {
7 pub raw: &'a HalfSpace,
9}
10
11macro_rules! impl_ref_methods(
12 ($View: ident) => {
13 impl<'a> $View<'a> {
14 pub fn normal(&self) -> Vect {
16 (*self.raw.normal).into()
17 }
18 }
19 }
20);
21
22impl_ref_methods!(HalfSpaceView);
23
24pub struct HalfSpaceViewMut<'a> {
26 pub raw: &'a mut HalfSpace,
28}
29
30impl_ref_methods!(HalfSpaceViewMut);
31
32impl HalfSpaceViewMut<'_> {
33 pub fn set_normal(&mut self, normal: Vect) {
35 let normal: rapier::math::Vector<_> = normal.into();
36 if let Some(unit_normal) = na::Unit::try_new(normal, 1.0e-6) {
37 self.raw.normal = unit_normal;
38 }
39 }
40}