Increase lowest rpm to fix no torque when starting to go uphill
This commit is contained in:
parent
ef8245d712
commit
b0fb81d88c
@ -266,7 +266,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
||||
physics.Body_Config {
|
||||
initial_pos = {0, 0, 0},
|
||||
initial_rot = linalg.quaternion_from_euler_angle_x_f32(-10 * math.RAD_PER_DEG),
|
||||
shape = physics.Shape_Box{size = {5, 1, 10}},
|
||||
shape = physics.Shape_Box{size = {5, 1, 100}},
|
||||
},
|
||||
)
|
||||
|
||||
@ -294,7 +294,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
||||
},
|
||||
)
|
||||
|
||||
if true {
|
||||
if false {
|
||||
for x in 0 ..< 10 {
|
||||
for y in 0 ..< 10 {
|
||||
physics.immediate_body(
|
||||
@ -412,7 +412,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
||||
#hash("engine", "fnv32a"),
|
||||
physics.Engine_Config {
|
||||
rpm_torque_curve = assets.get_curve_2d(&g_mem.assetman, "assets/ae86_rpm_torque.csv").points,
|
||||
lowest_rpm = 1000,
|
||||
lowest_rpm = 1100,
|
||||
inertia = 0.264,
|
||||
internal_friction = 0.01,
|
||||
gear_ratios = []f32{3.48, 3.587, 2.022, 1.384, 1, 0.861},
|
||||
|
@ -655,6 +655,7 @@ pgs_solve_engines :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f32,
|
||||
delta_omega := avg_wheel_vel * ratio - (-engine.w)
|
||||
|
||||
incremental_impulse := -inv_w * delta_omega
|
||||
engine.axle.engine_impulse += incremental_impulse
|
||||
|
||||
engine.w += incremental_impulse * w1
|
||||
wheel1.w += incremental_impulse * w2 * inv_ratio
|
||||
@ -682,6 +683,7 @@ pgs_solve_engines :: proc(sim_state: ^Sim_State, config: Solver_Config, dt: f32,
|
||||
delta_omega := wheel2.w - wheel1.w
|
||||
|
||||
incremental_impulse := -inv_w * delta_omega
|
||||
engine.axle.diff_impulse += incremental_impulse
|
||||
|
||||
wheel1.w += -incremental_impulse * wheel1.inv_inertia
|
||||
wheel2.w += incremental_impulse * wheel2.inv_inertia
|
||||
@ -955,18 +957,36 @@ pgs_substep :: proc(
|
||||
|
||||
e.w += e.friction_impulse / e.inertia
|
||||
|
||||
if true {
|
||||
// Warm start engine torque
|
||||
if false {
|
||||
drive_wheel1 := &e.axle.wheels[0]
|
||||
wheel1 := get_suspension_constraint(sim_state, drive_wheel1.wheel)
|
||||
|
||||
drive_wheel2 := &e.axle.wheels[1]
|
||||
wheel2 := get_suspension_constraint(sim_state, drive_wheel2.wheel)
|
||||
|
||||
gear_ratio := lookup_gear_ratio(gear_ratios, e.gear)
|
||||
|
||||
if e.gear != 0 {
|
||||
for i in 0 ..< e.axle.wheel_count {
|
||||
drive_wheel := &e.axle.wheels[i]
|
||||
wheel := get_suspension_constraint(sim_state, drive_wheel.wheel)
|
||||
ratio := gear_ratio * e.axle.final_drive_ratio
|
||||
inv_ratio := f32(1.0 / (ratio))
|
||||
|
||||
ratio :=
|
||||
lookup_gear_ratio(gear_ratios, e.gear) * e.axle.final_drive_ratio
|
||||
inv_ratio := f32(1.0 / ratio)
|
||||
w1 := f32(1.0 / (e.inertia * ratio * ratio))
|
||||
w2 := wheel1.inv_inertia
|
||||
w3 := wheel2.inv_inertia
|
||||
|
||||
wheel.w += drive_wheel.impulse * wheel.inv_inertia * inv_ratio
|
||||
e.w += (drive_wheel.impulse / (e.inertia * ratio * ratio))
|
||||
e.w += e.axle.engine_impulse * w1
|
||||
wheel1.w += e.axle.engine_impulse * w2 * inv_ratio
|
||||
wheel2.w += e.axle.engine_impulse * w3 * inv_ratio
|
||||
}
|
||||
|
||||
// Warmp start diff impulse
|
||||
if false {
|
||||
switch e.axle.diff_type {
|
||||
case .Open:
|
||||
case .Fixed:
|
||||
wheel1.w += -e.axle.diff_impulse * wheel1.inv_inertia
|
||||
wheel2.w += e.axle.diff_impulse * wheel2.inv_inertia
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user