bevy_rapier2d/geometry/shape_views/
convex_polygon.rs1use crate::math::Vect;
2use rapier::parry::shape::ConvexPolygon;
3
4#[derive(Copy, Clone)]
6pub struct ConvexPolygonView<'a> {
7 pub raw: &'a ConvexPolygon,
9}
10
11impl ConvexPolygonView<'_> {
12 pub fn points(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
14 self.raw.points().iter().map(|pt| (*pt).into())
15 }
16
17 pub fn normals(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
19 self.raw.normals().iter().map(|n| (**n).into())
20 }
21}
22
23pub struct ConvexPolygonViewMut<'a> {
25 pub raw: &'a mut ConvexPolygon,
27}
28
29impl ConvexPolygonViewMut<'_> {
30 pub fn points(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
32 self.raw.points().iter().map(|pt| (*pt).into())
33 }
34
35 pub fn normals(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
37 self.raw.normals().iter().map(|n| (**n).into())
38 }
39
40 }