aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/narrow_phase.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-01-21 16:03:27 +0100
committerCrozet Sébastien <developer@crozet.re>2021-01-21 16:03:27 +0100
commit98d3980db7a9803f4ee965237599a87771a417d1 (patch)
treeb46aeef3ef6f703d0e938b5e1b778aa0f73a4680 /src/geometry/narrow_phase.rs
parent8f330b2a00610e5b68c1acd9208120e8f750c7aa (diff)
downloadrapier-98d3980db7a9803f4ee965237599a87771a417d1.tar.gz
rapier-98d3980db7a9803f4ee965237599a87771a417d1.tar.bz2
rapier-98d3980db7a9803f4ee965237599a87771a417d1.zip
Allow several rules for combining friction/restitution coefficients.
Diffstat (limited to 'src/geometry/narrow_phase.rs')
-rw-r--r--src/geometry/narrow_phase.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs
index 621a3b4..8a9e578 100644
--- a/src/geometry/narrow_phase.rs
+++ b/src/geometry/narrow_phase.rs
@@ -3,7 +3,7 @@ use rayon::prelude::*;
use crate::data::pubsub::Subscription;
use crate::data::Coarena;
-use crate::dynamics::{BodyPair, RigidBodySet};
+use crate::dynamics::{BodyPair, CoefficientCombineRule, RigidBodySet};
use crate::geometry::{
BroadPhasePairEvent, ColliderGraphIndex, ColliderHandle, ContactData, ContactEvent,
ContactManifoldData, ContactPairFilter, IntersectionEvent, PairFilterContext,
@@ -522,6 +522,19 @@ impl NarrowPhase {
let mut has_any_active_contact = false;
+ let friction = CoefficientCombineRule::combine(
+ co1.friction,
+ co2.friction,
+ co1.flags.friction_combine_rule_value(),
+ co2.flags.friction_combine_rule_value(),
+ );
+ let restitution = CoefficientCombineRule::combine(
+ co1.restitution,
+ co2.restitution,
+ co1.flags.restitution_combine_rule_value(),
+ co2.flags.restitution_combine_rule_value(),
+ );
+
for manifold in &mut pair.manifolds {
let world_pos1 = manifold.subshape_pos1.prepend_to(co1.position());
manifold.data.solver_contacts.clear();
@@ -541,8 +554,8 @@ impl NarrowPhase {
point: world_pos1 * contact.local_p1
+ manifold.data.normal * contact.dist / 2.0,
dist: contact.dist,
- friction: (co1.friction + co2.friction) / 2.0,
- restitution: (co1.restitution + co2.restitution) / 2.0,
+ friction,
+ restitution,
surface_velocity: Vector::zeros(),
data: contact.data,
};