use crate::math::Vect;
use rapier::parry::shape::HalfSpace;
#[derive(Copy, Clone)]
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
}
}
}
);
impl_ref_methods!(HalfSpaceView);
pub struct HalfSpaceViewMut<'a> {
pub raw: &'a mut HalfSpace,
}
impl_ref_methods!(HalfSpaceViewMut);
impl HalfSpaceViewMut<'_> {
pub fn set_normal(&mut self, normal: Vect) {
let normal: rapier::math::Vector = normal;
if normal.length_squared() >= 1.0e-12 {
self.raw.normal = normal.normalize();
}
}
}