Fix reported contact impulse in the contact force event
Address https://github.com/dimforge/rapier.js/issues/261
This commit is contained in:
committed by
Sébastien Crozet
parent
59dc9bfe00
commit
09af4313fa
@@ -138,7 +138,7 @@ impl TwoBodyConstraintBuilderSimd {
|
||||
rhs: na::zero(),
|
||||
rhs_wo_bias: na::zero(),
|
||||
impulse: SimdReal::splat(0.0),
|
||||
total_impulse: SimdReal::splat(0.0),
|
||||
impulse_accumulator: SimdReal::splat(0.0),
|
||||
r: projected_mass,
|
||||
};
|
||||
}
|
||||
@@ -241,19 +241,18 @@ impl TwoBodyConstraintBuilderSimd {
|
||||
.simd_clamp(-max_penetration_correction, SimdReal::zero())
|
||||
* erp_inv_dt;
|
||||
let new_rhs = rhs_wo_bias + rhs_bias;
|
||||
let total_impulse = element.normal_part.total_impulse + element.normal_part.impulse;
|
||||
is_fast_contact =
|
||||
is_fast_contact | (-new_rhs * dt).simd_gt(ccd_thickness * SimdReal::splat(0.5));
|
||||
|
||||
element.normal_part.rhs_wo_bias = rhs_wo_bias;
|
||||
element.normal_part.rhs = new_rhs;
|
||||
element.normal_part.total_impulse = total_impulse;
|
||||
element.normal_part.impulse_accumulator += element.normal_part.impulse;
|
||||
element.normal_part.impulse = na::zero();
|
||||
}
|
||||
|
||||
// tangent parts.
|
||||
{
|
||||
element.tangent_part.total_impulse += element.tangent_part.impulse;
|
||||
element.tangent_part.impulse_accumulator += element.tangent_part.impulse;
|
||||
element.tangent_part.impulse = na::zero();
|
||||
|
||||
for j in 0..DIM - 1 {
|
||||
@@ -328,11 +327,12 @@ impl TwoBodyConstraintSimd {
|
||||
|
||||
pub fn writeback_impulses(&self, manifolds_all: &mut [&mut ContactManifold]) {
|
||||
for k in 0..self.num_contacts as usize {
|
||||
let impulses: [_; SIMD_WIDTH] = self.elements[k].normal_part.impulse.into();
|
||||
let impulses: [_; SIMD_WIDTH] = self.elements[k].normal_part.total_impulse().into();
|
||||
#[cfg(feature = "dim2")]
|
||||
let tangent_impulses: [_; SIMD_WIDTH] = self.elements[k].tangent_part.impulse[0].into();
|
||||
let tangent_impulses: [_; SIMD_WIDTH] =
|
||||
self.elements[k].tangent_part.total_impulse()[0].into();
|
||||
#[cfg(feature = "dim3")]
|
||||
let tangent_impulses = self.elements[k].tangent_part.impulse;
|
||||
let tangent_impulses = self.elements[k].tangent_part.total_impulse();
|
||||
|
||||
for ii in 0..SIMD_WIDTH {
|
||||
let manifold = &mut manifolds_all[self.manifold_id[ii]];
|
||||
|
||||
Reference in New Issue
Block a user