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 {
|
physics.Body_Config {
|
||||||
initial_pos = {0, 0, 0},
|
initial_pos = {0, 0, 0},
|
||||||
initial_rot = linalg.quaternion_from_euler_angle_x_f32(-10 * math.RAD_PER_DEG),
|
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 x in 0 ..< 10 {
|
||||||
for y in 0 ..< 10 {
|
for y in 0 ..< 10 {
|
||||||
physics.immediate_body(
|
physics.immediate_body(
|
||||||
@ -412,7 +412,7 @@ update_runtime_world :: proc(runtime_world: ^Runtime_World, dt: f32) {
|
|||||||
#hash("engine", "fnv32a"),
|
#hash("engine", "fnv32a"),
|
||||||
physics.Engine_Config {
|
physics.Engine_Config {
|
||||||
rpm_torque_curve = assets.get_curve_2d(&g_mem.assetman, "assets/ae86_rpm_torque.csv").points,
|
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,
|
inertia = 0.264,
|
||||||
internal_friction = 0.01,
|
internal_friction = 0.01,
|
||||||
gear_ratios = []f32{3.48, 3.587, 2.022, 1.384, 1, 0.861},
|
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)
|
delta_omega := avg_wheel_vel * ratio - (-engine.w)
|
||||||
|
|
||||||
incremental_impulse := -inv_w * delta_omega
|
incremental_impulse := -inv_w * delta_omega
|
||||||
|
engine.axle.engine_impulse += incremental_impulse
|
||||||
|
|
||||||
engine.w += incremental_impulse * w1
|
engine.w += incremental_impulse * w1
|
||||||
wheel1.w += incremental_impulse * w2 * inv_ratio
|
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
|
delta_omega := wheel2.w - wheel1.w
|
||||||
|
|
||||||
incremental_impulse := -inv_w * delta_omega
|
incremental_impulse := -inv_w * delta_omega
|
||||||
|
engine.axle.diff_impulse += incremental_impulse
|
||||||
|
|
||||||
wheel1.w += -incremental_impulse * wheel1.inv_inertia
|
wheel1.w += -incremental_impulse * wheel1.inv_inertia
|
||||||
wheel2.w += incremental_impulse * wheel2.inv_inertia
|
wheel2.w += incremental_impulse * wheel2.inv_inertia
|
||||||
@ -955,18 +957,36 @@ pgs_substep :: proc(
|
|||||||
|
|
||||||
e.w += e.friction_impulse / e.inertia
|
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 {
|
if e.gear != 0 {
|
||||||
for i in 0 ..< e.axle.wheel_count {
|
ratio := gear_ratio * e.axle.final_drive_ratio
|
||||||
drive_wheel := &e.axle.wheels[i]
|
inv_ratio := f32(1.0 / (ratio))
|
||||||
wheel := get_suspension_constraint(sim_state, drive_wheel.wheel)
|
|
||||||
|
|
||||||
ratio :=
|
w1 := f32(1.0 / (e.inertia * ratio * ratio))
|
||||||
lookup_gear_ratio(gear_ratios, e.gear) * e.axle.final_drive_ratio
|
w2 := wheel1.inv_inertia
|
||||||
inv_ratio := f32(1.0 / ratio)
|
w3 := wheel2.inv_inertia
|
||||||
|
|
||||||
wheel.w += drive_wheel.impulse * wheel.inv_inertia * inv_ratio
|
e.w += e.axle.engine_impulse * w1
|
||||||
e.w += (drive_wheel.impulse / (e.inertia * ratio * ratio))
|
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