diff options
| author | Emil Ernerfeldt <emil.ernerfeldt@gmail.com> | 2021-02-18 17:58:17 +0100 |
|---|---|---|
| committer | Emil Ernerfeldt <emil.ernerfeldt@gmail.com> | 2021-02-18 17:58:17 +0100 |
| commit | 5e7eedc3fdf74b49ecd999b003570bf352ee3f11 (patch) | |
| tree | 7dd9e71cc6b4e44028989779e07c108facb20461 /src/dynamics/solver/velocity_constraint.rs | |
| parent | 287cd4629524d180651a3953ed95a18e1be7f49b (diff) | |
| download | rapier-5e7eedc3fdf74b49ecd999b003570bf352ee3f11.tar.gz rapier-5e7eedc3fdf74b49ecd999b003570bf352ee3f11.tar.bz2 rapier-5e7eedc3fdf74b49ecd999b003570bf352ee3f11.zip | |
Always apply the predictive contact term, even for bouncing contacts
Diffstat (limited to 'src/dynamics/solver/velocity_constraint.rs')
| -rw-r--r-- | src/dynamics/solver/velocity_constraint.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/dynamics/solver/velocity_constraint.rs b/src/dynamics/solver/velocity_constraint.rs index dc7020f..2cac93d 100644 --- a/src/dynamics/solver/velocity_constraint.rs +++ b/src/dynamics/solver/velocity_constraint.rs @@ -239,11 +239,10 @@ impl VelocityConstraint { + gcross1.gdot(gcross1) + gcross2.gdot(gcross2)); - let rhs = if manifold_point.is_bouncy() { - (1.0 + manifold_point.restitution) * (vel1 - vel2).dot(&force_dir1) - } else { - (vel1 - vel2).dot(&force_dir1) + manifold_point.dist.max(0.0) * inv_dt - }; + let is_bouncy = manifold_point.is_bouncy() as u32 as Real; + let rhs = (1.0 + is_bouncy * manifold_point.restitution) + * (vel1 - vel2).dot(&force_dir1) + + manifold_point.dist.max(0.0) * inv_dt; let impulse = manifold_point.data.impulse * warmstart_coeff; |
