aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-06-23 16:23:39 +0200
committerSébastien Crozet <developer@crozet.re>2022-07-03 13:55:41 +0200
commit5063f3bb4fec2716f78a208552ee260f22428840 (patch)
treeb5665abb9c97469354c8c4dfd1a3fca21057ce16 /src/geometry
parentcd0be8c076c69b88bb1848de72228225eeccb52d (diff)
downloadrapier-5063f3bb4fec2716f78a208552ee260f22428840.tar.gz
rapier-5063f3bb4fec2716f78a208552ee260f22428840.tar.bz2
rapier-5063f3bb4fec2716f78a208552ee260f22428840.zip
Add the ability to disable contacts between two rigid-bodies attached by joints
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/narrow_phase.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs
index a1256b8..ecd1623 100644
--- a/src/geometry/narrow_phase.rs
+++ b/src/geometry/narrow_phase.rs
@@ -4,7 +4,8 @@ use rayon::prelude::*;
use crate::data::graph::EdgeIndex;
use crate::data::Coarena;
use crate::dynamics::{
- CoefficientCombineRule, IslandManager, RigidBodyDominance, RigidBodySet, RigidBodyType,
+ CoefficientCombineRule, ImpulseJointSet, IslandManager, RigidBodyDominance, RigidBodySet,
+ RigidBodyType,
};
use crate::geometry::{
BroadPhasePairEvent, ColliderChanges, ColliderGraphIndex, ColliderHandle, ColliderPair,
@@ -16,7 +17,7 @@ use crate::pipeline::{
ActiveEvents, ActiveHooks, ContactModificationContext, EventHandler, PairFilterContext,
PhysicsHooks,
};
-use crate::prelude::CollisionEventFlags;
+use crate::prelude::{CollisionEventFlags, MultibodyJointSet};
use parry::query::{DefaultQueryDispatcher, PersistentQueryDispatcher};
use parry::utils::IsometryOpt;
use std::collections::HashMap;
@@ -774,6 +775,8 @@ impl NarrowPhase {
prediction_distance: Real,
bodies: &RigidBodySet,
colliders: &ColliderSet,
+ impulse_joints: &ImpulseJointSet,
+ multibody_joints: &MultibodyJointSet,
modified_colliders: &[ColliderHandle],
hooks: &dyn PhysicsHooks,
events: &dyn EventHandler,
@@ -812,6 +815,27 @@ impl NarrowPhase {
rb_type2 = bodies[co_parent2.handle].body_type;
}
+ // Deal with contacts disabled between bodies attached by joints.
+ if let (Some(co_parent1), Some(co_parent2)) = (&co1.parent, &co2.parent) {
+ for (_, joint) in
+ impulse_joints.joints_between(co_parent1.handle, co_parent2.handle)
+ {
+ if !joint.data.contacts_enabled {
+ pair.clear();
+ break 'emit_events;
+ }
+ }
+
+ if let Some((_, _, mb_link)) =
+ multibody_joints.joint_between(co_parent1.handle, co_parent2.handle)
+ {
+ if !mb_link.joint.data.contacts_enabled {
+ pair.clear();
+ break 'emit_events;
+ }
+ }
+ }
+
// Filter based on the rigid-body types.
if !co1.flags.active_collision_types.test(rb_type1, rb_type2)
&& !co2.flags.active_collision_types.test(rb_type1, rb_type2)