bevy_rapier2d/geometry/shape_views/
halfspace.rsuse 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).into()
}
}
}
);
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.into();
if let Some(unit_normal) = na::Unit::try_new(normal, 1.0e-6) {
self.raw.normal = unit_normal;
}
}
}