aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2024-04-07 22:17:35 +0200
committerSébastien Crozet <sebastien@crozet.re>2024-04-30 23:10:46 +0200
commit7cbbb8e87b2710e819ca179b2f43c1a7633aedfa (patch)
treedc8d489ce8ccd9fc75ad2ed122f5b8275458b55c
parent996400726927fb952999afbc36db6e2bfba7d44e (diff)
downloadrapier-7cbbb8e87b2710e819ca179b2f43c1a7633aedfa.tar.gz
rapier-7cbbb8e87b2710e819ca179b2f43c1a7633aedfa.tar.bz2
rapier-7cbbb8e87b2710e819ca179b2f43c1a7633aedfa.zip
feat: add Collider::heightfield_with_flags
-rw-r--r--src/geometry/collider.rs14
-rw-r--r--src/pipeline/collision_pipeline.rs1
-rw-r--r--src/pipeline/query_pipeline.rs15
3 files changed, 25 insertions, 5 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index 5d2fa77..4ddd44e 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -12,6 +12,9 @@ use na::Unit;
use parry::bounding_volume::Aabb;
use parry::shape::{Shape, TriMeshFlags};
+#[cfg(feature = "dim3")]
+use crate::geometry::HeightFieldFlags;
+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[derive(Clone)]
/// A geometric entity that can be attached to a body so it can be affected by contacts and proximity queries.
@@ -760,6 +763,17 @@ impl ColliderBuilder {
Self::new(SharedShape::heightfield(heights, scale))
}
+ /// Initializes a collider builder with a heightfield shape defined by its set of height and a scale
+ /// factor along each coordinate axis.
+ #[cfg(feature = "dim3")]
+ pub fn heightfield_with_flags(
+ heights: na::DMatrix<Real>,
+ scale: Vector<Real>,
+ flags: HeightFieldFlags,
+ ) -> Self {
+ Self::new(SharedShape::heightfield_with_flags(heights, scale, flags))
+ }
+
/// The default friction coefficient used by the collider builder.
pub fn default_friction() -> Real {
0.5
diff --git a/src/pipeline/collision_pipeline.rs b/src/pipeline/collision_pipeline.rs
index 66bd9ad..f8bee80 100644
--- a/src/pipeline/collision_pipeline.rs
+++ b/src/pipeline/collision_pipeline.rs
@@ -80,6 +80,7 @@ impl CollisionPipeline {
narrow_phase.register_pairs(None, colliders, bodies, &self.broad_phase_events, events);
narrow_phase.compute_contacts(
prediction_distance,
+ 0.0,
bodies,
colliders,
&ImpulseJointSet::new(),
diff --git a/src/pipeline/query_pipeline.rs b/src/pipeline/query_pipeline.rs
index 4dc5652..59af7c6 100644
--- a/src/pipeline/query_pipeline.rs
+++ b/src/pipeline/query_pipeline.rs
@@ -6,8 +6,8 @@ use crate::math::{Isometry, Point, Real, Vector};
use crate::{dynamics::RigidBodySet, geometry::ColliderSet};
use parry::partitioning::{QbvhDataGenerator, QbvhUpdateWorkspace};
use parry::query::details::{
- NonlinearTOICompositeShapeShapeBestFirstVisitor, PointCompositeShapeProjBestFirstVisitor,
- PointCompositeShapeProjWithFeatureBestFirstVisitor,
+ NonlinearTOICompositeShapeShapeBestFirstVisitor, NormalConstraints,
+ PointCompositeShapeProjBestFirstVisitor, PointCompositeShapeProjWithFeatureBestFirstVisitor,
RayCompositeShapeToiAndNormalBestFirstVisitor, RayCompositeShapeToiBestFirstVisitor,
TOICompositeShapeShapeBestFirstVisitor,
};
@@ -246,17 +246,22 @@ pub enum QueryPipelineMode {
impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> {
type PartShape = dyn Shape;
+ type PartNormalConstraints = dyn NormalConstraints;
type PartId = ColliderHandle;
type QbvhStorage = DefaultStorage;
fn map_typed_part_at(
&self,
shape_id: Self::PartId,
- mut f: impl FnMut(Option<&Isometry<Real>>, &Self::PartShape),
+ mut f: impl FnMut(
+ Option<&Isometry<Real>>,
+ &Self::PartShape,
+ Option<&Self::PartNormalConstraints>,
+ ),
) {
if let Some(co) = self.colliders.get(shape_id) {
if self.filter.test(self.bodies, shape_id, co) {
- f(Some(&co.pos), &*co.shape)
+ f(Some(&co.pos), &*co.shape, None)
}
}
}
@@ -264,7 +269,7 @@ impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> {
fn map_untyped_part_at(
&self,
shape_id: Self::PartId,
- f: impl FnMut(Option<&Isometry<Real>>, &Self::PartShape),
+ f: impl FnMut(Option<&Isometry<Real>>, &Self::PartShape, Option<&dyn NormalConstraints>),
) {
self.map_typed_part_at(shape_id, f);
}