Merge branch 'convert_camera_settings' into 'master'

Use settings values for Camera settings (#6876)

See merge request OpenMW/openmw!3041
simplify_debugging
psi29a 2 years ago
commit 6f8c152487

@ -93,8 +93,7 @@ namespace
return Constants::CellGridRadius; return Constants::CellGridRadius;
const int maxLocalViewingDistance const int maxLocalViewingDistance
= std::max(Settings::Manager::getInt("max local viewing distance", "Map"), Constants::CellGridRadius); = std::max(Settings::Manager::getInt("max local viewing distance", "Map"), Constants::CellGridRadius);
const int viewingDistanceInCells const int viewingDistanceInCells = Settings::camera().mViewingDistance / Constants::CellSizeInUnits;
= Settings::Manager::getFloat("viewing distance", "Camera") / Constants::CellSizeInUnits;
return std::clamp(viewingDistanceInCells, Constants::CellGridRadius, maxLocalViewingDistance); return std::clamp(viewingDistanceInCells, Constants::CellGridRadius, maxLocalViewingDistance);
} }
} }

@ -2,7 +2,7 @@
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/lua/utilpackage.hpp> #include <components/lua/utilpackage.hpp>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -82,17 +82,13 @@ namespace MWLua
api["getCollisionType"] = [camera]() { return camera->getCollisionType(); }; api["getCollisionType"] = [camera]() { return camera->getCollisionType(); };
api["setCollisionType"] = [camera](int collisionType) { camera->setCollisionType(collisionType); }; api["setCollisionType"] = [camera](int collisionType) { camera->setCollisionType(collisionType); };
api["getBaseFieldOfView"] = []() { api["getBaseFieldOfView"] = [] { return osg::DegreesToRadians(Settings::camera().mFieldOfView); };
return osg::DegreesToRadians(
std::clamp(Settings::Manager::getFloat("field of view", "Camera"), 1.f, 179.f));
};
api["getFieldOfView"] api["getFieldOfView"]
= [renderingManager]() { return osg::DegreesToRadians(renderingManager->getFieldOfView()); }; = [renderingManager]() { return osg::DegreesToRadians(renderingManager->getFieldOfView()); };
api["setFieldOfView"] api["setFieldOfView"]
= [renderingManager](float v) { renderingManager->setFieldOfView(osg::RadiansToDegrees(v)); }; = [renderingManager](float v) { renderingManager->setFieldOfView(osg::RadiansToDegrees(v)); };
api["getBaseViewDistance"] api["getBaseViewDistance"] = [] { return Settings::camera().mViewingDistance.get(); };
= []() { return std::max(0.f, Settings::Manager::getFloat("viewing distance", "Camera")); };
api["getViewDistance"] = [renderingManager]() { return renderingManager->getViewDistance(); }; api["getViewDistance"] = [renderingManager]() { return renderingManager->getViewDistance(); };
api["setViewDistance"] = [renderingManager](float d) { renderingManager->setViewDistance(d, true); }; api["setViewDistance"] = [renderingManager](float d) { renderingManager->setViewDistance(d, true); };

