diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-01-21 16:03:27 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-01-21 16:03:27 +0100 |
| commit | 98d3980db7a9803f4ee965237599a87771a417d1 (patch) | |
| tree | b46aeef3ef6f703d0e938b5e1b778aa0f73a4680 /src/geometry/narrow_phase.rs | |
| parent | 8f330b2a00610e5b68c1acd9208120e8f750c7aa (diff) | |
| download | rapier-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.rs | 19 |
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, }; |
