Add pitstop audio cue, original explosions/smoke, authentic HUD, and Modern lighting/shadows

This commit is contained in:
Luxferre committed 2026-12-01 09:19:20 +02:00
1 parent 3a377b0534
commit 197bfbc973
21 files changed
+1927 -246

No files matched your search

+24
View File
@@ -275,6 +275,30 @@ int main() {
eng.stop_music();
}
// 7. Continuous pitstop REFUEL.WAV loop (charging, high-pitched standby, clean fade-out)
{
eng.stop_music();
eng.set_engine_state(false, 0.0f, false, 0.0f);
std::vector<float> pit_buf(12000 * 2, 0.0f);
eng.set_pitstop_state(true, true, 0.25f);
eng.mix_offline(pit_buf.data(), 12000);
BufferStats chg_st = measure_buffer(pit_buf, "Pitstop charging");
CHECK(chg_st.finite_ok && chg_st.rms > 0.01f);
eng.set_pitstop_state(true, false, 1.0f);
eng.mix_offline(pit_buf.data(), 12000);
BufferStats stdby_st = measure_buffer(pit_buf, "Pitstop standby");
CHECK(stdby_st.finite_ok && stdby_st.rms > 0.004f && stdby_st.rms < chg_st.rms);
eng.set_pitstop_state(false, false, 1.0f);
std::vector<float> fade_buf(4800 * 2, 0.0f);
eng.mix_offline(fade_buf.data(), 4800);
eng.mix_offline(pit_buf.data(), 12000);
BufferStats off_st = measure_buffer(pit_buf, "Pitstop off");
CHECK(off_st.finite_ok && off_st.rms < 0.001f);
}
std::cout << "[PASS] AudioEngine, OPL3 FM, SoundFont SBK, Normalization & Limiter validated\n";
return 0;
}
+175 -5
View File
@@ -671,25 +671,47 @@ int main() {
p1.vel = Vec3(0, 0, 0);
};
// Fuel bay (49.0, 79.0): recharges only fuel + emits Refuel sound
// Fuel bay (49.0, 79.0): recharges only fuel, updates on_pit_mask/pit_fill_ratio & emits PitComplete on 100%
p1.fuel = 20.0f;
p1.shield = 20.0f;
p1.ammo = 20.0f;
p1.refuel_sound_cd = 0.0f;
place_p1(49.0f, 79.0f);
psim.clear_events();
bool saw_refuel_sfx = false;
float first_fill = 1.0f;
float mid_fill = 0.0f;
bool saw_pit_complete = false;
for (int t = 0; t < 60; ++t) {
psim.step(CraftInput{}, CraftInput{}, dt);
if (t == 0) {
CHECK(p1.on_pit_mask == 2u);
CHECK(p1.active_recharge_mask == 2u);
first_fill = p1.pit_fill_ratio;
}
if (t == 59) {
mid_fill = p1.pit_fill_ratio;
}
for (const auto& ev : psim.events()) {
if (ev.sound == sim::SimSoundCue::Refuel) saw_refuel_sfx = true;
if (ev.sound == sim::SimSoundCue::PitComplete) saw_pit_complete = true;
}
psim.clear_events();
}
CHECK(p1.fuel > 70.0f);
CHECK(p1.shield == 20.0f);
CHECK(p1.ammo == 20.0f);
CHECK(saw_refuel_sfx);
CHECK(mid_fill > first_fill && mid_fill < 1.0f);
// Continue on Fuel bay until full -> PitComplete emitted & active_recharge_mask clears while on_pit_mask stays 2
for (int t = 0; t < 70; ++t) {
psim.step(CraftInput{}, CraftInput{}, dt);
for (const auto& ev : psim.events()) {
if (ev.sound == sim::SimSoundCue::PitComplete) saw_pit_complete = true;
}
psim.clear_events();
}
CHECK(p1.fuel >= p1.max_fuel - 0.5f);
CHECK(p1.on_pit_mask == 2u);
CHECK(p1.active_recharge_mask == 0u);
CHECK(saw_pit_complete);
// Ammo bay (49.0, 85.0): recharges only ammo
p1.fuel = 20.0f;
@@ -760,5 +782,153 @@ int main() {
}
std::cout << "[PASS] Authentic pitstop Fuel/Shield/Ammo chargers verified across all 6 tracks\n";
// 9. Original Explosions, Volumetric Smoke Trails, Wreck Plumes & Steam Vents
{
// 9a. Unguided missile smoke contrail + exhaust glow
{
sim::RaceSetup ms;
ms.mode = sim::GameMode::SingleRace;
ms.track_number = 1;
ms.num_ai = 0;
ms.fuel_enabled = false;
sim::RaceSim msim;
CHECK(msim.start_race(lvl1, ms));
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
auto& p1 = msim.crafts_mut()[0];
p1.lock_progress = 0.0f;
p1.lock_target_id = -1;
CraftInput fire;
fire.fire_missile = true;
msim.step(fire, CraftInput{}, dt);
for (int t = 0; t < 10; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
bool saw_smoke = false, saw_glow = false;
for (const auto& pb : msim.particles()) {
if (pb.kind == sim::ParticleKind::Smoke) saw_smoke = true;
if (pb.kind == sim::ParticleKind::AdditiveGlow) saw_glow = true;
}
CHECK(saw_smoke && saw_glow);
}
// 9b. Multi-layer explosion FX evolution (expanding smoke, falling debris) + kMaxParticles cap
{
sim::RaceSetup es;
es.mode = sim::GameMode::DeathMatch;
es.track_number = 1;
es.num_ai = 1;
es.fuel_enabled = false;
sim::RaceSim esim;
CHECK(esim.start_race(lvl1, es));
for (int t = 0; t < 200; ++t) esim.step(CraftInput{}, CraftInput{}, dt);
auto& p1 = esim.crafts_mut()[0];
auto& tgt = esim.crafts_mut()[1];
tgt.curr_pose.pos = p1.curr_pose.pos + p1.forward_dir() * 4.0f;
tgt.prev_pose = tgt.curr_pose;
tgt.shield = 1.0f;
p1.lock_progress = 1.0f;
p1.lock_target_id = tgt.id;
CraftInput fire;
fire.fire_missile = true;
for (int t = 0; t < 20 && tgt.recovery_state == sim::RecoveryState::Active; ++t) {
esim.step(fire, CraftInput{}, dt);
fire.fire_missile = false;
}
CHECK(tgt.recovery_state == sim::RecoveryState::CallingRepair);
float max_smoke0 = 0.0f;
float min_debris_vy0 = 1e9f;
bool has_fireball = false, has_smoke = false, has_debris = false;
for (const auto& pb : esim.particles()) {
if (pb.kind == sim::ParticleKind::Fireball) has_fireball = true;
if (pb.kind == sim::ParticleKind::Smoke) {
has_smoke = true;
max_smoke0 = std::max(max_smoke0, pb.size);
}
if (pb.kind == sim::ParticleKind::Debris) {
has_debris = true;
min_debris_vy0 = std::min(min_debris_vy0, pb.vel.y);
}
}
CHECK(has_fireball && has_smoke && has_debris);
for (int t = 0; t < 6; ++t) esim.step(CraftInput{}, CraftInput{}, dt);
float max_smoke1 = 0.0f;
float min_debris_vy1 = 1e9f;
for (const auto& pb : esim.particles()) {
if (pb.kind == sim::ParticleKind::Smoke) max_smoke1 = std::max(max_smoke1, pb.size);
if (pb.kind == sim::ParticleKind::Debris) min_debris_vy1 = std::min(min_debris_vy1, pb.vel.y);
}
CHECK(max_smoke1 > max_smoke0);
CHECK(min_debris_vy1 < min_debris_vy0);
// Wreck plume continues emitting Fireball & Smoke long after initial explosion fades
for (int t = 0; t < 55; ++t) esim.step(CraftInput{}, CraftInput{}, dt);
CHECK(tgt.recovery_state != sim::RecoveryState::Active);
bool wreck_fire = false, wreck_smoke = false;
for (int t = 0; t < 25; ++t) {
esim.step(CraftInput{}, CraftInput{}, dt);
for (const auto& pb : esim.particles()) {
if (pb.kind == sim::ParticleKind::Fireball) wreck_fire = true;
if (pb.kind == sim::ParticleKind::Smoke) wreck_smoke = true;
}
}
CHECK(wreck_fire && wreck_smoke);
// Rapid wall-missile spam stays within kMaxParticles
for (int t = 0; t < 35; ++t) {
p1.missile_cd = 0.0f;
p1.ammo = p1.max_ammo;
CraftInput spam;
spam.fire_missile = true;
esim.step(spam, CraftInput{}, dt);
}
CHECK(esim.particles().size() <= sim::RaceSim::kMaxParticles);
}
// 9c. Damaged craft smoke trail & Level 4 continuous steam vent
{
assets::LevelData lvl4;
CHECK(lvl4.load(vfs, 4));
sim::RaceSetup ss;
ss.mode = sim::GameMode::SingleRace;
ss.track_number = 4;
ss.num_ai = 0;
ss.fuel_enabled = false;
sim::RaceSim ssim;
CHECK(ssim.start_race(lvl4, ss));
for (int t = 0; t < 200; ++t) ssim.step(CraftInput{}, CraftInput{}, dt);
auto& p1 = ssim.crafts_mut()[0];
p1.shield = p1.max_shield * 0.15f;
for (int t = 0; t < 15; ++t) ssim.step(CraftInput{}, CraftInput{}, dt);
bool damaged_smoke = false;
for (const auto& pb : ssim.particles()) {
if (pb.kind == sim::ParticleKind::Smoke) damaged_smoke = true;
}
CHECK(damaged_smoke);
// Restore full shield, trigger Level 4 group 6 steam vents via (11.5, 77.5)
p1.shield = p1.max_shield;
for (int t = 0; t < 80; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); // let old smoke expire
p1.curr_pose.pos = Vec3(11.5f, ssim.level().sample_height_world(11.5f, 77.5f) + 0.30f, 77.5f);
p1.prev_pose = p1.curr_pose;
p1.vel = Vec3(0, 0, 0);
ssim.step(CraftInput{}, CraftInput{}, dt);
CHECK(!ssim.particles().empty());
// After 1.5s (> 1.15s initial puff lifetime), continuous steam vent still emits Smoke
for (int t = 0; t < 90; ++t) ssim.step(CraftInput{}, CraftInput{}, dt);
bool continuous_steam = false;
for (const auto& pb : ssim.particles()) {
if (pb.kind == sim::ParticleKind::Smoke) continuous_steam = true;
}
CHECK(continuous_steam);
}
}
std::cout << "[PASS] Original explosions, smoke trails, wreck plumes & steam vents validated\n";
return 0;
}
+29
View File
@@ -37,16 +37,23 @@ int main() {
CHECK(!geo.column_indices.empty());
CHECK(geo.column_indices.size() % 6 == 0);
bool has_open_ao = false;
bool has_crevice_ao = false;
for (const auto& v : geo.terrain_verts) {
CHECK(std::isfinite(v.pos.x) && std::isfinite(v.pos.y) && std::isfinite(v.pos.z));
CHECK(v.tile >= 0.0f && v.tile < 256.0f);
CHECK(v.light >= 0.25f && v.light <= 1.5f);
CHECK(std::isfinite(v.ao) && v.ao >= 0.65f && v.ao <= 1.01f);
CHECK(v.u >= -1e-4f && v.u <= 1.0001f);
CHECK(v.v >= -1e-4f && v.v <= 1.0001f);
if (v.ao > 0.99f) has_open_ao = true;
if (v.ao < 0.95f) has_crevice_ao = true;
}
CHECK(has_open_ao && has_crevice_ao);
for (const auto& v : geo.column_verts) {
CHECK(std::isfinite(v.pos.x) && std::isfinite(v.pos.y) && std::isfinite(v.pos.z));
CHECK(v.tile >= 0.0f && v.tile < 256.0f);
CHECK(std::isfinite(v.ao) && v.ao >= 0.65f && v.ao <= 1.01f);
CHECK(v.u >= -1e-4f && v.u <= 1.0001f);
CHECK(v.v >= -1e-4f && v.v <= 1.0001f);
}
@@ -135,6 +142,28 @@ int main() {
}
}
// Verify PANEL0-1 authentic HUD sprites referenced in GameApp::render_hud_viewport
{
assets::SpriteBank panel_bank;
CHECK(panel_bank.load(vfs, "DATA/PANEL0-1.DAT", "DATA/PANEL0-1.TAB", pal));
auto check_range = [&](int a, int b) -> bool {
for (int idx = a; idx <= b; ++idx) {
if (idx < 0 || static_cast<size_t>(idx) >= panel_bank.sprites.size()) return false;
const auto& sp = panel_bank.sprites[idx];
if (sp.width <= 2 || sp.height <= 2 || sp.rgba.empty()) return false;
}
return true;
};
CHECK(check_range(1, 77));
CHECK(check_range(86, 162));
CHECK(check_range(198, 199));
CHECK(check_range(227, 228));
CHECK(check_range(258, 268));
CHECK(check_range(270, 271));
CHECK(check_range(273, 276));
CHECK(check_range(281, 286));
}
// Verify 3D model GPU geometry conversion
assets::ObjectTextureAtlas atlas;
CHECK(atlas.load(vfs, pal));