aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/collider.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-01-21 16:29:05 +0100
committerCrozet Sébastien <developer@crozet.re>2021-01-21 16:29:05 +0100
commit800b35b103c60a3f13dffdfe1c20561074041cea (patch)
treefdedf5109816f7790278c0ab40403f7b646db7f2 /src/geometry/collider.rs
parent98d3980db7a9803f4ee965237599a87771a417d1 (diff)
downloadrapier-800b35b103c60a3f13dffdfe1c20561074041cea.tar.gz
rapier-800b35b103c60a3f13dffdfe1c20561074041cea.tar.bz2
rapier-800b35b103c60a3f13dffdfe1c20561074041cea.zip
Add collider constructors for shapes obtained from convex decomposition.
Diffstat (limited to 'src/geometry/collider.rs')
-rw-r--r--src/geometry/collider.rs51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index c5f53f7..232b246 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -1,6 +1,7 @@
+use crate::cdl::transformation::vhacd::VHACDParameters;
use crate::dynamics::{CoefficientCombineRule, MassProperties, RigidBodyHandle};
use crate::geometry::{ColliderShape, InteractionGroups};
-use crate::math::{AngVector, Isometry, Point, Real, Rotation, Vector};
+use crate::math::{AngVector, Isometry, Point, Real, Rotation, Vector, DIM};
use cdl::bounding_volume::AABB;
use cdl::shape::Shape;
#[cfg(feature = "dim2")]
@@ -299,6 +300,54 @@ impl ColliderBuilder {
Self::new(ColliderShape::trimesh(vertices, indices))
}
+ /// Initializes a collider builder with a compound shape obtained from the decomposition of
+ /// the given trimesh (in 3D) or polyline (in 2D) into convex parts.
+ pub fn convex_decomposition(vertices: &[Point<Real>], indices: &[[u32; DIM]]) -> Self {
+ Self::new(ColliderShape::convex_decomposition(vertices, indices))
+ }
+
+ /// Initializes a collider builder with a compound shape obtained from the decomposition of
+ /// the given trimesh (in 3D) or polyline (in 2D) into convex parts dilated with round corners.
+ pub fn round_convex_decomposition(
+ vertices: &[Point<Real>],
+ indices: &[[u32; DIM]],
+ border_radius: Real,
+ ) -> Self {
+ Self::new(ColliderShape::round_convex_decomposition(
+ vertices,
+ indices,
+ border_radius,
+ ))
+ }
+
+ /// Initializes a collider builder with a compound shape obtained from the decomposition of
+ /// the given trimesh (in 3D) or polyline (in 2D) into convex parts.
+ pub fn convex_decomposition_with_params(
+ vertices: &[Point<Real>],
+ indices: &[[u32; DIM]],
+ params: &VHACDParameters,
+ ) -> Self {
+ Self::new(ColliderShape::convex_decomposition_with_params(
+ vertices, indices, params,
+ ))
+ }
+
+ /// Initializes a collider builder with a compound shape obtained from the decomposition of
+ /// the given trimesh (in 3D) or polyline (in 2D) into convex parts dilated with round corners.
+ pub fn round_convex_decomposition_with_params(
+ vertices: &[Point<Real>],
+ indices: &[[u32; DIM]],
+ params: &VHACDParameters,
+ border_radius: Real,
+ ) -> Self {
+ Self::new(ColliderShape::round_convex_decomposition_with_params(
+ vertices,
+ indices,
+ params,
+ border_radius,
+ ))
+ }
+
pub fn convex_hull(points: &[Point<Real>]) -> Option<Self> {
ColliderShape::convex_hull(points).map(|cp| Self::new(cp))
}