fix: add 60-second grace period to M2 model cleanup

Models that lose all instances are no longer immediately evicted from
GPU memory. Instead they get a 60-second grace period, preventing the
thrash cycle where GO models (barrels, chests, herbs) were evicted
every 5 seconds and re-loaded when the same object type respawned.
This commit is contained in:
Kelsi 2026-03-18 07:00:50 -07:00
parent 3c60ef8464
commit f78d885e13
2 changed files with 25 additions and 2 deletions

View file

@ -13,6 +13,7 @@
#include <string>
#include <optional>
#include <random>
#include <chrono>
#include <future>
namespace wowee {
@ -434,6 +435,9 @@ private:
void* glowVBMapped_ = nullptr;
std::unordered_map<uint32_t, M2ModelGPU> models;
// Grace period for model cleanup: track when a model first became instanceless.
// Models are only evicted after 60 seconds with no instances.
std::unordered_map<uint32_t, std::chrono::steady_clock::time_point> modelUnusedSince_;
std::vector<M2Instance> instances;
// O(1) dedup: key = (modelId, quantized x, quantized y, quantized z) → instanceId