From 9bf1321f8f1d2e116f44c2461a53f302c4ef4171 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 8 Dec 2020 17:31:49 +0100 Subject: Outsource the contact manifold, SAT, and some shapes. --- src/geometry/shape.rs | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'src/geometry/shape.rs') diff --git a/src/geometry/shape.rs b/src/geometry/shape.rs index 66840a0..80b24c5 100644 --- a/src/geometry/shape.rs +++ b/src/geometry/shape.rs @@ -1,17 +1,18 @@ use crate::dynamics::MassProperties; use crate::geometry::{Ball, Capsule, Cuboid, HeightField, Segment, Triangle, Trimesh}; use crate::math::Isometry; +use buckler::bounding_volume::AABB; +use buckler::query::{PointQuery, RayCast}; use downcast_rs::{impl_downcast, DowncastSync}; #[cfg(feature = "serde-serialize")] use erased_serde::Serialize; -use ncollide::bounding_volume::{HasBoundingVolume, AABB}; -use ncollide::query::{PointQuery, RayCast}; use num::Zero; use num_derive::FromPrimitive; #[cfg(feature = "dim3")] use { - crate::geometry::{Cone, Cylinder, PolygonalFeatureMap, RoundCylinder}, - ncollide::bounding_volume::BoundingVolume, + crate::geometry::{Cone, Cylinder, RoundCylinder}, + buckler::bounding_volume::BoundingVolume, + buckler::shape::PolygonalFeatureMap, }; #[derive(Copy, Clone, Debug, FromPrimitive)] @@ -57,7 +58,7 @@ pub enum ShapeType { } /// Trait implemented by shapes usable by Rapier. -pub trait Shape: RayCast + PointQuery + DowncastSync { +pub trait Shape: RayCast + PointQuery + DowncastSync { /// Convert this shape as a serializable entity. #[cfg(feature = "serde-serialize")] fn as_serialize(&self) -> Option<&dyn Serialize> { @@ -67,7 +68,7 @@ pub trait Shape: RayCast + PointQuery + DowncastSync { // TODO: add a compute_local_aabb method? /// Computes the AABB of this shape. - fn compute_aabb(&self, position: &Isometry) -> AABB; + fn compute_aabb(&self, position: &Isometry) -> AABB; /// Compute the mass-properties of this shape given its uniform density. fn mass_properties(&self, density: f32) -> MassProperties; @@ -144,8 +145,8 @@ impl Shape for Ball { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, density: f32) -> MassProperties { @@ -163,7 +164,7 @@ impl Shape for Ball { // Some(self as &dyn Serialize) // } // -// fn compute_aabb(&self, position: &Isometry) -> AABB { +// fn compute_aabb(&self, position: &Isometry) -> AABB { // self.aabb(position) // } // @@ -182,8 +183,8 @@ impl Shape for Cuboid { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, density: f32) -> MassProperties { @@ -206,7 +207,7 @@ impl Shape for Capsule { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { + fn compute_aabb(&self, position: &Isometry) -> AABB { self.aabb(position) } @@ -230,8 +231,8 @@ impl Shape for Triangle { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, _density: f32) -> MassProperties { @@ -254,8 +255,8 @@ impl Shape for Segment { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, _density: f32) -> MassProperties { @@ -278,7 +279,7 @@ impl Shape for Trimesh { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { + fn compute_aabb(&self, position: &Isometry) -> AABB { self.aabb(position) } @@ -297,8 +298,8 @@ impl Shape for HeightField { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, _density: f32) -> MassProperties { @@ -317,8 +318,8 @@ impl Shape for Cylinder { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, density: f32) -> MassProperties { @@ -342,8 +343,8 @@ impl Shape for Cone { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { - self.bounding_volume(position) + fn compute_aabb(&self, position: &Isometry) -> AABB { + self.aabb(position) } fn mass_properties(&self, density: f32) -> MassProperties { @@ -367,7 +368,7 @@ impl Shape for RoundCylinder { Some(self as &dyn Serialize) } - fn compute_aabb(&self, position: &Isometry) -> AABB { + fn compute_aabb(&self, position: &Isometry) -> AABB { self.cylinder .compute_aabb(position) .loosened(self.border_radius) -- cgit