2026-11-30 22:31:51 +02:00
|
|
|
#include "assets/level.hpp"
|
|
|
|
|
#include "core/clock.hpp"
|
|
|
|
|
#include "core/math.hpp"
|
|
|
|
|
#include "core/vfs.hpp"
|
|
|
|
|
#include "sim/physics.hpp"
|
|
|
|
|
#include "sim/race_sim.hpp"
|
|
|
|
|
#include "sim/vehicle_defs.hpp"
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
using namespace top_octane;
|
|
|
|
|
|
|
|
|
|
#define CHECK(cond) \
|
|
|
|
|
do { \
|
|
|
|
|
if (!(cond)) { \
|
|
|
|
|
std::cerr << "FAIL [" << __FILE__ << ":" << __LINE__ << "]: " #cond << "\n"; \
|
|
|
|
|
return 1; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
Vfs vfs;
|
|
|
|
|
CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR));
|
|
|
|
|
|
|
|
|
|
// 1. Verify starting grid across all 6 levels is collision-free and finite
|
|
|
|
|
for (int l = 1; l <= 6; ++l) {
|
|
|
|
|
assets::LevelData lvl;
|
|
|
|
|
CHECK(lvl.load(vfs, l));
|
|
|
|
|
|
|
|
|
|
sim::RaceSetup setup;
|
|
|
|
|
setup.track_number = l;
|
|
|
|
|
setup.num_ai = 7;
|
|
|
|
|
|
|
|
|
|
sim::RaceSim sim;
|
|
|
|
|
CHECK(sim.start_race(lvl, setup));
|
|
|
|
|
CHECK(sim.crafts().size() == 8);
|
|
|
|
|
|
|
|
|
|
for (const auto& c : sim.crafts()) {
|
|
|
|
|
CHECK(std::isfinite(c.curr_pose.pos.x));
|
|
|
|
|
CHECK(std::isfinite(c.curr_pose.pos.y));
|
|
|
|
|
CHECK(std::isfinite(c.curr_pose.pos.z));
|
|
|
|
|
CHECK(!lvl.is_cell_solid_at_y(static_cast<int>(std::floor(c.curr_pose.pos.x)),
|
|
|
|
|
static_cast<int>(std::floor(c.curr_pose.pos.z)),
|
|
|
|
|
c.curr_pose.pos.y));
|
|
|
|
|
}
|
|
|
|
|
for (size_t i = 0; i < sim.crafts().size(); ++i) {
|
|
|
|
|
for (size_t j = i + 1; j < sim.crafts().size(); ++j) {
|
|
|
|
|
const auto& ca = sim.crafts()[i];
|
|
|
|
|
const auto& cb = sim.crafts()[j];
|
|
|
|
|
float ra = sim::kVehicleSpecs[std::clamp(ca.vehicle_idx, 0, 5)].collision_radius;
|
|
|
|
|
float rb = sim::kVehicleSpecs[std::clamp(cb.vehicle_idx, 0, 5)].collision_radius;
|
|
|
|
|
float dx = cb.curr_pose.pos.x - ca.curr_pose.pos.x;
|
|
|
|
|
float dz = cb.curr_pose.pos.z - ca.curr_pose.pos.z;
|
|
|
|
|
CHECK(std::hypot(dx, dz) >= ra + rb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Start grid valid & collision-free across all 6 tracks\n";
|
|
|
|
|
|
|
|
|
|
// 2. Verify fixed-step determinism (running two identical sims produces bit-identical state)
|
|
|
|
|
assets::LevelData lvl1;
|
|
|
|
|
CHECK(lvl1.load(vfs, 1));
|
|
|
|
|
|
|
|
|
|
auto run_determinism = [&](int steps) -> sim::CraftPose {
|
|
|
|
|
sim::RaceSetup setup;
|
|
|
|
|
setup.track_number = 1;
|
|
|
|
|
setup.num_ai = 0;
|
|
|
|
|
sim::RaceSim s;
|
|
|
|
|
s.start_race(lvl1, setup);
|
|
|
|
|
CraftInput in;
|
|
|
|
|
in.throttle = 1.0f;
|
|
|
|
|
for (int i = 0; i < steps; ++i) {
|
|
|
|
|
in.steer = (i > 220 && i < 260) ? 0.5f : 0.0f;
|
|
|
|
|
in.boost = (i > 200 && i < 240);
|
|
|
|
|
s.step(in, CraftInput{}, static_cast<float>(FixedStepClock::kFixedDt));
|
|
|
|
|
}
|
|
|
|
|
return s.crafts()[0].curr_pose;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sim::CraftPose pa = run_determinism(400);
|
|
|
|
|
sim::CraftPose pb = run_determinism(400);
|
|
|
|
|
CHECK(pa.pos.x == pb.pos.x && pa.pos.y == pb.pos.y && pa.pos.z == pb.pos.z);
|
|
|
|
|
CHECK(pa.yaw == pb.yaw);
|
|
|
|
|
std::cout << "[PASS] Fixed-timestep 60Hz determinism verified\n";
|
|
|
|
|
|
|
|
|
|
// 3. Verify autopilot completes an entire 2-lap race cleanly on Level 1 without getting stuck
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup setup;
|
|
|
|
|
setup.track_number = 1;
|
|
|
|
|
setup.total_laps = 2;
|
|
|
|
|
setup.num_ai = 0;
|
|
|
|
|
sim::RaceSim s;
|
|
|
|
|
CHECK(s.start_race(lvl1, setup));
|
|
|
|
|
s.crafts_mut()[0].autopilot = true;
|
|
|
|
|
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
// Simulate up to 180 seconds (10800 ticks)
|
|
|
|
|
for (int t = 0; t < 10800 && !s.race_finished(); ++t) {
|
|
|
|
|
s.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
// Replenish fuel if low so test isolates navigation/physics/checkpoints
|
|
|
|
|
if (s.crafts()[0].fuel < 20.0f) s.crafts_mut()[0].fuel = 100.0f;
|
|
|
|
|
}
|
|
|
|
|
const auto& p1 = s.crafts()[0];
|
|
|
|
|
std::cout << " Autopilot 2-lap test: finished=" << p1.finished
|
|
|
|
|
<< " lap=" << p1.lap << " cps=" << p1.checkpoints_passed
|
|
|
|
|
<< " time=" << p1.race_time << "s\n";
|
|
|
|
|
CHECK(p1.finished);
|
|
|
|
|
CHECK(p1.best_lap_time > 5.0f && p1.best_lap_time < 80.0f);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Autopilot hover physics, checkpoints & 2-lap completion verified\n";
|
|
|
|
|
|
|
|
|
|
// 4. Verify wall containment (steering straight into a boundary/column never tunnels out of map)
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup setup;
|
|
|
|
|
setup.track_number = 1;
|
|
|
|
|
setup.num_ai = 0;
|
|
|
|
|
sim::RaceSim s;
|
|
|
|
|
CHECK(s.start_race(lvl1, setup));
|
|
|
|
|
CraftInput ram;
|
|
|
|
|
ram.throttle = 1.0f;
|
|
|
|
|
ram.steer = 1.0f;
|
|
|
|
|
ram.boost = true;
|
|
|
|
|
for (int t = 0; t < 600; ++t) {
|
|
|
|
|
s.step(ram, CraftInput{}, static_cast<float>(FixedStepClock::kFixedDt));
|
|
|
|
|
const auto& pos = s.crafts()[0].curr_pose.pos;
|
|
|
|
|
CHECK(pos.x >= 1.0f && pos.x <= assets::kMapWidth - 2.0f);
|
|
|
|
|
CHECK(pos.z >= 1.0f && pos.z <= assets::kMapHeight - 2.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Map boundary & column containment verified\n";
|
|
|
|
|
|
|
|
|
|
// 5. Seam-free multi-tile wall sliding & 2-craft column squeeze containment
|
|
|
|
|
assets::LevelData syn;
|
|
|
|
|
syn.map.resize(assets::kMapWidth * assets::kMapHeight);
|
|
|
|
|
for (auto& m : syn.map) {
|
|
|
|
|
m.height = 2048;
|
|
|
|
|
m.tex_or_col = 0;
|
|
|
|
|
}
|
|
|
|
|
syn.columns[1].shape_mask = 0x03;
|
|
|
|
|
for (int x = 10; x <= 19; ++x) {
|
|
|
|
|
syn.cell_mut(x, 20).tex_or_col = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
sim::CraftState car;
|
|
|
|
|
car.id = 0;
|
|
|
|
|
car.vehicle_idx = 0; // CAR0- (r = 0.48)
|
|
|
|
|
car.curr_pose.pos = Vec3(11.0f, 0.28f, 19.45f);
|
|
|
|
|
car.curr_pose.yaw = kHalfPi;
|
|
|
|
|
car.prev_pose = car.curr_pose;
|
|
|
|
|
car.vel = Vec3(12.0f, 0.0f, 2.5f);
|
|
|
|
|
car.fuel = car.max_fuel = 100.0f;
|
|
|
|
|
car.shield = car.max_shield = 100.0f;
|
|
|
|
|
|
|
|
|
|
CraftInput neutral{};
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
for (int t = 0; t < 30; ++t) {
|
|
|
|
|
sim::step_craft_physics(car, neutral, syn, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(car.curr_pose.pos.z <= 20.0f - 0.48f + 0.02f);
|
|
|
|
|
CHECK(car.curr_pose.pos.x > 14.5f);
|
|
|
|
|
CHECK(car.vel.x > 4.5f);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Seam-free multi-tile wall sliding verified\n";
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
sim::CraftState a;
|
|
|
|
|
a.id = 0;
|
|
|
|
|
a.vehicle_idx = 2; // JUGGA (r = 0.60)
|
|
|
|
|
a.curr_pose.pos = Vec3(15.0f, 0.28f, 19.38f);
|
|
|
|
|
a.prev_pose = a.curr_pose;
|
|
|
|
|
a.vel = Vec3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
a.fuel = a.max_fuel = 125.0f;
|
|
|
|
|
|
|
|
|
|
sim::CraftState b;
|
|
|
|
|
b.id = 1;
|
|
|
|
|
b.vehicle_idx = 1; // TANK (r = 0.56)
|
|
|
|
|
b.curr_pose.pos = Vec3(15.0f, 0.28f, 18.4f);
|
|
|
|
|
b.prev_pose = b.curr_pose;
|
|
|
|
|
b.vel = Vec3(0.0f, 0.0f, 12.0f);
|
|
|
|
|
b.fuel = b.max_fuel = 110.0f;
|
|
|
|
|
|
|
|
|
|
CraftInput neutral{};
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
for (int t = 0; t < 30; ++t) {
|
|
|
|
|
sim::step_craft_physics(a, neutral, syn, dt);
|
|
|
|
|
sim::step_craft_physics(b, neutral, syn, dt);
|
|
|
|
|
for (int iter = 0; iter < 2; ++iter) {
|
|
|
|
|
float rel = 0.0f;
|
|
|
|
|
sim::resolve_craft_pair_collision(a, b, rel);
|
|
|
|
|
float imp = 0.0f;
|
|
|
|
|
bool scr = false;
|
|
|
|
|
sim::resolve_world_collisions(a, syn, imp, scr);
|
|
|
|
|
sim::resolve_world_collisions(b, syn, imp, scr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CHECK(!syn.is_cell_solid_at_y(static_cast<int>(std::floor(a.curr_pose.pos.x)),
|
|
|
|
|
static_cast<int>(std::floor(a.curr_pose.pos.z)),
|
|
|
|
|
a.curr_pose.pos.y));
|
|
|
|
|
CHECK(!syn.is_cell_solid_at_y(static_cast<int>(std::floor(b.curr_pose.pos.x)),
|
|
|
|
|
static_cast<int>(std::floor(b.curr_pose.pos.z)),
|
|
|
|
|
b.curr_pose.pos.y));
|
|
|
|
|
CHECK(a.curr_pose.pos.z <= 20.0f - sim::kVehicleSpecs[a.vehicle_idx].collision_radius + 0.02f);
|
|
|
|
|
CHECK(b.curr_pose.pos.z <= 20.0f - sim::kVehicleSpecs[b.vehicle_idx].collision_radius + 0.02f);
|
|
|
|
|
float sep = std::hypot(b.curr_pose.pos.x - a.curr_pose.pos.x,
|
|
|
|
|
b.curr_pose.pos.z - a.curr_pose.pos.z);
|
|
|
|
|
CHECK(sep >= 0.60f + 0.56f - 0.05f);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] 2-craft column squeeze containment verified\n";
|
|
|
|
|
|
|
|
|
|
// 6. Track 1 gantry overpass clearance & ceiling clamp
|
|
|
|
|
{
|
|
|
|
|
int gx = -1, gz = -1;
|
|
|
|
|
for (int z = 0; z < assets::kMapHeight && gx < 0; ++z) {
|
|
|
|
|
for (int x = 0; x < assets::kMapWidth; ++x) {
|
|
|
|
|
const auto& m = lvl1.cell(x, z);
|
|
|
|
|
if (m.tex_or_col < 0) {
|
|
|
|
|
int cidx = -m.tex_or_col;
|
|
|
|
|
if (cidx > 0 && cidx < assets::kMaxColumns) {
|
|
|
|
|
uint16_t mask = lvl1.columns[cidx].shape_mask;
|
|
|
|
|
if ((mask & 1u) == 0 && (mask & 0xFEu) != 0) {
|
|
|
|
|
gx = x;
|
|
|
|
|
gz = z;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CHECK(gx >= 0 && gz >= 0);
|
|
|
|
|
float gy = lvl1.cell_height_world(gx, gz);
|
|
|
|
|
CHECK(!lvl1.is_cell_solid_at_y(gx, gz, gy + 0.28f));
|
|
|
|
|
|
|
|
|
|
float floor_y = 0.0f, ceil_y = 1e6f;
|
|
|
|
|
lvl1.sample_surface_and_ceiling(gx + 0.5f, gz + 0.5f, gy + 0.28f, floor_y, ceil_y);
|
|
|
|
|
CHECK(ceil_y < 1e5f && ceil_y >= gy + 0.95f);
|
|
|
|
|
|
|
|
|
|
sim::CraftState c;
|
|
|
|
|
c.vehicle_idx = 0;
|
|
|
|
|
c.curr_pose.pos = Vec3(gx + 0.5f, ceil_y - 0.10f, gz + 0.5f);
|
|
|
|
|
c.prev_pose = c.curr_pose;
|
|
|
|
|
c.vel = Vec3(0.0f, 5.0f, 0.0f);
|
|
|
|
|
float imp = 0.0f;
|
|
|
|
|
bool scr = false;
|
|
|
|
|
sim::resolve_world_collisions(c, lvl1, imp, scr);
|
|
|
|
|
CHECK(c.curr_pose.pos.y <= ceil_y - 0.45f);
|
|
|
|
|
CHECK(c.vel.y <= 0.0f);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Overhead gantry overpass & ceiling clamping verified\n";
|
|
|
|
|
|
|
|
|
|
// 7. All 6 tracks 1-lap autopilot completion
|
|
|
|
|
for (int l = 1; l <= 6; ++l) {
|
|
|
|
|
assets::LevelData lvl;
|
|
|
|
|
CHECK(lvl.load(vfs, l));
|
|
|
|
|
sim::RaceSetup setup;
|
|
|
|
|
setup.track_number = l;
|
|
|
|
|
setup.total_laps = 1;
|
|
|
|
|
setup.num_ai = 0;
|
|
|
|
|
sim::RaceSim s;
|
|
|
|
|
CHECK(s.start_race(lvl, setup));
|
|
|
|
|
s.crafts_mut()[0].autopilot = true;
|
|
|
|
|
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
for (int t = 0; t < 9000 && !s.race_finished(); ++t) {
|
|
|
|
|
s.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
if (s.crafts()[0].fuel < 20.0f) s.crafts_mut()[0].fuel = 100.0f;
|
|
|
|
|
}
|
|
|
|
|
const auto& p1 = s.crafts()[0];
|
|
|
|
|
std::cout << " Track " << l << " 1-lap autopilot: finished=" << p1.finished
|
|
|
|
|
<< " time=" << p1.race_time << "s\n";
|
|
|
|
|
CHECK(p1.finished);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] 1-lap autopilot completion verified across all 6 tracks\n";
|
2026-12-01 08:05:04 +02:00
|
|
|
|
|
|
|
|
// 8. 8-direction full-boost ramming stress test across all 6 tracks (0 column/cliff traps)
|
|
|
|
|
{
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
for (int l = 1; l <= 6; ++l) {
|
|
|
|
|
assets::LevelData lvl;
|
|
|
|
|
CHECK(lvl.load(vfs, l));
|
|
|
|
|
for (const auto& wp : lvl.main_waypoints) {
|
|
|
|
|
for (int di = 0; di < 8; ++di) {
|
|
|
|
|
float ang = static_cast<float>(di) * (kPi * 0.25f);
|
|
|
|
|
sim::CraftState c;
|
|
|
|
|
c.id = 0;
|
|
|
|
|
c.vehicle_idx = 0;
|
|
|
|
|
c.curr_pose.pos = Vec3(wp.x, lvl.sample_height_world(wp.x, wp.z) + 0.30f, wp.z);
|
|
|
|
|
c.curr_pose.yaw = ang;
|
|
|
|
|
c.prev_pose = c.curr_pose;
|
|
|
|
|
c.vel = Vec3(std::sin(ang) * 22.0f, 0.0f, std::cos(ang) * 22.0f);
|
|
|
|
|
c.fuel = c.max_fuel = 100.0f;
|
|
|
|
|
c.shield = c.max_shield = 100.0f;
|
|
|
|
|
|
|
|
|
|
CraftInput in;
|
|
|
|
|
in.throttle = 1.0f;
|
|
|
|
|
in.boost = true;
|
|
|
|
|
for (int t = 0; t < 150; ++t) {
|
|
|
|
|
sim::step_craft_physics(c, in, lvl, dt, false);
|
|
|
|
|
const Vec3& p = c.curr_pose.pos;
|
|
|
|
|
int ix = static_cast<int>(std::floor(p.x));
|
|
|
|
|
int iz = static_cast<int>(std::floor(p.z));
|
|
|
|
|
CHECK(ix >= 0 && ix < assets::kMapWidth && iz >= 0 && iz < assets::kMapHeight);
|
|
|
|
|
const auto& me = lvl.cell(ix, iz);
|
|
|
|
|
if (me.tex_or_col < 0 && -me.tex_or_col > 0 && -me.tex_or_col < assets::kMaxColumns) {
|
|
|
|
|
const auto& col = lvl.columns[-me.tex_or_col];
|
|
|
|
|
float gy = lvl.sample_height_world(p.x, p.z);
|
|
|
|
|
for (int s = 0; s < 8; ++s) {
|
|
|
|
|
if ((col.shape_mask & (1u << s)) == 0) continue;
|
|
|
|
|
float sb = gy + static_cast<float>(s);
|
|
|
|
|
float st = sb + 1.0f;
|
|
|
|
|
CHECK(!(sb <= p.y + 0.35f && st >= p.y - 0.02f));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!c.airborne && p.y <= lvl.sample_height_world(p.x, p.z) + 0.55f) {
|
|
|
|
|
Vec3 sn = lvl.sample_normal_world(p.x, p.z);
|
|
|
|
|
CHECK(sn.y >= 0.30f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] 8-direction boost ramming stress test: 0 texture/cliff traps across all 6 tracks\n";
|
|
|
|
|
|
|
|
|
|
// 9. Targeted containment, bridge deck, cliff, and escape edge cases
|
|
|
|
|
{
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
|
|
|
|
|
// 9a. Sloped column containment on Level 5 (56, 16) (M1, dh=2.50)
|
|
|
|
|
assets::LevelData lvl5;
|
|
|
|
|
CHECK(lvl5.load(vfs, 5));
|
|
|
|
|
{
|
|
|
|
|
sim::CraftState c;
|
|
|
|
|
c.id = 0;
|
|
|
|
|
c.vehicle_idx = 0;
|
|
|
|
|
c.curr_pose.pos = Vec3(56.5f, lvl5.sample_height_world(56.5f, 17.6f) + 0.28f, 17.6f);
|
|
|
|
|
c.curr_pose.yaw = kPi;
|
|
|
|
|
c.prev_pose = c.curr_pose;
|
|
|
|
|
c.vel = Vec3(0.0f, 0.0f, -14.0f);
|
|
|
|
|
c.fuel = c.max_fuel = 100.0f;
|
|
|
|
|
CraftInput in;
|
|
|
|
|
in.throttle = 1.0f;
|
|
|
|
|
for (int t = 0; t < 30; ++t) {
|
|
|
|
|
sim::step_craft_physics(c, in, lvl5, dt, false);
|
|
|
|
|
int ix = static_cast<int>(std::floor(c.curr_pose.pos.x));
|
|
|
|
|
int iz = static_cast<int>(std::floor(c.curr_pose.pos.z));
|
|
|
|
|
CHECK(!(ix == 56 && iz == 16 &&
|
|
|
|
|
lvl5.is_cell_solid_at_point(ix, iz, c.curr_pose.pos.x, c.curr_pose.pos.z,
|
|
|
|
|
c.curr_pose.pos.y)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 9b. Overpass bridge deck support on Level 2 (M2), Level 3 (M6), and Level 6 (M2)
|
|
|
|
|
struct BridgeCase { int lvl_num; float wx; float wz; float top_offset; };
|
|
|
|
|
const BridgeCase bcases[3] = {
|
|
|
|
|
{2, 77.5f, 6.5f, 2.0f},
|
|
|
|
|
{3, 109.5f, 90.5f, 3.0f},
|
|
|
|
|
{6, 90.5f, 32.5f, 2.0f},
|
|
|
|
|
};
|
|
|
|
|
for (const auto& bc : bcases) {
|
|
|
|
|
assets::LevelData blvl;
|
|
|
|
|
CHECK(blvl.load(vfs, bc.lvl_num));
|
|
|
|
|
float gy = blvl.sample_height_world(bc.wx, bc.wz);
|
|
|
|
|
float deck_y = gy + bc.top_offset;
|
|
|
|
|
float floor_y = 0.0f, ceil_y = 1e6f;
|
|
|
|
|
blvl.sample_surface_and_ceiling(bc.wx, bc.wz, deck_y + 0.28f, floor_y, ceil_y);
|
|
|
|
|
CHECK(floor_y >= deck_y - 0.02f);
|
|
|
|
|
|
|
|
|
|
sim::CraftState c;
|
|
|
|
|
c.id = 0;
|
|
|
|
|
c.vehicle_idx = 0;
|
|
|
|
|
c.curr_pose.pos = Vec3(bc.wx, deck_y + 0.28f, bc.wz);
|
|
|
|
|
c.prev_pose = c.curr_pose;
|
|
|
|
|
c.fuel = c.max_fuel = 100.0f;
|
|
|
|
|
CraftInput neutral{};
|
|
|
|
|
for (int t = 0; t < 15; ++t) {
|
|
|
|
|
sim::step_craft_physics(c, neutral, blvl, dt, false);
|
|
|
|
|
}
|
|
|
|
|
CHECK(c.curr_pose.pos.y >= deck_y + 0.14f);
|
|
|
|
|
}
|
|
|
|
|
|
2026-12-01 13:59:43 +02:00
|
|
|
// 9c. Sheer terrain cliff blocking (Level 1 x=34..35) vs downhill drop clearance (Level 5 (22,99))
|
2026-12-01 08:05:04 +02:00
|
|
|
{
|
|
|
|
|
sim::CraftState cliff_car;
|
|
|
|
|
cliff_car.id = 0;
|
|
|
|
|
cliff_car.vehicle_idx = 0;
|
2026-12-01 13:59:43 +02:00
|
|
|
cliff_car.curr_pose.pos = Vec3(32.5f, lvl1.sample_height_world(32.5f, 57.5f) + 0.28f, 57.5f);
|
|
|
|
|
cliff_car.curr_pose.yaw = kHalfPi;
|
2026-12-01 08:05:04 +02:00
|
|
|
cliff_car.prev_pose = cliff_car.curr_pose;
|
2026-12-01 13:59:43 +02:00
|
|
|
cliff_car.vel = Vec3(14.0f, 0.0f, 0.0f);
|
2026-12-01 08:05:04 +02:00
|
|
|
cliff_car.fuel = cliff_car.max_fuel = 100.0f;
|
|
|
|
|
CraftInput in;
|
|
|
|
|
in.throttle = 1.0f;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
sim::step_craft_physics(cliff_car, in, lvl1, dt, false);
|
|
|
|
|
}
|
2026-12-01 13:59:43 +02:00
|
|
|
CHECK(cliff_car.curr_pose.pos.x < 33.85f);
|
|
|
|
|
CHECK(cliff_car.curr_pose.pos.y < 0.0f);
|
2026-12-01 08:05:04 +02:00
|
|
|
|
|
|
|
|
sim::CraftState drop_car;
|
|
|
|
|
drop_car.id = 0;
|
|
|
|
|
drop_car.vehicle_idx = 0;
|
|
|
|
|
drop_car.curr_pose.pos = Vec3(22.5f, lvl5.sample_height_world(22.5f, 101.0f) + 0.28f, 101.0f);
|
|
|
|
|
drop_car.curr_pose.yaw = kPi;
|
|
|
|
|
drop_car.prev_pose = drop_car.curr_pose;
|
|
|
|
|
drop_car.vel = Vec3(0.0f, 0.0f, -14.0f);
|
|
|
|
|
drop_car.fuel = drop_car.max_fuel = 100.0f;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
sim::step_craft_physics(drop_car, in, lvl5, dt, false);
|
|
|
|
|
}
|
|
|
|
|
CHECK(drop_car.curr_pose.pos.z < 97.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 9d. Guaranteed escape from inside a solid 3x3 building block
|
|
|
|
|
for (int z = 30; z <= 32; ++z) {
|
|
|
|
|
for (int x = 30; x <= 32; ++x) {
|
|
|
|
|
syn.cell_mut(x, z).tex_or_col = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sim::CraftState trapped;
|
|
|
|
|
trapped.id = 0;
|
|
|
|
|
trapped.vehicle_idx = 0;
|
|
|
|
|
trapped.curr_pose.pos = Vec3(31.5f, 0.28f, 31.5f);
|
|
|
|
|
trapped.prev_pose = trapped.curr_pose;
|
|
|
|
|
float imp = 0.0f;
|
|
|
|
|
bool scr = false;
|
|
|
|
|
CHECK(sim::resolve_world_collisions(trapped, syn, imp, scr));
|
|
|
|
|
CHECK(std::isfinite(trapped.curr_pose.pos.x) && std::isfinite(trapped.curr_pose.pos.z));
|
|
|
|
|
CHECK(!syn.is_cell_solid_at_point(static_cast<int>(std::floor(trapped.curr_pose.pos.x)),
|
|
|
|
|
static_cast<int>(std::floor(trapped.curr_pose.pos.z)),
|
|
|
|
|
trapped.curr_pose.pos.x, trapped.curr_pose.pos.z,
|
|
|
|
|
trapped.curr_pose.pos.y));
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Sloped column, overpass deck, cliff wall, downhill drop & escape verified\n";
|
2026-12-01 13:59:43 +02:00
|
|
|
|
|
|
|
|
// 10. Verify all 6 vehicles accelerate to strictly distinct stat-ordered cruise and boost top speeds
|
|
|
|
|
{
|
|
|
|
|
assets::LevelData flat_lvl;
|
|
|
|
|
flat_lvl.map.resize(assets::kMapWidth * assets::kMapHeight);
|
|
|
|
|
for (auto& m : flat_lvl.map) {
|
|
|
|
|
m.height = 2048;
|
|
|
|
|
m.tex_or_col = 0;
|
|
|
|
|
}
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
auto measure_max_speed = [&](int veh_idx, bool with_boost) -> float {
|
|
|
|
|
sim::CraftState c;
|
|
|
|
|
c.id = 0;
|
|
|
|
|
c.vehicle_idx = veh_idx;
|
|
|
|
|
c.curr_pose.pos = Vec3(15.0f, 0.28f, 80.0f);
|
|
|
|
|
c.curr_pose.yaw = kHalfPi;
|
|
|
|
|
c.prev_pose = c.curr_pose;
|
|
|
|
|
c.fuel = c.max_fuel = 1000.0f;
|
|
|
|
|
c.shield = c.max_shield = 100.0f;
|
|
|
|
|
CraftInput in;
|
|
|
|
|
in.throttle = 1.0f;
|
|
|
|
|
in.boost = with_boost;
|
|
|
|
|
for (int t = 0; t < 270; ++t) { // 4.5 seconds unobstructed +X run (kMapWidth = 256)
|
|
|
|
|
sim::step_craft_physics(c, in, flat_lvl, dt, false);
|
|
|
|
|
}
|
|
|
|
|
return c.speed_horizontal();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Ordered strictly from lowest stat_speed to highest: Jugga(4) < Beserker(5) < Speeder(7) < Flexiwing(8) < Outrider(9) < Vampyr(10)
|
|
|
|
|
constexpr int kSpeedOrder[6] = {2, 1, 0, 5, 4, 3};
|
|
|
|
|
float cruise[6]{};
|
|
|
|
|
float boosted[6]{};
|
|
|
|
|
for (int v = 0; v < 6; ++v) {
|
|
|
|
|
cruise[v] = measure_max_speed(v, false);
|
|
|
|
|
boosted[v] = measure_max_speed(v, true);
|
|
|
|
|
}
|
|
|
|
|
for (int k = 0; k < 5; ++k) {
|
|
|
|
|
int va = kSpeedOrder[k];
|
|
|
|
|
int vb = kSpeedOrder[k + 1];
|
|
|
|
|
CHECK(cruise[vb] - cruise[va] >= 1.2f);
|
|
|
|
|
CHECK(boosted[vb] - boosted[va] >= 1.8f);
|
|
|
|
|
}
|
|
|
|
|
CHECK(cruise[3] - cruise[2] >= 8.5f); // Vampyr vs Jugga
|
|
|
|
|
std::cout << "[PASS] Vehicle top speeds & boost velocities strictly differentiate all 6 crafts\n";
|
|
|
|
|
}
|
2026-11-30 22:31:51 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|