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
38
39
use crate::math::Vect;
use rapier::parry::shape::HalfSpace;
pub struct HalfSpaceView<'a> {
pub raw: &'a HalfSpace,
}
macro_rules! impl_ref_methods(
($View: ident) => {
impl<'a> $View<'a> {
pub fn normal(&self) -> Vect {
(*self.raw.normal).into()
}
}
}
);
impl_ref_methods!(HalfSpaceView);
pub struct HalfSpaceViewMut<'a> {
pub raw: &'a mut HalfSpace,
}
impl_ref_methods!(HalfSpaceViewMut);
impl<'a> HalfSpaceViewMut<'a> {
pub fn set_normal(&mut self, normal: Vect) {
let normal: rapier::math::Vector<_> = normal.into();
if let Some(unit_normal) = na::Unit::try_new(normal, 1.0e-6) {
self.raw.normal = unit_normal;
}
}
}