Automate WMO floor cache pre-computation

Add precomputeFloorCache() method that samples all WMO bounds at load time
and populates the persistent floor height grid. Called after terrain
streaming completes (initial spawn and teleport) when cache is empty.
This commit is contained in:
Kelsi 2026-02-05 17:30:08 -08:00
parent 125cf588bb
commit 12a7604450
3 changed files with 62 additions and 0 deletions

View file

@ -1270,6 +1270,12 @@ void Application::startSinglePlayer() {
LOG_INFO("Terrain streaming complete: ", terrainMgr->getLoadedTileCount(), " tiles loaded");
// Pre-compute floor cache if it wasn't loaded from file
if (renderer->getWMORenderer() && renderer->getWMORenderer()->getFloorCacheSize() == 0) {
showStatus("Pre-computing collision cache...");
renderer->getWMORenderer()->precomputeFloorCache();
}
// Re-snap camera to ground now that all surrounding tiles are loaded
// (the initial reset inside loadTestTerrain only had 1 tile).
if (spawnSnapToGround && renderer->getCameraController()) {
@ -1396,6 +1402,11 @@ void Application::teleportTo(int presetIndex) {
}
LOG_INFO("Teleport terrain streaming complete: ", terrainMgr->getLoadedTileCount(), " tiles loaded");
// Pre-compute floor cache for the new area
if (renderer->getWMORenderer()) {
renderer->getWMORenderer()->precomputeFloorCache();
}
}
// Floor-snapping presets use camera reset. WMO-floor presets keep explicit Z.