From 50601b773331e8d48ac596e619e7037ed3506d6c Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 11 Sep 2025 17:04:07 +0200 Subject: [PATCH] Remove rendered segments outside the map grid again --- apps/openmw/mwgui/mapwindow.cpp | 16 ++++++++++++++-- apps/openmw/mwrender/localmap.cpp | 10 +++++++--- apps/openmw/mwrender/localmap.hpp | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index ab35f3e25c..fa2c03e9be 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -390,7 +390,7 @@ namespace MWGui const int x = cell.getGridX(); const int y = cell.getGridY(); - MyGUI::IntSize oldSize{ mGrid.width(), mGrid.height() }; + const MyGUI::IntRect prevGrid = mGrid; if (cell.isExterior()) { @@ -423,6 +423,18 @@ namespace MWGui ++it; } } + + if (mActiveCell && mActiveCell->isExterior()) + { + for (int cx = prevGrid.left; cx <= prevGrid.right; ++cx) + { + for (int cy = prevGrid.top; cy <= prevGrid.bottom; ++cy) + { + if (!mGrid.inside({ cx, cy })) + mLocalMapRender->removeExteriorCell(cx, cy); + } + } + } } else { @@ -470,7 +482,7 @@ namespace MWGui resetEntry(mMaps[i], false, nullptr); } - if (oldSize != MyGUI::IntSize{ mGrid.width(), mGrid.height() }) + if (prevGrid.width() != mGrid.width() || prevGrid.height() != mGrid.height()) setCanvasSize(mLocalMap, mGrid, getWidgetSize()); // Delay the door markers update until scripts have been given a chance to run. diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index d12b4480f2..c5d36a65a5 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -206,13 +206,16 @@ namespace MWRender std::make_pair(cell->getCell()->getGridX(), cell->getCell()->getGridY()), MapSegment{}); } + void LocalMap::removeExteriorCell(int x, int y) + { + mExteriorSegments.erase({ x, y }); + } + void LocalMap::removeCell(MWWorld::CellStore* cell) { saveFogOfWar(cell); - if (cell->isExterior()) - mExteriorSegments.erase({ cell->getCell()->getGridX(), cell->getCell()->getGridY() }); - else + if (!cell->isExterior()) mInteriorSegments.clear(); } @@ -301,6 +304,7 @@ namespace MWRender return; mInterior = true; + mExteriorSegments.clear(); mBounds = bounds; diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index 650a34f655..af745376b4 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -55,6 +55,7 @@ namespace MWRender void requestMap(const MWWorld::CellStore* cell); void addCell(MWWorld::CellStore* cell); + void removeExteriorCell(int x, int y); void removeCell(MWWorld::CellStore* cell);