From 5efaa9817c6172f5be24a0efdff7f308db4e71f1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 7 Feb 2016 18:01:14 +0100 Subject: [PATCH] Add preloading settings --- apps/openmw/mwworld/scene.cpp | 16 +++++++++------- apps/openmw/mwworld/scene.hpp | 1 + files/settings-default.cfg | 6 ++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index b859efbf1..c788df234 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -193,11 +193,14 @@ namespace MWWorld void Scene::update (float duration, bool paused) { - mPreloadTimer += duration; - if (mPreloadTimer > 0.5f) + if (mPreloadEnabled) { - preloadCells(); - mPreloadTimer = 0.f; + mPreloadTimer += duration; + if (mPreloadTimer > 0.5f) + { + preloadCells(); + mPreloadTimer = 0.f; + } } mRendering.update (duration, paused); @@ -448,7 +451,8 @@ namespace MWWorld , mPreloadTimer(0.f) , mHalfGridSize(Settings::Manager::getInt("exterior cell load distance", "Cells")) , mCellLoadingThreshold(1024.f) - , mPreloadDistance(1000.f) + , mPreloadDistance(Settings::Manager::getInt("preload distance", "Cells")) + , mPreloadEnabled(Settings::Manager::getBool("preload enabled", "Cells")) { mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager())); } @@ -700,8 +704,6 @@ namespace MWWorld float dist = std::max(std::abs(thisCellCenterX - playerPos.x()), std::abs(thisCellCenterY - playerPos.y())); float loadDist = 8192/2 + 8192 - mCellLoadingThreshold + mPreloadDistance; - std::cout << cellX+dx << " " << cellY+dy << " dist " << dist << " need " << loadDist << std::endl; - if (dist < loadDist) mPreloader->preload(MWBase::Environment::get().getWorld()->getExterior(cellX+dx, cellY+dy), mRendering.getReferenceTime()); } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 36021819e..34e137e45 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -62,6 +62,7 @@ namespace MWWorld int mHalfGridSize; float mCellLoadingThreshold; float mPreloadDistance; + bool mPreloadEnabled; void insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener); diff --git a/files/settings-default.cfg b/files/settings-default.cfg index dddf1a29b..c03342600 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -37,6 +37,12 @@ first person field of view = 55.0 # dramatically affect performance, see documentation for details. exterior cell load distance = 1 +# Preload cells in a background thread +preload enabled = true + +# Preloading distance threshold +preload distance = 1000 + [Map] # Size of each exterior cell in pixels in the world map. (e.g. 12 to 24).