1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 04:20:29 +00:00

Do not update doors markers at each frame, only when needed

This commit is contained in:
Cédric Mocquillon 2021-08-12 22:06:21 +02:00
parent ee1ec53cd9
commit b0b60b05b8
2 changed files with 18 additions and 1 deletions

View File

@ -192,6 +192,7 @@ namespace MWGui
, mMarkerUpdateTimer(0.0f)
, mLastDirectionX(0.0f)
, mLastDirectionY(0.0f)
, mNeedDoorMarkersUpdate(false)
{
mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers);
}
@ -440,6 +441,10 @@ namespace MWGui
}
}
// Delay the door markers update until scripts have been given a chance to run.
// If we don't do this, door markers that should be disabled will still appear on the map.
mNeedDoorMarkersUpdate = true;
for (MyGUI::Widget* widget : currentDoorMarkersWidgets())
widget->setCoord(getMarkerCoordinates(widget, 8));
@ -544,7 +549,11 @@ namespace MWGui
void LocalMapBase::onFrame(float dt)
{
updateDoorMarkers();
if (mNeedDoorMarkersUpdate)
{
updateDoorMarkers();
mNeedDoorMarkersUpdate = false;
}
mMarkerUpdateTimer += dt;
@ -950,6 +959,9 @@ namespace MWGui
zoomOnCursor(zoomRatio);
return; //the zoom out is too big, we switch to the global map
}
if (zoomOut)
mNeedDoorMarkersUpdate = true;
}
zoomOnCursor(speedDiff);
}
@ -1172,7 +1184,10 @@ namespace MWGui
MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos;
if (!mGlobal)
{
mNeedDoorMarkersUpdate = true;
mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff );
}
else
mGlobalMap->setViewOffset( mGlobalMap->getViewOffset() + diff );

View File

@ -187,6 +187,8 @@ namespace MWGui
float mLastDirectionX;
float mLastDirectionY;
bool mNeedDoorMarkersUpdate;
private:
void updateDoorMarkers();
};