From 36b1c5578181dce2b5b5e5e94fd10b2dd1fee6db Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Jun 2023 10:33:15 +0200 Subject: [PATCH 1/2] Add `Aabb<2>::to_parry` --- crates/fj-math/src/aabb.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/fj-math/src/aabb.rs b/crates/fj-math/src/aabb.rs index 7c5b9e496..a0c10e8d0 100644 --- a/crates/fj-math/src/aabb.rs +++ b/crates/fj-math/src/aabb.rs @@ -67,6 +67,14 @@ impl Aabb<2> { max: aabb.maxs.into(), } } + + /// Convert the AABB to a Parry AABB + pub fn to_parry(self) -> parry2d_f64::bounding_volume::Aabb { + parry2d_f64::bounding_volume::Aabb { + mins: self.min.to_na(), + maxs: self.max.to_na(), + } + } } impl Aabb<3> { From 5bd0192d0fd7669e5a5a2dc5b84b8931643b1791 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Jun 2023 10:34:08 +0200 Subject: [PATCH 2/2] Add `Aabb<2>::merged` --- crates/fj-math/src/aabb.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/fj-math/src/aabb.rs b/crates/fj-math/src/aabb.rs index a0c10e8d0..e67f3dc97 100644 --- a/crates/fj-math/src/aabb.rs +++ b/crates/fj-math/src/aabb.rs @@ -1,3 +1,4 @@ +use parry2d_f64::bounding_volume::BoundingVolume as _; use parry3d_f64::bounding_volume::BoundingVolume as _; use super::{Point, Vector}; @@ -75,6 +76,11 @@ impl Aabb<2> { maxs: self.max.to_na(), } } + + /// Merge this AABB with another + pub fn merged(&self, other: &Self) -> Self { + self.to_parry().merged(&other.to_parry()).into() + } } impl Aabb<3> {