mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Revert terrain_manager to original finalizeTile to fix water rendering
The incremental advanceFinalization state machine broke water rendering in ways that couldn't be resolved. Reverted to the original monolithic finalizeTile approach. The other performance optimizations (bone SSBO pre-allocation, WMO distance culling, M2 adaptive distance tiers) are kept.
This commit is contained in:
parent
7dd78e2c0a
commit
9b90ab0429
2 changed files with 255 additions and 326 deletions
|
|
@ -123,41 +123,6 @@ struct PendingTile {
|
|||
std::unordered_map<std::string, pipeline::BLPImage> preloadedTextures;
|
||||
};
|
||||
|
||||
/**
|
||||
* Phases for incremental tile finalization (one bounded unit of work per call)
|
||||
*/
|
||||
enum class FinalizationPhase {
|
||||
TERRAIN, // Upload terrain mesh + textures
|
||||
M2_MODELS, // Upload ONE M2 model per call
|
||||
M2_INSTANCES, // Create all M2 instances (lightweight struct allocation)
|
||||
WMO_MODELS, // Upload ONE WMO model per call
|
||||
WMO_INSTANCES, // Create all WMO instances + load WMO liquids
|
||||
WMO_DOODADS, // Upload ONE WMO doodad M2 per call
|
||||
WATER, // Upload water from terrain
|
||||
AMBIENT, // Register ambient emitters
|
||||
DONE // Commit to loadedTiles
|
||||
};
|
||||
|
||||
/**
|
||||
* In-progress tile finalization state — tracks progress across frames
|
||||
*/
|
||||
struct FinalizingTile {
|
||||
std::shared_ptr<PendingTile> pending;
|
||||
FinalizationPhase phase = FinalizationPhase::TERRAIN;
|
||||
|
||||
// Progress indices within current phase
|
||||
size_t m2ModelIndex = 0; // Next M2 model to upload
|
||||
size_t wmoModelIndex = 0; // Next WMO model to upload
|
||||
size_t wmoDoodadIndex = 0; // Next WMO doodad to upload
|
||||
|
||||
// Accumulated results (built up across phases)
|
||||
std::vector<uint32_t> m2InstanceIds;
|
||||
std::vector<uint32_t> wmoInstanceIds;
|
||||
std::vector<uint32_t> tileUniqueIds;
|
||||
std::vector<uint32_t> tileWmoUniqueIds;
|
||||
std::unordered_set<uint32_t> uploadedM2ModelIds;
|
||||
};
|
||||
|
||||
/**
|
||||
* Terrain manager for multi-tile terrain streaming
|
||||
*
|
||||
|
|
@ -254,8 +219,8 @@ public:
|
|||
int getLoadedTileCount() const { return static_cast<int>(loadedTiles.size()); }
|
||||
int getPendingTileCount() const { return static_cast<int>(pendingTiles.size()); }
|
||||
int getReadyQueueCount() const { return static_cast<int>(readyQueue.size()); }
|
||||
/** Total unfinished tiles (worker threads + ready queue + finalizing) */
|
||||
int getRemainingTileCount() const { return static_cast<int>(pendingTiles.size() + readyQueue.size() + finalizingTiles_.size()); }
|
||||
/** Total unfinished tiles (worker threads + ready queue) */
|
||||
int getRemainingTileCount() const { return static_cast<int>(pendingTiles.size() + readyQueue.size()); }
|
||||
TileCoord getCurrentTile() const { return currentTile; }
|
||||
|
||||
/** Process all ready tiles immediately (use during loading screens) */
|
||||
|
|
@ -289,10 +254,9 @@ private:
|
|||
std::shared_ptr<PendingTile> prepareTile(int x, int y);
|
||||
|
||||
/**
|
||||
* Advance incremental finalization of a tile (one bounded unit of work).
|
||||
* Returns true when the tile is fully finalized (phase == DONE).
|
||||
* Main thread: upload prepared tile data to GPU
|
||||
*/
|
||||
bool advanceFinalization(FinalizingTile& ft);
|
||||
void finalizeTile(const std::shared_ptr<PendingTile>& pending);
|
||||
|
||||
/**
|
||||
* Background worker thread loop
|
||||
|
|
@ -377,8 +341,16 @@ private:
|
|||
// Dedup set for WMO placements across tile boundaries (prevents rendering Stormwind 16x)
|
||||
std::unordered_set<uint32_t> placedWmoIds;
|
||||
|
||||
// Tiles currently being incrementally finalized across frames
|
||||
std::deque<FinalizingTile> finalizingTiles_;
|
||||
// Progressive M2 upload queue (spread heavy uploads across frames)
|
||||
struct PendingM2Upload {
|
||||
uint32_t modelId;
|
||||
pipeline::M2Model model;
|
||||
std::string path;
|
||||
};
|
||||
std::queue<PendingM2Upload> m2UploadQueue_;
|
||||
static constexpr int MAX_M2_UPLOADS_PER_FRAME = 5; // Upload up to 5 models per frame
|
||||
|
||||
void processM2UploadQueue();
|
||||
|
||||
struct GroundEffectEntry {
|
||||
std::array<uint32_t, 4> doodadIds{{0, 0, 0, 0}};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue