diff --git a/game/physics/simulation.odin b/game/physics/simulation.odin index 6fff0bb..59bdbf6 100644 --- a/game/physics/simulation.odin +++ b/game/physics/simulation.odin @@ -431,14 +431,21 @@ pgs_solve_contacts :: proc( } { - FRICTION :: 0.6 - friction_clamp := contact.total_normal_impulse[point_idx] * FRICTION + DYNAMIC_FRICTION :: 0.6 + STATIC_FRICTION :: 0.8 + STATIC_FRICTION_VELOCITY_THRESHOLD :: 0.01 delta_v_tang := Vec2 { lg.dot(delta_v, manifold.tangent), lg.dot(delta_v, manifold.bitangent), } + use_static_friction := + lg.dot(delta_v_tang, delta_v_tang) < + STATIC_FRICTION_VELOCITY_THRESHOLD * STATIC_FRICTION_VELOCITY_THRESHOLD + friction: f32 = use_static_friction ? STATIC_FRICTION : DYNAMIC_FRICTION + friction_clamp := contact.total_normal_impulse[point_idx] * friction + incremental_impulse := -inv_w * delta_v_tang new_total_impulse: Vec2 = lg.clamp(