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>
This commit is contained in:
Thierry Berger
2025-01-08 17:16:34 +01:00
committed by GitHub
parent cf77b5bf57
commit dc4bd24da8
26 changed files with 129 additions and 45 deletions

View File

@@ -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

View File

@@ -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);