Migrate 32 engine definitions into validated startup-loaded TOML files and separate configuration and snapshots from scenario assembly. Add camera-based stereo propagation from shared pipe geometry, preserve exhaust character, tune carburetor mixtures and idle, use ignition cuts for carb engines, and support returning to the scenario menu. Validation: full Windows build and all 14 CTest checks passed.
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
namespace fluidsim::port {
|
|
|
|
// Longitudinal vehicle model and the friction clutch coupling it to the crank.
|
|
struct VehicleConfig {
|
|
std::vector<float> gear_ratios{4.1f, 2.7f, 2.0f, 1.55f, 1.25f, 0.98f};
|
|
float final_drive_ratio{2.7f}, primary_reduction{1.8f};
|
|
float clutch_capacity{80.0f}, clutch_engagement_rate{8.0f};
|
|
float mass{160.0f}, wheel_radius{0.32f}, rotational_inertia{1.2f};
|
|
float rolling_resistance{0.015f}, drag_coefficient{0.7f}, frontal_area{0.65f};
|
|
float air_density{1.225f}, gravity{9.80665f};
|
|
};
|
|
|
|
class Vehicle : public VehicleConfig {
|
|
public:
|
|
int current_gear{};
|
|
float clutch_input{1.0f}, speed{}, engagement{};
|
|
|
|
float total_gear_ratio() const;
|
|
float kinetic_energy() const;
|
|
float update(float engine_omega, float engine_inertia, float dt);
|
|
void shift_up();
|
|
void shift_down();
|
|
void set_neutral();
|
|
void set_first_gear();
|
|
|
|
private:
|
|
float shift_cut_timer_{};
|
|
void apply_road_resistance(float dt);
|
|
};
|
|
|
|
} // namespace fluidsim::port
|