From dce4cceb39ee70c0df7880047c67a5ad999e3a8f Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 5 Nov 2021 11:06:19 +0400 Subject: [PATCH 1/2] Support deleted CellRefs in groundcover (bug 6276) --- CHANGELOG.md | 1 + apps/openmw/mwrender/groundcover.cpp | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc23c39d92..0dea848d7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -235,6 +235,7 @@ Bug #6043: Actor can have torch missing when torch animation is played Bug #6047: Mouse bindings can be triggered during save loading Bug #6136: Game freezes when NPCs try to open doors that are about to be closed + Bug #6276: Deleted groundcover instances are not deleted in game Bug #6294: Game crashes with empty pathgrid Feature #390: 3rd person look "over the shoulder" Feature #832: OpenMW-CS: Handle deleted references diff --git a/apps/openmw/mwrender/groundcover.cpp b/apps/openmw/mwrender/groundcover.cpp index 2998ee509a..1cabf564e2 100644 --- a/apps/openmw/mwrender/groundcover.cpp +++ b/apps/openmw/mwrender/groundcover.cpp @@ -181,6 +181,8 @@ namespace MWRender void Groundcover::collectInstances(InstanceMap& instances, float size, const osg::Vec2f& center) { + if (mDensity <=0.f) return; + const MWWorld::ESMStore& worldStore = MWBase::Environment::get().getWorld()->getStore(); osg::Vec2f minBound = (center - osg::Vec2f(size/2.f, size/2.f)); osg::Vec2f maxBound = (center + osg::Vec2f(size/2.f, size/2.f)); @@ -195,6 +197,7 @@ namespace MWRender if (!cell) continue; calculator.reset(); + std::map refs; for (size_t i=0; imContextList.size(); ++i) { unsigned int index = cell->mContextList[i].index; @@ -206,18 +209,21 @@ namespace MWRender bool deleted = false; while(cell->getNextRef(esm[index], ref, deleted)) { - if (deleted) continue; - - if (!calculator.isInstanceEnabled()) continue; - if (!isInChunkBorders(ref, minBound, maxBound)) continue; - - std::string model = getGroundcoverModel(ref.mRefID, mGroundcoverStore, worldStore); - if (model.empty()) continue; - model = "meshes/" + model; + if (!deleted && refs.find(ref.mRefNum) == refs.end() && !calculator.isInstanceEnabled()) deleted = true; + if (!deleted && !isInChunkBorders(ref, minBound, maxBound)) deleted = true; - instances[model].emplace_back(std::move(ref)); + if (deleted) { refs.erase(ref.mRefNum); continue; } + refs[ref.mRefNum] = std::move(ref); } } + + for (auto& pair : refs) + { + ESM::CellRef& ref = pair.second; + const std::string& model = getGroundcoverModel(ref.mRefID, mGroundcoverStore, worldStore); + if (!model.empty()) + instances["meshes\\" + model].emplace_back(std::move(ref)); + } } } } From cca6029088397ec54e9b2fc0e86dfefcf56d1250 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 14 Nov 2021 11:08:05 +0400 Subject: [PATCH 2/2] Add missing changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dea848d7b..0d61907f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -235,6 +235,7 @@ Bug #6043: Actor can have torch missing when torch animation is played Bug #6047: Mouse bindings can be triggered during save loading Bug #6136: Game freezes when NPCs try to open doors that are about to be closed + Bug #6142: Groundcover plugins change cells flags Bug #6276: Deleted groundcover instances are not deleted in game Bug #6294: Game crashes with empty pathgrid Feature #390: 3rd person look "over the shoulder"