perf(editor): cache M2/WMO models across rebuilds, only clear instances

The editor's rebuildObjects path was destroying every cached model and
re-uploading it on every (debounced) change. Added M2Renderer::clearInstances
that drops only the instance list while keeping models loaded. Editor's
clearObjects switches to clearInstances (M2) + clearInstances (WMO),
and persistent path->modelId maps survive across rebuilds. clearTerrain
fully evicts when loading a new zone.
This commit is contained in:
Kelsi 2026-05-06 03:23:06 -07:00
parent f18976ced9
commit 5241bbd669
4 changed files with 45 additions and 5 deletions

View file

@ -377,6 +377,22 @@ void M2Renderer::clear() {
textureBudgetRejectWarnings_ = 0;
}
void M2Renderer::clearInstances() {
if (vkCtx_) vkDeviceWaitIdle(vkCtx_->getDevice());
for (auto& inst : instances) destroyInstanceBones(inst);
instances.clear();
spatialGrid.clear();
instanceIndexById.clear();
instanceDedupMap_.clear();
smokeInstanceIndices_.clear();
portalInstanceIndices_.clear();
animatedInstanceIndices_.clear();
particleOnlyInstanceIndices_.clear();
particleInstanceIndices_.clear();
smokeParticles.clear();
smokeEmitAccum = 0.0f;
}
void M2Renderer::setCollisionFocus(const glm::vec3& worldPos, float radius) {
collisionFocusEnabled = (radius > 0.0f);
collisionFocusPos = worldPos;