Change iteration counts, fix extra snapshots when no steps were taken

This commit is contained in:
sergeypdev 2025-03-02 21:30:37 +04:00
parent 860f9f59b6
commit c3ac6c2db1
2 changed files with 5 additions and 4 deletions

View File

@ -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 {

View File

@ -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)
}