diff --git a/game/game.odin b/game/game.odin index 9a91788..60600f8 100644 --- a/game/game.odin +++ b/game/game.odin @@ -73,9 +73,9 @@ Car :: struct { } SOLVER_CONFIG :: physics.Solver_Config { - timestep = 1.0 / 120, + timestep = 1.0 / 60, gravity = rl.Vector3{0, -9.8, 0}, - substreps_minus_one = 2 - 1, + substreps_minus_one = 4 - 1, } Game_Memory :: struct { diff --git a/game/physics/simulation.odin b/game/physics/simulation.odin index fb7e7d1..4fe38ba 100644 --- a/game/physics/simulation.odin +++ b/game/physics/simulation.odin @@ -173,11 +173,11 @@ simulate :: proc( // bvh.debug_draw_bvh_bounds(&sim_state_bvh, body_aabbs, 0) + num_steps := 0 switch step_mode { case .Accumulated_Time: state.accumulated_time += dt - num_steps := 0 for state.accumulated_time >= config.timestep { num_steps += 1 state.accumulated_time -= config.timestep @@ -188,9 +188,10 @@ simulate :: proc( } case .Single: simulate_step(get_next_sim_state(scene), config, potential_pairs) + num_steps += 1 } - if commit { + if num_steps > 0 && commit { flip_sim_state(scene) }