From 20606a2aff2c4226355ba0e2e4721016ddb2204f Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 19 Jul 2017 16:43:29 +0200 Subject: [PATCH] Add 'prediction time' setting for cell/terrain pre-loading --- apps/openmw/mwworld/scene.cpp | 3 ++- apps/openmw/mwworld/scene.hpp | 1 + docs/source/reference/modding/settings/cells.rst | 13 +++++++++++++ files/settings-default.cfg | 3 +++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index bec053bc0..8da01cc4b 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -478,6 +478,7 @@ namespace MWWorld , mPreloadExteriorGrid(Settings::Manager::getBool("preload exterior grid", "Cells")) , mPreloadDoors(Settings::Manager::getBool("preload doors", "Cells")) , mPreloadFastTravel(Settings::Manager::getBool("preload fast travel", "Cells")) + , mPredictionTime(Settings::Manager::getFloat("prediction time", "Cells")) { mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain(), rendering.getLandManager())); mPreloader->setWorkQueue(mRendering.getWorkQueue()); @@ -685,7 +686,7 @@ namespace MWWorld const MWWorld::ConstPtr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); osg::Vec3f playerPos = player.getRefData().getPosition().asVec3(); osg::Vec3f moved = playerPos - mLastPlayerPos; - osg::Vec3f predictedPos = playerPos + moved / dt; + osg::Vec3f predictedPos = playerPos + moved / dt * mPredictionTime; if (mCurrentCell->isExterior()) exteriorPositions.push_back(predictedPos); diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 586ac4f67..e2fac6438 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -67,6 +67,7 @@ namespace MWWorld bool mPreloadExteriorGrid; bool mPreloadDoors; bool mPreloadFastTravel; + float mPredictionTime; osg::Vec3f mLastPlayerPos; diff --git a/docs/source/reference/modding/settings/cells.rst b/docs/source/reference/modding/settings/cells.rst index bbde2fc32..d2e7cf5be 100644 --- a/docs/source/reference/modding/settings/cells.rst +++ b/docs/source/reference/modding/settings/cells.rst @@ -155,6 +155,19 @@ preload cell expiry delay The amount of time (in seconds) that a preloaded cell will stay in cache after it is no longer referenced or required, for example, after the player has moved away from a door without entering it. +prediction time +--------------- + +:Type: floating point +:Range: >=0 +:Default: 1 + +The amount of time (in seconds) in the future to predict the player position for. This predicted position is used to preload any cells and/or distant terrain required at that position. + +This setting will only have an effect if 'preload enabled' is set or the 'distant terrain' in the Terrain section is set. + +Increasing this setting from its default may help if your computer/hard disk is too slow to preload in time and you see loading screens and/or lag spikes. + cache expiry delay ------------------ diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 9c3667a6e..40c1ed099 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -73,6 +73,9 @@ preload cell cache max = 20 # How long to keep preloaded cells in cache after they're no longer referenced/required (in seconds) preload cell expiry delay = 5 +# The predicted position of the player N seconds in the future will be used for preloading cells and distant terrain +prediction time = 1 + # How long to keep models/textures/collision shapes in cache after they're no longer referenced/required (in seconds) cache expiry delay = 5