Add hood cam, tweak tyre params, split split angle and split ratio params
This commit is contained in:
parent
f143c9b591
commit
91cd60b155
@ -57,6 +57,7 @@ Runtime_World :: struct {
|
||||
camera_speed: f32,
|
||||
camera: rl.Camera3D,
|
||||
orbit_camera: Orbit_Camera,
|
||||
camera_mode: Camera_Mode,
|
||||
dt: f32,
|
||||
rewind_simulation: bool,
|
||||
step_simulation: bool,
|
||||
@ -89,6 +90,11 @@ Game_Memory :: struct {
|
||||
free_cam: bool,
|
||||
}
|
||||
|
||||
Camera_Mode :: enum {
|
||||
Orbit,
|
||||
Hood,
|
||||
}
|
||||
|
||||
Track_Edit_State :: enum {
|
||||
// Point selection
|
||||
Select,
|
||||
@ -320,8 +326,8 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
||||
wheel_extent_x := f32(1.7)
|
||||
wheel_y := f32(-0.5)
|
||||
rest := f32(1)
|
||||
natural_frequency := f32(0.4)
|
||||
damping := f32(0.08)
|
||||
natural_frequency := f32(0.35)
|
||||
damping := f32(0.07)
|
||||
radius := f32(0.6)
|
||||
wheel_front_z := f32(3.05)
|
||||
wheel_back_z := f32(-2.45)
|
||||
@ -395,7 +401,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
||||
|
||||
DRIVE_IMPULSE :: 3000
|
||||
BRAKE_IMPULSE :: 10
|
||||
TURN_ANGLE :: -f32(30) * math.RAD_PER_DEG
|
||||
TURN_ANGLE :: -f32(50) * math.RAD_PER_DEG
|
||||
// 68% front, 32% rear
|
||||
BRAKE_BIAS :: f32(0.68)
|
||||
|
||||
@ -430,6 +436,9 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
||||
turn_vel_correction := clamp(30.0 / linalg.length(car_body.v), 0, 1)
|
||||
|
||||
turn_input := rl.GetGamepadAxisMovement(0, .LEFT_X)
|
||||
if abs(turn_input) < GAMEPAD_DEADZONE {
|
||||
turn_input = 0
|
||||
}
|
||||
if rl.IsKeyDown(.A) && !g_mem.free_cam {
|
||||
turn_input = -1
|
||||
}
|
||||
@ -531,6 +540,16 @@ update :: proc() {
|
||||
g_mem.es.world.player_pos = g_mem.runtime_world.camera.position
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(.F2) && !g_mem.free_cam {
|
||||
cam_mode := &get_runtime_world().camera_mode
|
||||
switch cam_mode^ {
|
||||
case .Orbit:
|
||||
cam_mode^ = .Hood
|
||||
case .Hood:
|
||||
cam_mode^ = .Orbit
|
||||
}
|
||||
}
|
||||
|
||||
dt := rl.GetFrameTime()
|
||||
|
||||
// Debug BVH traversal
|
||||
@ -572,8 +591,26 @@ update :: proc() {
|
||||
if g_mem.free_cam {
|
||||
update_free_look_camera(get_editor_state())
|
||||
} else {
|
||||
orbit_camera_update(&get_runtime_world().orbit_camera)
|
||||
get_runtime_world().camera = orbit_camera_to_rl(get_runtime_world().orbit_camera)
|
||||
switch get_runtime_world().camera_mode {
|
||||
case .Orbit:
|
||||
orbit_camera_update(&get_runtime_world().orbit_camera)
|
||||
get_runtime_world().camera = orbit_camera_to_rl(get_runtime_world().orbit_camera)
|
||||
case .Hood:
|
||||
car := physics.get_body(
|
||||
physics.get_sim_state(&get_runtime_world().world.physics_scene),
|
||||
get_runtime_world().car_handle,
|
||||
)
|
||||
|
||||
cam: rl.Camera3D
|
||||
cam.position = physics.body_local_to_world(car, physics.Vec3{0, 0.9, 2})
|
||||
cam.target =
|
||||
cam.position + physics.body_local_to_world_vec(car, physics.Vec3{0, 0, 1})
|
||||
cam.up = physics.body_local_to_world_vec(car, physics.Vec3{0, 1, 0})
|
||||
cam.fovy = 60
|
||||
cam.projection = .PERSPECTIVE
|
||||
|
||||
get_runtime_world().camera = cam
|
||||
}
|
||||
}
|
||||
update_runtime_world(get_runtime_world(), dt)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import "core:math"
|
||||
|
||||
Pacejka96_Params :: [11]f32
|
||||
|
||||
DEFAULT_PACEJKA96_PARAMS :: Pacejka96_Params{1.65, -180, 1900, 0, 229, 0.0, 0, 0, 0, 0, 0}
|
||||
DEFAULT_PACEJKA96_PARAMS :: Pacejka96_Params{1.45, -150, 1500, 0, 400, -0.4, 0, 0, 0, 0, 0}
|
||||
|
||||
// X is slip ratio percentage [-100, 100] or slip angle in degrees, where positive angle is turning left
|
||||
// Output is the friction coefficient
|
||||
|
@ -563,8 +563,36 @@ pgs_solve_suspension :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f
|
||||
slip_angle :=
|
||||
lg.angle_between(forward, body_vel_at_contact_patch) * math.DEG_PER_RAD
|
||||
|
||||
OPTIMAL_SLIP_RATIO :: f32(0.075)
|
||||
OPTIMAL_SLIP_ANGLE :: f32(8)
|
||||
SLIP_RATIO_PARAMS :: Pacejka96_Params {
|
||||
1.7,
|
||||
-150,
|
||||
1500,
|
||||
0,
|
||||
700,
|
||||
-0.8,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
}
|
||||
|
||||
SLIP_ANGLE_PARAMS :: Pacejka96_Params {
|
||||
1.6,
|
||||
-150,
|
||||
1500,
|
||||
0,
|
||||
229,
|
||||
-0.4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
}
|
||||
|
||||
OPTIMAL_SLIP_RATIO :: f32(0.0078)
|
||||
OPTIMAL_SLIP_ANGLE :: f32(5.5)
|
||||
MAX_SLIP_LEN :: f32(2.0)
|
||||
|
||||
slip_vec := Vec2 {
|
||||
@ -581,7 +609,7 @@ pgs_solve_suspension :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f
|
||||
long_friction :=
|
||||
abs(
|
||||
pacejka_96(
|
||||
DEFAULT_PACEJKA96_PARAMS,
|
||||
SLIP_RATIO_PARAMS,
|
||||
slip_ratio * 100,
|
||||
max(abs(v.spring_impulse), 0.001) * inv_dt * 0.001,
|
||||
),
|
||||
@ -590,7 +618,7 @@ pgs_solve_suspension :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f
|
||||
lat_friction :=
|
||||
abs(
|
||||
pacejka_96(
|
||||
DEFAULT_PACEJKA96_PARAMS,
|
||||
SLIP_ANGLE_PARAMS,
|
||||
slip_angle,
|
||||
max(abs(v.spring_impulse), 0.001) * inv_dt * 0.001,
|
||||
),
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user