bevy_rapier2d/geometry/shape_views/
convex_polygon.rsuse crate::math::Vect;
use rapier::parry::shape::ConvexPolygon;
#[derive(Copy, Clone)]
pub struct ConvexPolygonView<'a> {
pub raw: &'a ConvexPolygon,
}
impl ConvexPolygonView<'_> {
pub fn points(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
self.raw.points().iter().map(|pt| (*pt).into())
}
pub fn normals(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
self.raw.normals().iter().map(|n| (**n).into())
}
}
pub struct ConvexPolygonViewMut<'a> {
pub raw: &'a mut ConvexPolygon,
}
impl ConvexPolygonViewMut<'_> {
pub fn points(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
self.raw.points().iter().map(|pt| (*pt).into())
}
pub fn normals(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
self.raw.normals().iter().map(|n| (**n).into())
}
}