@ -31,7 +31,7 @@
#include <components/shader/removedalphafunc.hpp> #include <components/shader/removedalphafunc.hpp>
#include <components/shader/shadermanager.hpp> #include <components/shader/shadermanager.hpp>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
#include <components/sceneutil/cullsafeboundsvisitor.hpp> #include <components/sceneutil/cullsafeboundsvisitor.hpp>
#include <components/sceneutil/depth.hpp> #include <components/sceneutil/depth.hpp>
@ -315,13 +315,12 @@ namespace MWRender
, mNightEyeFactor(0.f) , mNightEyeFactor(0.f)
// TODO: Near clip should not need to be bounded like this, but too small values break OSG shadow calculations // TODO: Near clip should not need to be bounded like this, but too small values break OSG shadow calculations
// CPU-side. See issue: #6072 // CPU-side. See issue: #6072
, mNearClip(std::max(0.005f, Settings::Manager::getFloat("near clip", "Camera"))) , mNearClip(Settings::camera().mNearClip)
, mViewDistance(Settings::Manager::getFloat("viewing distance", "Camera")) , mViewDistance(Settings::camera().mViewingDistance)
, mFieldOfViewOverridden(false) , mFieldOfViewOverridden(false)
, mFieldOfViewOverride(0.f) , mFieldOfViewOverride(0.f)
, mFieldOfView(std::clamp(Settings::Manager::getFloat("field of view", "Camera"), 1.f, 179.f)) , mFieldOfView(Settings::camera().mFieldOfView)
, mFirstPersonFieldOfView( , mFirstPersonFieldOfView(Settings::camera().mFirstPersonFieldOfView)
std::clamp(Settings::Manager::getFloat("first person field of view", "Camera"), 1.f, 179.f))
{ {
bool reverseZ = SceneUtil::AutoDepth::isReversed(); bool reverseZ = SceneUtil::AutoDepth::isReversed();
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString( auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(
@ -565,12 +564,11 @@ namespace MWRender
osg::Camera::CullingMode cullingMode = osg::Camera::DEFAULT_CULLING | osg::Camera::FAR_PLANE_CULLING; osg::Camera::CullingMode cullingMode = osg::Camera::DEFAULT_CULLING | osg::Camera::FAR_PLANE_CULLING;
if (!Settings::Manager::getBool("small feature culling", "Camera")) if (!Settings::camera().mSmallFeatureCulling)
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING); cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
else else
{ {
mViewer->getCamera()->setSmallFeatureCullingPixelSize( mViewer->getCamera()->setSmallFeatureCullingPixelSize(Settings::camera().mSmallFeatureCullingPixelSize);
Settings::Manager::getFloat("small feature culling pixel size", "Camera"));
cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING; cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING;
} }
@ -1365,7 +1363,7 @@ namespace MWRender
{ {
if (it->first == "Camera" && it->second == "field of view") if (it->first == "Camera" && it->second == "field of view")
{ {
mFieldOfView = Settings::Manager::getFloat("field of view", "Camera"); mFieldOfView = Settings::camera().mFieldOfView;
updateProjection = true; updateProjection = true;
} }
else if (it->first == "Video" && (it->second == "resolution x" || it->second == "resolution y")) else if (it->first == "Video" && (it->second == "resolution x" || it->second == "resolution y"))
@ -1374,7 +1372,7 @@ namespace MWRender
} }
else if (it->first == "Camera" && it->second == "viewing distance") else if (it->first == "Camera" && it->second == "viewing distance")
{ {
setViewDistance(Settings::Manager::getFloat("viewing distance", "Camera")); setViewDistance(Settings::camera().mViewingDistance);
} }
else if (it->first == "General" else if (it->first == "General"
&& (it->second == "texture filter" || it->second == "texture mipmap" || it->second == "anisotropy")) && (it->second == "texture filter" || it->second == "texture mipmap" || it->second == "anisotropy"))

@ -13,12 +13,11 @@
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
#include <components/sceneutil/depth.hpp> #include <components/sceneutil/depth.hpp>
#include <components/settings/values.hpp>
#include <components/shader/shadermanager.hpp> #include <components/shader/shadermanager.hpp>
#include <components/stereo/multiview.hpp> #include <components/stereo/multiview.hpp>
#include <components/stereo/stereomanager.hpp> #include <components/stereo/stereomanager.hpp>
#include <components/settings/settings.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwgui/loadingscreen.hpp" #include "../mwgui/loadingscreen.hpp"
@ -341,8 +340,8 @@ namespace MWRender
void ScreenshotManager::makeCubemapScreenshot(osg::Image* image, int w, int h, const osg::Matrixd& cameraTransform) void ScreenshotManager::makeCubemapScreenshot(osg::Image* image, int w, int h, const osg::Matrixd& cameraTransform)
{ {
osg::ref_ptr<osg::Camera> rttCamera(new osg::Camera); osg::ref_ptr<osg::Camera> rttCamera(new osg::Camera);
float nearClip = Settings::Manager::getFloat("near clip", "Camera"); const float nearClip = Settings::camera().mNearClip;
float viewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); const float viewDistance = Settings::camera().mViewingDistance;
// each cubemap side sees 90 degrees // each cubemap side sees 90 degrees
if (SceneUtil::AutoDepth::isReversed()) if (SceneUtil::AutoDepth::isReversed())
rttCamera->setProjectionMatrix( rttCamera->setProjectionMatrix(

@ -3,7 +3,7 @@
#include <algorithm> #include <algorithm>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
namespace SceneUtil namespace SceneUtil
{ {
@ -113,7 +113,7 @@ namespace SceneUtil
{ {
bool enableReverseZ = false; bool enableReverseZ = false;
if (Settings::Manager::getBool("reverse z", "Camera")) if (Settings::camera().mReverseZ)
{ {
osg::ref_ptr<osg::GLExtensions> exts = osg::GLExtensions::Get(0, false); osg::ref_ptr<osg::GLExtensions> exts = osg::GLExtensions::Get(0, false);
if (exts && exts->isClipControlSupported) if (exts && exts->isClipControlSupported)

@ -23,7 +23,7 @@
#include <components/sceneutil/depth.hpp> #include <components/sceneutil/depth.hpp>
#include <components/sceneutil/statesetupdater.hpp> #include <components/sceneutil/statesetupdater.hpp>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
namespace Stereo namespace Stereo
{ {
@ -309,11 +309,8 @@ namespace Stereo
void Manager::update() void Manager::update()
{ {
double near_ = 1.f; const double near_ = Settings::camera().mNearClip;
double far_ = 10000.f; const double far_ = Settings::camera().mViewingDistance;
near_ = Settings::Manager::getFloat("near clip", "Camera");
far_ = Settings::Manager::getFloat("viewing distance", "Camera");
if (mUpdateViewCallback) if (mUpdateViewCallback)
{ {

Loading…
Cancel
Save