Preload terrain textures on background thread and fix ramp Z-snapping

Load BLP texture data during prepareTile() and upload to GL cache in
finalizeTile(), eliminating file I/O stalls on the main thread. Reduce
ready tiles per frame to 1. Fix camera sweep to snap Z to ramp surfaces.
Change hearthstone action bar slot from spell to item.
This commit is contained in:
Kelsi 2026-02-08 01:16:23 -08:00
parent 0ce38cfb99
commit d910073d7a
6 changed files with 66 additions and 13 deletions

View file

@ -4,6 +4,7 @@
#include "pipeline/terrain_mesh.hpp"
#include "pipeline/m2_loader.hpp"
#include "pipeline/wmo_loader.hpp"
#include "pipeline/blp_loader.hpp"
#include <string>
#include <unordered_map>
#include <unordered_set>
@ -103,6 +104,10 @@ struct PendingTile {
glm::mat4 modelMatrix; // Pre-computed world transform
};
std::vector<WMODoodadReady> wmoDoodads;
// Pre-loaded terrain texture BLP data (loaded on background thread to avoid
// blocking file I/O on the main thread during finalizeTile)
std::unordered_map<std::string, pipeline::BLPImage> preloadedTextures;
};
/**

View file

@ -1,6 +1,7 @@
#pragma once
#include "pipeline/terrain_mesh.hpp"
#include "pipeline/blp_loader.hpp"
#include "rendering/shader.hpp"
#include "rendering/texture.hpp"
#include "rendering/camera.hpp"
@ -87,6 +88,12 @@ public:
*/
void removeTile(int tileX, int tileY);
/**
* Upload pre-loaded BLP textures to the GL texture cache.
* Called before loadTerrain() so texture loading avoids file I/O.
*/
void uploadPreloadedTextures(const std::unordered_map<std::string, pipeline::BLPImage>& textures);
/**
* Render loaded terrain
* @param camera Camera for view/projection matrices