aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorThierry Berger <contact@thierryberger.com>2025-01-08 17:16:34 +0100
committerGitHub <noreply@github.com>2025-01-08 17:16:34 +0100
commitdc4bd24da869cfa8143c3ee9a98cdec662db289e (patch)
tree6ea25968a264636f40c4042ef19f3a25d9c4f52f /src/geometry
parentcf77b5bf574f8363794f979510deec5c08e58401 (diff)
downloadrapier-dc4bd24da869cfa8143c3ee9a98cdec662db289e.tar.gz
rapier-dc4bd24da869cfa8143c3ee9a98cdec662db289e.tar.bz2
rapier-dc4bd24da869cfa8143c3ee9a98cdec662db289e.zip
Update to Parry 0.18 (#770)
* update to parry ~main * use traverse_depth_first * add example to test intersection * rely on upstream PR rather than local * re-enable profiler_ui for examples * rely on official parry repository * chore: switch back to the published version of parry * chore: update changelog * chore: remove dead code * fix compilation of rapier3d-meshloader and rapier3d-urdf * chore: cargo fmt --------- Co-authored-by: Sébastien Crozet <sebcrozet@dimforge.com>
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/collider.rs15
-rw-r--r--src/geometry/mesh_converter.rs9
2 files changed, 17 insertions, 7 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index c0cec6b..4f5312f 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -10,7 +10,7 @@ use crate::pipeline::{ActiveEvents, ActiveHooks};
use crate::prelude::ColliderEnabled;
use na::Unit;
use parry::bounding_volume::{Aabb, BoundingVolume};
-use parry::shape::{Shape, TriMeshFlags};
+use parry::shape::{Shape, TriMeshBuilderError, TriMeshFlags};
#[cfg(feature = "dim3")]
use crate::geometry::HeightFieldFlags;
@@ -685,8 +685,11 @@ impl ColliderBuilder {
}
/// Initializes a collider builder with a triangle mesh shape defined by its vertex and index buffers.
- pub fn trimesh(vertices: Vec<Point<Real>>, indices: Vec<[u32; 3]>) -> Self {
- Self::new(SharedShape::trimesh(vertices, indices))
+ pub fn trimesh(
+ vertices: Vec<Point<Real>>,
+ indices: Vec<[u32; 3]>,
+ ) -> Result<Self, TriMeshBuilderError> {
+ Ok(Self::new(SharedShape::trimesh(vertices, indices)?))
}
/// Initializes a collider builder with a triangle mesh shape defined by its vertex and index buffers and
@@ -695,8 +698,10 @@ impl ColliderBuilder {
vertices: Vec<Point<Real>>,
indices: Vec<[u32; 3]>,
flags: TriMeshFlags,
- ) -> Self {
- Self::new(SharedShape::trimesh_with_flags(vertices, indices, flags))
+ ) -> Result<Self, TriMeshBuilderError> {
+ Ok(Self::new(SharedShape::trimesh_with_flags(
+ vertices, indices, flags,
+ )?))
}
/// Initializes a collider builder with a shape converted from the given triangle mesh index
diff --git a/src/geometry/mesh_converter.rs b/src/geometry/mesh_converter.rs
index cfa1391..13868fd 100644
--- a/src/geometry/mesh_converter.rs
+++ b/src/geometry/mesh_converter.rs
@@ -1,6 +1,6 @@
use parry::bounding_volume;
use parry::math::{Isometry, Point, Real};
-use parry::shape::{Cuboid, SharedShape, TriMeshFlags};
+use parry::shape::{Cuboid, SharedShape, TriMeshBuilderError, TriMeshFlags};
#[cfg(feature = "dim3")]
use parry::transformation::vhacd::VHACDParameters;
@@ -17,6 +17,9 @@ pub enum MeshConverterError {
/// The convex hull calculation carried out by the [`MeshConverter::ConvexHull`] failed.
#[error("convex-hull computation failed")]
ConvexHullFailed,
+ /// The TriMesh building failed.
+ #[error("TriMesh building failed")]
+ TriMeshBuilderError(TriMeshBuilderError),
}
/// Determines how meshes (generally when loaded from a file) are converted into Rapier colliders.
@@ -61,9 +64,11 @@ impl MeshConverter {
) -> Result<(SharedShape, Isometry<Real>), MeshConverterError> {
let mut transform = Isometry::identity();
let shape = match self {
- MeshConverter::TriMesh => SharedShape::trimesh(vertices, indices),
+ MeshConverter::TriMesh => SharedShape::trimesh(vertices, indices)
+ .map_err(MeshConverterError::TriMeshBuilderError)?,
MeshConverter::TriMeshWithFlags(flags) => {
SharedShape::trimesh_with_flags(vertices, indices, *flags)
+ .map_err(MeshConverterError::TriMeshBuilderError)?
}
MeshConverter::Obb => {
let (pose, cuboid) = parry::utils::obb(&vertices);