Add track recovery, fix Arctic Land bridge & 9-map sim/render, harden security & optimize runtime
- Add manual track recovery (R / Backspace / Gamepad Back), document controls in README.md, fix Track 8 (Arctic Land) bridge jump/clearance physics, and fix Track 5 respawn invincibility & Track 6 off-track AI recovery across all 9 maps - Verify 9-map sector morphing, combat (swept projectiles/LOS), pitstop chargers, and overpass/bridge surface sampling - Fix Overpass Bottom (-Y) diagonal split and AO, add TerrainChunk frustum culling, O(1) 3D Classic uPaletteLut, atlas gutter/bleed UVs, cached uniform locations, and reusable render scratch buffers - Harden VFS path traversal, RNC decompression bombs/truncated headers, asset/WAV parsers, GameConfig, save loaders, CLI args, and FLIC lifecycle - Optimize 48 kHz OPL3/SoundFont synthesis (trig LUTs, cached envelopes/filters), 64-bit XMI ticks, and audio parameter/thread safety - Add security, rendering, physics, and gameplay regression tests across all test suites
This commit is contained in:
1 parent
5c2ac8e70f
commit
db788a2739
50 files changed
+3522
-1100
No files matched your search
@@ -6,6 +6,7 @@
|
||||
#include "render/world_geometry.hpp"
|
||||
#include "sim/vehicle_defs.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
@@ -165,13 +166,20 @@ int main() {
|
||||
CHECK(check_range(281, 286));
|
||||
}
|
||||
|
||||
// Verify 3D model GPU geometry conversion
|
||||
// Verify 3D model GPU geometry conversion & TEX0-0 half-texel UV inset
|
||||
assets::ObjectTextureAtlas atlas;
|
||||
CHECK(atlas.load(vfs, pal));
|
||||
const char* keys[] = {"CAR0-0", "TANK0-0", "JUGGA0-0", "JET0-0", "BIKE0-0", "SKIM0-0", "RECOV0-0"};
|
||||
for (const char* k : keys) {
|
||||
assets::ModelMesh mesh;
|
||||
CHECK(mesh.load(vfs, std::string("OBJECTS/DATA/") + k + ".DAT", &atlas));
|
||||
for (const auto& tri : mesh.triangles) {
|
||||
if (!tri.textured) continue;
|
||||
for (int c = 0; c < 3; ++c) {
|
||||
CHECK(tri.u[c] > 0.0f && tri.u[c] < 1.0f);
|
||||
CHECK(tri.v_coord[c] > 0.0f && tri.v_coord[c] < 1.0f);
|
||||
}
|
||||
}
|
||||
render::ModelGeometry mg = render::build_model_geometry(mesh, pal);
|
||||
CHECK(!mg.verts.empty());
|
||||
CHECK(mg.indices.size() == mesh.triangles.size() * 3u);
|
||||
@@ -183,6 +191,70 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Verify Bottom (-Y) overpass diagonal split, TerrainChunk AABBs & update bounds
|
||||
{
|
||||
assets::LevelData lvl8;
|
||||
CHECK(lvl8.load(vfs, 8));
|
||||
render::WorldGeometry geo8 = render::build_level_geometry(lvl8);
|
||||
|
||||
// 1. 16x16 TerrainChunk AABBs cover every vertex and sum to terrain_indices
|
||||
const int gw = assets::kMapWidth - 1;
|
||||
const int gh = assets::kMapHeight - 1;
|
||||
const int cs = render::WorldGeometry::kTerrainChunkSize;
|
||||
const int chunks_x = (gw + cs - 1) / cs;
|
||||
const int chunks_z = (gh + cs - 1) / cs;
|
||||
CHECK(geo8.terrain_chunks.size() == static_cast<size_t>(chunks_x) * static_cast<size_t>(chunks_z));
|
||||
size_t total_chunk_idx = 0;
|
||||
for (const auto& ch : geo8.terrain_chunks) {
|
||||
CHECK(ch.index_count > 0);
|
||||
CHECK(ch.first_index + ch.index_count <= geo8.terrain_indices.size());
|
||||
total_chunk_idx += ch.index_count;
|
||||
for (uint32_t i = 0; i < ch.index_count; ++i) {
|
||||
uint32_t vi = geo8.terrain_indices[ch.first_index + i];
|
||||
const Vec3& p = geo8.terrain_verts[vi].pos;
|
||||
CHECK(p.x >= ch.min_b.x - 1e-4f && p.x <= ch.max_b.x + 1e-4f);
|
||||
CHECK(p.y >= ch.min_b.y - 1e-4f && p.y <= ch.max_b.y + 1e-4f);
|
||||
CHECK(p.z >= ch.min_b.z - 1e-4f && p.z <= ch.max_b.z + 1e-4f);
|
||||
}
|
||||
}
|
||||
CHECK(total_chunk_idx == geo8.terrain_indices.size());
|
||||
|
||||
// 2. Refresh bounds reflects terrain height changes cleanly
|
||||
lvl8.cell_mut(75, 70).height = 4096;
|
||||
render::update_terrain_region(lvl8, 74, 69, 76, 71, geo8.terrain_verts);
|
||||
render::refresh_terrain_chunk_bounds(geo8, 74, 69, 76, 71);
|
||||
const auto& updated_chunk = geo8.terrain_chunks[(70 / cs) * chunks_x + (75 / cs)];
|
||||
CHECK(updated_chunk.max_b.y >= 2.9f);
|
||||
|
||||
// 3. All Bottom (-Y) column quads split along (00)-(11) diagonal matching Top/Terrain
|
||||
int bottom_quads = 0;
|
||||
for (size_t i = 0; i + 5 < geo8.column_indices.size(); i += 6) {
|
||||
const auto& v0 = geo8.column_verts[geo8.column_indices[i + 0]];
|
||||
if (v0.normal.y > -0.9f) continue;
|
||||
// For our emitted bottom indices {base+3, base+2, base+1, base+3, base+1, base+0},
|
||||
// index+0 is p3=(00) and index+2 is p1=(11): shared diagonal has dx*dz > 0.5
|
||||
const auto& d0 = geo8.column_verts[geo8.column_indices[i + 0]];
|
||||
const auto& d1 = geo8.column_verts[geo8.column_indices[i + 2]];
|
||||
CHECK((d1.pos.x - d0.pos.x) * (d1.pos.z - d0.pos.z) > 0.5f);
|
||||
++bottom_quads;
|
||||
}
|
||||
CHECK(bottom_quads > 0);
|
||||
|
||||
// 4. Synthetic 2x2 sm=0x02 overpass treats center vertex as overpass (ao=0.88), not solid base (0.72)
|
||||
assets::LevelData syn;
|
||||
syn.map.resize(assets::kMapWidth * assets::kMapHeight);
|
||||
syn.columns[1].shape_mask = 0x02u;
|
||||
syn.columns[1].blocks[1] = 0;
|
||||
for (int z = 10; z <= 11; ++z) {
|
||||
for (int x = 10; x <= 11; ++x) {
|
||||
syn.cell_mut(x, z).tex_or_col = -1;
|
||||
}
|
||||
}
|
||||
render::WorldGeometry geo_syn = render::build_level_geometry(syn);
|
||||
const size_t v_base = (static_cast<size_t>(11) * (assets::kMapWidth - 1) + 11) * 4u;
|
||||
CHECK(std::abs(geo_syn.terrain_verts[v_base].ao - 0.88f) < 1e-4f);
|
||||
}
|
||||
|
||||
std::cout << "[PASS] All 9 Levels & Vehicle 3D Render Geometry validated\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user