diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-11-03 11:21:06 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-11-03 11:22:30 +0100 |
| commit | 502be0245c10eeaf5e30ed25653c5a76287e72be (patch) | |
| tree | 4e1bad46a42dc90b782410d9396ca731d94a596c /src/dynamics/solver/velocity_ground_constraint.rs | |
| parent | a38fdc101dc74473c45a8b4f5d770f2bc43f30c2 (diff) | |
| download | rapier-502be0245c10eeaf5e30ed25653c5a76287e72be.tar.gz rapier-502be0245c10eeaf5e30ed25653c5a76287e72be.tar.bz2 rapier-502be0245c10eeaf5e30ed25653c5a76287e72be.zip | |
Add restitution.
Diffstat (limited to 'src/dynamics/solver/velocity_ground_constraint.rs')
| -rw-r--r-- | src/dynamics/solver/velocity_ground_constraint.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/dynamics/solver/velocity_ground_constraint.rs b/src/dynamics/solver/velocity_ground_constraint.rs index d9229ff..d8ef8be 100644 --- a/src/dynamics/solver/velocity_ground_constraint.rs +++ b/src/dynamics/solver/velocity_ground_constraint.rs @@ -169,9 +169,15 @@ impl VelocityGroundConstraint { .transform_vector(dp2.gcross(-force_dir1)); let r = 1.0 / (rb2.mass_properties.inv_mass + gcross2.gdot(gcross2)); - let rhs = -vel2.dot(&force_dir1) - + vel1.dot(&force_dir1) - + manifold_point.dist.max(0.0) * params.inv_dt(); + + let mut rhs = (vel1 - vel2).dot(&force_dir1); + + if rhs <= -params.restitution_velocity_threshold { + rhs += manifold.restitution * rhs + } + + rhs += manifold_point.dist.max(0.0) * params.inv_dt(); + let impulse = manifold_points[k].impulse * warmstart_coeff; constraint.elements[k].normal_part = VelocityGroundConstraintElementPart { |
