New contacts are bouncy, old are resting

If a contact is new (previous impluse = 0), then we treat it as bouncy (respecting restitution).
If the contact is old we treat it as resting.

Exceptions for restitutions <=0 and >= 1.
This commit is contained in:
Emil Ernerfeldt
2021-02-15 21:18:26 +01:00
parent 9a15838ad5
commit f9e3d382d2
5 changed files with 49 additions and 35 deletions

View File

@@ -239,13 +239,11 @@ impl VelocityConstraint {
+ gcross1.gdot(gcross1)
+ gcross2.gdot(gcross2));
let mut rhs = (vel1 - vel2).dot(&force_dir1);
if rhs <= -params.restitution_velocity_threshold {
rhs += manifold_point.restitution * rhs
}
rhs += manifold_point.dist.max(0.0) * inv_dt;
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 impulse = manifold_point.data.impulse * warmstart_coeff;