Skip to content

Commit f245490

Browse files
authored
implement Bounded2d for ConvexPolygon (#18286)
# Objective - Implement `Bounded2d` for `ConvexPolygon`
1 parent 2c22bc1 commit f245490

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use crate::{
44
bounding::BoundingVolume,
55
ops,
66
primitives::{
7-
Annulus, Arc2d, Capsule2d, Circle, CircularSector, CircularSegment, Ellipse, Line2d,
8-
Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d,
7+
Annulus, Arc2d, Capsule2d, Circle, CircularSector, CircularSegment, ConvexPolygon, Ellipse,
8+
Line2d, Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d,
9+
Triangle2d,
910
},
1011
Dir2, Isometry2d, Mat2, Rot2, Vec2,
1112
};
@@ -375,6 +376,16 @@ impl<const N: usize> Bounded2d for Polygon<N> {
375376
}
376377
}
377378

379+
impl<const N: usize> Bounded2d for ConvexPolygon<N> {
380+
fn aabb_2d(&self, isometry: impl Into<Isometry2d>) -> Aabb2d {
381+
Aabb2d::from_point_cloud(isometry, self.vertices().as_slice())
382+
}
383+
384+
fn bounding_circle(&self, isometry: impl Into<Isometry2d>) -> BoundingCircle {
385+
BoundingCircle::from_point_cloud(isometry, self.vertices().as_slice())
386+
}
387+
}
388+
378389
#[cfg(feature = "alloc")]
379390
impl Bounded2d for BoxedPolygon {
380391
fn aabb_2d(&self, isometry: impl Into<Isometry2d>) -> Aabb2d {

0 commit comments

Comments
 (0)