From f5f4467565061f01c5c333b975b03acbea857c60 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 2 Mar 2026 10:15:01 -0800 Subject: [PATCH] Fix terrain streaming performance: revert copy back to move, remove broken cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit changed std::move to copy for terrain/mesh data to fix the empty-cache bug. But copying ~8 MB per tile × 81 tiles caused a 60s streaming timeout. The tile cache was already broken before — putCachedTile stored a shared_ptr to the same PendingTile whose data was moved out, so cached tiles always had empty meshes. Remove the putCachedTile call entirely; tiles re-parse from ADT files (asset manager file cache hit) when they re-enter streaming range. The softReset cache clear from the previous commit remains as safety for map transitions. --- src/rendering/terrain_manager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rendering/terrain_manager.cpp b/src/rendering/terrain_manager.cpp index 1f5c8066..67d486b3 100644 --- a/src/rendering/terrain_manager.cpp +++ b/src/rendering/terrain_manager.cpp @@ -912,8 +912,8 @@ bool TerrainManager::advanceFinalization(FinalizingTile& ft) { // Commit tile to loadedTiles auto tile = std::make_unique(); tile->coord = coord; - tile->terrain = pending->terrain; // copy (not move) — pending is cached for reuse - tile->mesh = pending->mesh; // copy (not move) — pending is cached for reuse + tile->terrain = std::move(pending->terrain); + tile->mesh = std::move(pending->mesh); tile->loaded = true; tile->m2InstanceIds = std::move(ft.m2InstanceIds); tile->wmoInstanceIds = std::move(ft.wmoInstanceIds); @@ -921,7 +921,9 @@ bool TerrainManager::advanceFinalization(FinalizingTile& ft) { tile->doodadUniqueIds = std::move(ft.tileUniqueIds); getTileBounds(coord, tile->minX, tile->minY, tile->maxX, tile->maxY); loadedTiles[coord] = std::move(tile); - putCachedTile(pending); + // NOTE: Don't cache pending here — std::move above empties terrain/mesh, + // so the cached tile would have 0 valid chunks on reuse. Tiles are + // re-parsed from ADT files (file-cache hit) when they re-enter range. // Now safe to remove from pendingTiles (tile is in loadedTiles) {