mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Throttle proactive tile streaming to reduce post-load hitching
Add 2-second cooldown timer before re-checking for unloaded tiles when workers are idle, preventing excessive streamTiles() calls that caused frame hitches right after world load.
This commit is contained in:
parent
c13dbf2198
commit
6cf08fbaa6
2 changed files with 15 additions and 10 deletions
|
|
@ -207,16 +207,20 @@ void TerrainManager::update(const Camera& camera, float deltaTime) {
|
|||
streamTiles();
|
||||
lastStreamTile = newTile;
|
||||
} else {
|
||||
// Proactive loading: when workers are idle, re-check for unloaded tiles
|
||||
// within range. This catches tiles that weren't queued on the initial
|
||||
// streamTiles pass (e.g. cache eviction, late-arriving ADT availability).
|
||||
bool workersIdle;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(queueMutex);
|
||||
workersIdle = loadQueue.empty();
|
||||
}
|
||||
if (workersIdle) {
|
||||
streamTiles();
|
||||
// Proactive loading: when workers are idle, periodically re-check for
|
||||
// unloaded tiles within range. Throttled to avoid hitching right after
|
||||
// world load when many tiles finalize simultaneously.
|
||||
proactiveStreamTimer_ += deltaTime;
|
||||
if (proactiveStreamTimer_ >= 2.0f) {
|
||||
proactiveStreamTimer_ = 0.0f;
|
||||
bool workersIdle;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(queueMutex);
|
||||
workersIdle = loadQueue.empty();
|
||||
}
|
||||
if (workersIdle) {
|
||||
streamTiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue