Fix mem leak, change number of stacks

This commit is contained in:
sergeypdev 2025-03-16 00:17:00 +04:00
parent 60522ea836
commit fb1643e6e6
2 changed files with 12 additions and 9 deletions

View File

@ -277,8 +277,8 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
) )
if true { if true {
for x in 0 ..< 5 { for x in 0 ..< 10 {
for y in 0 ..< 20 { for y in 0 ..< 10 {
physics.immediate_body( physics.immediate_body(
&world.physics_scene, &world.physics_scene,
&runtime_world.solver_state, &runtime_world.solver_state,
@ -320,8 +320,8 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
wheel_extent_x := f32(1.7) wheel_extent_x := f32(1.7)
wheel_y := f32(-0.5) wheel_y := f32(-0.5)
rest := f32(1) rest := f32(1)
natural_frequency := f32(0.2) natural_frequency := f32(0.3)
damping := f32(0.12) damping := f32(0.08)
radius := f32(0.6) radius := f32(0.6)
wheel_front_z := f32(3.05) wheel_front_z := f32(3.05)
wheel_back_z := f32(-2.45) wheel_back_z := f32(-2.45)
@ -388,7 +388,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
DRIVE_IMPULSE :: 10000 DRIVE_IMPULSE :: 10000
BRAKE_IMPULSE :: 10000 BRAKE_IMPULSE :: 10000
TURN_ANGLE :: -f32(30) * math.RAD_PER_DEG TURN_ANGLE :: -f32(20) * math.RAD_PER_DEG
for wheel_handle in drive_wheels { for wheel_handle in drive_wheels {
wheel := physics.get_suspension_constraint(sim_state, wheel_handle) wheel := physics.get_suspension_constraint(sim_state, wheel_handle)
@ -405,16 +405,19 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
} }
} }
car_body := physics.get_body(sim_state, runtime_world.car_handle)
turn_vel_correction := clamp(30.0 / linalg.length(car_body.v), 0, 1)
for wheel_handle in turn_wheels { for wheel_handle in turn_wheels {
wheel := physics.get_suspension_constraint(sim_state, wheel_handle) wheel := physics.get_suspension_constraint(sim_state, wheel_handle)
wheel.turn_angle = 0 wheel.turn_angle = 0
if rl.IsKeyDown(.A) && !g_mem.free_cam { if rl.IsKeyDown(.A) && !g_mem.free_cam {
wheel.turn_angle += -TURN_ANGLE wheel.turn_angle += -TURN_ANGLE * turn_vel_correction
} }
if rl.IsKeyDown(.D) && !g_mem.free_cam { if rl.IsKeyDown(.D) && !g_mem.free_cam {
wheel.turn_angle += TURN_ANGLE wheel.turn_angle += TURN_ANGLE * turn_vel_correction
} }
} }

View File

@ -357,7 +357,7 @@ pgs_solve_contacts :: proc(
impulse_coef = 0 impulse_coef = 0
} }
random_order := make([]i32, len(sim_state.contact_container.contacts)) random_order := make([]i32, len(sim_state.contact_container.contacts), context.temp_allocator)
{ {
for i in 0 ..< len(random_order) { for i in 0 ..< len(random_order) {
random_order[i] = i32(i) random_order[i] = i32(i)
@ -522,7 +522,7 @@ pgs_solve_suspension :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f
lateral_vel := lg.dot(right, vel_contact) lateral_vel := lg.dot(right, vel_contact)
friction := f32(0.8) friction := f32(1)
friction_clamp := -v.spring_impulse * friction friction_clamp := -v.spring_impulse * friction
incremental_impulse := -inv_w * lateral_vel incremental_impulse := -inv_w * lateral_vel