From c2131e7c31cb331ce8c9bfe48d26fcb2d4a2bbda Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 24 May 2015 02:34:20 +0200 Subject: [PATCH] Make near clip distance configurable --- apps/openmw/mwrender/renderingmanager.cpp | 11 ++++++----- apps/openmw/mwrender/renderingmanager.hpp | 1 + files/mygui/openmw_settings_window.layout | 2 +- files/settings-default.cfg | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index af4e46f62..b8620d60b 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -132,7 +132,7 @@ namespace MWRender osg::Camera::CullingMode cullingMode = osg::Camera::DEFAULT_CULLING|osg::Camera::FAR_PLANE_CULLING; - if (!Settings::Manager::getBool("small feature culling", "Viewing distance")) + if (!Settings::Manager::getBool("small feature culling", "Camera")) cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING); else cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING; @@ -144,7 +144,8 @@ namespace MWRender mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor)); - mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance"); + mNearClip = Settings::Manager::getFloat("near clip", "Camera"); + mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); mFieldOfView = Settings::Manager::getFloat("field of view", "General"); updateProjectionMatrix(); } @@ -372,7 +373,7 @@ namespace MWRender double fovy, aspect, zNear, zFar; mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar); fovy = mFieldOfView; - zNear = 5.f; + zNear = mNearClip; zFar = mViewDistance; mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar); } @@ -401,9 +402,9 @@ namespace MWRender mFieldOfView = Settings::Manager::getFloat("field of view", "General"); updateProjectionMatrix(); } - else if (it->first == "Viewing distance" && it->second == "viewing distance") + else if (it->first == "Camera" && it->second == "viewing distance") { - mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance"); + mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); mStateUpdater->setFogEnd(mViewDistance); updateProjectionMatrix(); } diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 8a81aacd7..2978c9983 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -137,6 +137,7 @@ namespace MWRender osg::ref_ptr mStateUpdater; + float mNearClip; float mViewDistance; float mFieldOfView; diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 3fb4adf42..19e3bcf88 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -341,7 +341,7 @@ - + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 6653966cf..0581d7356 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -99,8 +99,9 @@ local map hud widget size = 256 [Cells] exterior grid size = 3 -[Viewing distance] -# Viewing distance at normal weather conditions +[Camera] +near clip = 5 + # The maximum distance with no pop-in will be: (see RenderingManager::configureFog) # viewing distance * view frustum factor <= cell size (8192) - loading threshold (1024) # view frustum factor takes into account that the view frustum end is a plane, so at the edges of the screen you can see further than you should be able to.