Fix geometry collision traps and implement authentic sector morphing

This commit is contained in:
Luxferre committed 2026-12-01 08:05:04 +02:00
1 parent cd63921ea4
commit b9353f552c
16 files changed
+1470 -131

No files matched your search

+36
View File
@@ -82,6 +82,42 @@ int main() {
// Verify partial morph region update stays valid
render::update_terrain_region(lvl, 10, 80, 15, 85, geo.terrain_verts);
if (l == 6) {
// Remove 39 solid columns at (44..57, 50..55) using morph id=140 source cells
assets::LevelData morphed = lvl;
for (int oz = 0; oz <= 5; ++oz) {
for (int ox = 0; ox <= 13; ++ox) {
morphed.cell_mut(44 + ox, 50 + oz) = lvl.cell(31 + ox, 41 + oz);
}
}
std::vector<render::WorldVertex> mverts;
std::vector<uint32_t> mindices;
render::rebuild_column_geometry(morphed, mverts, mindices);
CHECK(mindices.size() < geo.column_indices.size());
CHECK(!mverts.empty() && mindices.size() % 6 == 0);
for (const auto& v : mverts) {
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.u >= -1e-4f && v.u <= 1.0001f);
CHECK(v.v >= -1e-4f && v.v <= 1.0001f);
}
CHECK(check_winding(mverts, mindices, false));
// Also verify bidirectional swap relocates column vertices cleanly with valid winding
assets::LevelData swapped = lvl;
for (int oz = 0; oz <= 5; ++oz) {
for (int ox = 0; ox <= 13; ++ox) {
auto dc = lvl.cell(44 + ox, 50 + oz);
auto sc = lvl.cell(31 + ox, 41 + oz);
swapped.cell_mut(44 + ox, 50 + oz) = sc;
swapped.cell_mut(31 + ox, 41 + oz) = dc;
}
}
render::rebuild_column_geometry(swapped, mverts, mindices);
CHECK(!mverts.empty() && mindices.size() == geo.column_indices.size());
CHECK(check_winding(mverts, mindices, false));
}
std::cout << " Level " << l << " geo: terrain_tris=" << geo.terrain_indices.size() / 3
<< " column_tris=" << geo.column_indices.size() / 3 << "\n";
}