1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-17 10:21:11 +00:00

Merge branch 'ZoomableMapsIncreasesLoadingTimes' into 'master'

Zoomable maps increases loading times

Closes #6204

See merge request OpenMW/openmw!1106
This commit is contained in:
psi29a 2021-08-10 07:28:26 +00:00
commit eb3c50842d
3 changed files with 20 additions and 14 deletions

View File

@ -36,7 +36,7 @@ namespace
{ {
const int cellSize = Constants::CellSizeInUnits; const int cellSize = Constants::CellSizeInUnits;
constexpr float speed = 1.08; //the zoom speed, it should be greater than 1 constexpr float speed = 1.08f; //the zoom speed, it should be greater than 1
enum LocalMapWidgetDepth enum LocalMapWidgetDepth
{ {
@ -99,10 +99,9 @@ namespace
return Constants::CellGridRadius; return Constants::CellGridRadius;
if (!Settings::Manager::getBool("distant terrain", "Terrain")) if (!Settings::Manager::getBool("distant terrain", "Terrain"))
return Constants::CellGridRadius; return Constants::CellGridRadius;
const float localViewingDistanceCoef = Settings::Manager::getFloat("local viewing distance coef", "Map"); const int maxLocalViewingDistance = std::max(Settings::Manager::getInt("max local viewing distance", "Map"), Constants::CellGridRadius);
const int viewingDistance = Settings::Manager::getInt("viewing distance", "Camera"); const int viewingDistanceInCells = Settings::Manager::getFloat("viewing distance", "Camera") / Constants::CellSizeInUnits;
const int localViewingDistanceInCells = (viewingDistance * localViewingDistanceCoef) / double(Constants::CellSizeInUnits); return std::min(maxLocalViewingDistance, viewingDistanceInCells);
return std::max(Constants::CellGridRadius, localViewingDistanceInCells);
} }
} }
@ -791,14 +790,17 @@ namespace MWGui
getWidget(mEventBoxGlobal, "EventBoxGlobal"); getWidget(mEventBoxGlobal, "EventBoxGlobal");
mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
mEventBoxGlobal->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); const bool allowZooming = Settings::Manager::getBool("allow zooming", "Map");
if(allowZooming)
mEventBoxGlobal->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed);
mEventBoxGlobal->setDepth(Global_ExploreOverlayLayer); mEventBoxGlobal->setDepth(Global_ExploreOverlayLayer);
getWidget(mEventBoxLocal, "EventBoxLocal"); getWidget(mEventBoxLocal, "EventBoxLocal");
mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked); mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked);
mEventBoxLocal->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); if (allowZooming)
mEventBoxLocal->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed);
LocalMapBase::init(mLocalMap, mPlayerArrowLocal, getLocalViewingDistance()); LocalMapBase::init(mLocalMap, mPlayerArrowLocal, getLocalViewingDistance());

View File

@ -115,14 +115,18 @@ If this setting is true the user can zoom in/out on local and global map with th
This setting can be controlled in Advanced tab of the launcher. This setting can be controlled in Advanced tab of the launcher.
local viewing distance coef max local viewing distance
--------------------------- ---------------------------
:Type: float :Type: integer
:Range: > 0 and <= 1 :Range: > 0
:Default: 0.5 :Default: 10
This setting controls viewing distance on local map. It is the coefficient of the viewing distance viewable on the local map if 'distant terrain' is enabled otherwise you will see the default value (a 3x3 square centered on the player). This setting controls the viewing distance on local map when 'distant terrain' is enabled.
If this setting is greater than the viewing distance then only up to the viewing distance is used for local map, otherwise the viewing distance is used.
If view distance is changed in settings menu during the game, then viewable distance on the local map is not updated. If view distance is changed in settings menu during the game, then viewable distance on the local map is not updated.
.. warning::
Increasing this setting can increase cell load times,
because the localmap take a snapshot of each cell contained in a square of 2 x (max local viewing distance) + 1 square.
This setting can not be configured except by editing the settings configuration file. This setting can not be configured except by editing the settings configuration file.

View File

@ -205,8 +205,8 @@ global = false
# If true, allow zoom on local and global maps # If true, allow zoom on local and global maps
allow zooming = false allow zooming = false
# The local view distance coefficient (1.0 is full view distance if distant terrain is enabled) # The local view distance in number of cells (up to the view distance)
local viewing distance coef = 0.5 max local viewing distance = 10
[GUI] [GUI]