diff --git a/crates/fj-math/src/aabb.rs b/crates/fj-math/src/aabb.rs index 7c5b9e496..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}; @@ -67,6 +68,19 @@ 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(), + } + } + + /// Merge this AABB with another + pub fn merged(&self, other: &Self) -> Self { + self.to_parry().merged(&other.to_parry()).into() + } } impl Aabb<3> {