init commit

This commit is contained in:
Avery Haas
2026-08-28 22:38:58 -04:00
commit 120e4f505f
324 changed files with 133476 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
#include <chrono>
#include "imgui.h"
#include "engine/simulation.h"
#include "gui/gui.h"
int main() {
Gui gui;
if (!gui.init()) return 1;
Simulation sim;
const double SIM_DT = 1.0 / 360.0;
double accumulator = 0.0;
auto last_time = std::chrono::steady_clock::now();
while (gui.begin_frame()) {
// 'r' resets the engine (rpm -> 0). false = don't auto-repeat while held.
if (ImGui::IsKeyPressed(ImGuiKey_R, false)) {
sim.engine().reset();
}
auto now = std::chrono::steady_clock::now();
double frame_time = std::chrono::duration<double>(now - last_time).count();
last_time = now;
if (frame_time > 0.25) frame_time = 0.25; // clamp huge stalls (e.g. breakpoint)
accumulator += frame_time;
while (accumulator >= SIM_DT) {
sim.step(SIM_DT);
accumulator -= SIM_DT;
}
// Build this frame's display data. Only rpm is real right now;
// the rest are placeholders until those models exist.
EngineStats stats;
stats.rpm = sim.engine().rpm();
stats.fuel_consumption_lph = 0.0; // TODO: derive from fuel model
stats.crank_power_kw = 0.0; // TODO: torque_nm * rpm -> kW
stats.output_heat_j = 0.0; // TODO: energy balance / exhaust heat model
stats.extra_stats.push_back({"Oil Temp", 0.0, "C"});
stats.extra_stats.push_back({"Coolant Temp", 0.0, "C"});
gui.render(stats);
gui.end_frame();
}
gui.shutdown();
return 0;
}