Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parry next version (0.18.x) #763

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ resolver = "2"
#parry2d-f64 = { git = "https://github.com/dimforge/parry", branch = "master" }
#parry3d-f64 = { git = "https://github.com/dimforge/parry", branch = "master" }


parry2d = { git = "https://github.com/Vrixyz/parry", branch = "273-shape-shape-best" }
parry3d = { git = "https://github.com/Vrixyz/parry", branch = "273-shape-shape-best" }
parry2d-f64 = { git = "https://github.com/Vrixyz/parry", branch = "273-shape-shape-best" }
parry3d-f64 = { git = "https://github.com/Vrixyz/parry", branch = "273-shape-shape-best" }

# # For feature unstable-puffin-pr-235
# # See https://github.com/dimforge/rapier/issues/760.
# puffin_egui = { version = "0.29", optional = true, git = "https://github.com/Vrixyz/puffin.git", branch = "expose_ui_options" }
Expand Down
2 changes: 1 addition & 1 deletion benchmarks3d/trimesh3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn init_world(testbed: &mut Testbed) {

let rigid_body = RigidBodyBuilder::fixed();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::trimesh(vertices, indices);
let collider = ColliderBuilder::trimesh(vertices, indices).unwrap();
colliders.insert_with_parent(collider, handle, &mut bodies);

/*
Expand Down
1 change: 1 addition & 0 deletions examples2d/trimesh2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub fn init_world(testbed: &mut Testbed) {

for k in 0..5 {
let collider = ColliderBuilder::trimesh(vertices.clone(), indices.clone())
.unwrap()
.contact_skin(0.2);
let rigid_body = RigidBodyBuilder::dynamic()
.translation(vector![ith as f32 * 8.0 - 20.0, 20.0 + k as f32 * 11.0])
Expand Down
2 changes: 1 addition & 1 deletion examples3d/debug_trimesh3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn init_world(testbed: &mut Testbed) {

let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, 0.0, 0.0]);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::trimesh(vtx, idx);
let collider = ColliderBuilder::trimesh(vtx, idx).expect("Could not create trimesh collider.");
colliders.insert_with_parent(collider, handle, &mut bodies);
testbed.set_initial_body_color(handle, [0.3, 0.3, 0.3]);

Expand Down
1 change: 1 addition & 0 deletions examples3d/dynamic_trimesh3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub fn do_init_world(testbed: &mut Testbed, use_convex_decomposition: bool) {
} else {
// SharedShape::trimesh(vertices, indices)
SharedShape::trimesh_with_flags(vertices, indices, TriMeshFlags::FIX_INTERNAL_EDGES)
.unwrap()
};
shapes.push(decomposed_shape);

Expand Down
3 changes: 2 additions & 1 deletion examples3d/trimesh3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub fn init_world(testbed: &mut Testbed) {
vertices,
indices,
TriMeshFlags::MERGE_DUPLICATE_VERTICES,
);
)
.unwrap();
colliders.insert_with_parent(collider, handle, &mut bodies);

/*
Expand Down
15 changes: 10 additions & 5 deletions src/geometry/collider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/geometry/mesh_converter.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 6 additions & 9 deletions src/pipeline/query_pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,14 @@ impl QueryPipeline {
filter: QueryFilter,
) -> Option<ColliderHandle> {
let pipeline_shape = self.as_composite_shape(bodies, colliders, filter);
#[allow(deprecated)]
// TODO: replace this with IntersectionCompositeShapeShapeVisitor when it
// can return the shape part id.
let mut visitor =
parry::query::details::IntersectionCompositeShapeShapeBestFirstVisitor::new(
&*self.query_dispatcher,
shape_pos,
&pipeline_shape,
shape,
);

let mut visitor = parry::query::details::IntersectionCompositeShapeShapeVisitor::new(
&*self.query_dispatcher,
shape_pos,
&pipeline_shape,
shape,
);
self.qbvh
.traverse_best_first(&mut visitor)
.map(|h| (h.1 .0))
Comment on lines 491 to 493
Copy link
Contributor Author

@Vrixyz Vrixyz Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use traverse_depth_first + benchmark in big scene (100x100x100 cubes + query)

Expand Down
Loading