From a5271be988e9e72c299f295d7ae60d0a71cb81e3 Mon Sep 17 00:00:00 2001 From: brendan c Date: Wed, 23 Jul 2025 18:59:47 -0700 Subject: [PATCH 1/2] add a flag `first_tick` to ContactForceEvent that is true if this is the first tick on which corresponding contact has generated a force --- src/geometry/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index a947c9ed0..f07e46b72 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -146,6 +146,10 @@ pub struct ContactForceEvent { pub max_force_direction: Vector, /// The magnitude of the largest force at a contact point of this contact pair. pub max_force_magnitude: Real, + + /// True if this the first physics tick on which this contact has generated a + /// contact force event. + pub first_tick: bool, } impl ContactForceEvent { @@ -170,6 +174,12 @@ impl ContactForceEvent { } result.total_force += m.data.normal * total_manifold_impulse; + + for sc in m.data.solver_contacts.iter() { + if sc.is_new { + result.first_tick = true; + } + } } let inv_dt = crate::utils::inv(dt); From 638783c30b45e6d859623243b2ce2407a05d8e6c Mon Sep 17 00:00:00 2001 From: brendan c Date: Fri, 28 Nov 2025 16:20:33 -0800 Subject: [PATCH 2/2] update for rapier 31.0 --- src/geometry/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index efe328d06..15c5f17df 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -204,7 +204,7 @@ impl ContactForceEvent { result.total_force += m.data.normal * total_manifold_impulse; for sc in m.data.solver_contacts.iter() { - if sc.is_new { + if sc.is_new == 1.0 { result.first_tick = true; } }