From 4f5bdbb4fb1246c7506001d40c84bde54506825a Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 18 May 2024 02:14:58 +0200 Subject: [PATCH] Remove recastmesh group for absent tile --- apps/openmw/mwrender/recastmesh.cpp | 18 +++++++++++++----- apps/openmw/mwrender/recastmesh.hpp | 2 -- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwrender/recastmesh.cpp b/apps/openmw/mwrender/recastmesh.cpp index 8edbc8568d..65e7c344d8 100644 --- a/apps/openmw/mwrender/recastmesh.cpp +++ b/apps/openmw/mwrender/recastmesh.cpp @@ -67,14 +67,22 @@ namespace MWRender ++it; } - for (const auto& tile : tiles) + for (const auto& [position, mesh] : tiles) { - if (mGroups.count(tile.first)) - continue; - const auto group = SceneUtil::createRecastMeshGroup(*tile.second, settings.mRecast); + const auto it = mGroups.find(position); + + if (it != mGroups.end()) + { + if (it->second.mVersion == mesh->getVersion()) + continue; + + mRootNode->removeChild(it->second.mValue); + } + + const auto group = SceneUtil::createRecastMeshGroup(*mesh, settings.mRecast); MWBase::Environment::get().getResourceSystem()->getSceneManager()->recreateShaders(group, "debug"); group->setNodeMask(Mask_Debug); - mGroups.emplace(tile.first, Group{ tile.second->getVersion(), group }); + mGroups.insert_or_assign(it, position, Group{ mesh->getVersion(), group }); mRootNode->addChild(group); } } diff --git a/apps/openmw/mwrender/recastmesh.hpp b/apps/openmw/mwrender/recastmesh.hpp index 2a45d67c6f..271f209684 100644 --- a/apps/openmw/mwrender/recastmesh.hpp +++ b/apps/openmw/mwrender/recastmesh.hpp @@ -6,8 +6,6 @@ #include -#include - namespace osg { class Group;