mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 21:45:33 +00:00
Use settings values for Camera settings
This commit is contained in:
parent
5b36ea0179
commit
5d5e6844d1
6 changed files with 21 additions and 32 deletions
|
@ -93,8 +93,7 @@ namespace
|
|||
return Constants::CellGridRadius;
|
||||
const int maxLocalViewingDistance
|
||||
= std::max(Settings::Manager::getInt("max local viewing distance", "Map"), Constants::CellGridRadius);
|
||||
const int viewingDistanceInCells
|
||||
= Settings::Manager::getFloat("viewing distance", "Camera") / Constants::CellSizeInUnits;
|
||||
const int viewingDistanceInCells = Settings::camera().mViewingDistance / Constants::CellSizeInUnits;
|
||||
return std::clamp(viewingDistanceInCells, Constants::CellGridRadius, maxLocalViewingDistance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <components/lua/luastate.hpp>
|
||||
#include <components/lua/utilpackage.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -82,17 +82,13 @@ namespace MWLua
|
|||
api["getCollisionType"] = [camera]() { return camera->getCollisionType(); };
|
||||
api["setCollisionType"] = [camera](int collisionType) { camera->setCollisionType(collisionType); };
|
||||
|
||||
api["getBaseFieldOfView"] = []() {
|
||||
return osg::DegreesToRadians(
|
||||
std::clamp(Settings::Manager::getFloat("field of view", "Camera"), 1.f, 179.f));
|
||||
};
|
||||
api["getBaseFieldOfView"] = [] { return osg::DegreesToRadians(Settings::camera().mFieldOfView); };
|
||||
api["getFieldOfView"]
|
||||
= [renderingManager]() { return osg::DegreesToRadians(renderingManager->getFieldOfView()); };
|
||||
api["setFieldOfView"]
|
||||
= [renderingManager](float v) { renderingManager->setFieldOfView(osg::RadiansToDegrees(v)); };
|
||||
|
||||
api["getBaseViewDistance"]
|
||||
= []() { return std::max(0.f, Settings::Manager::getFloat("viewing distance", "Camera")); };
|
||||
api["getBaseViewDistance"] = [] { return Settings::camera().mViewingDistance.get(); };
|
||||
api["getViewDistance"] = [renderingManager]() { return renderingManager->getViewDistance(); };
|
||||
api["setViewDistance"] = [renderingManager](float d) { renderingManager->setViewDistance(d, true); };
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <components/shader/removedalphafunc.hpp>
|
||||
#include <components/shader/shadermanager.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/sceneutil/cullsafeboundsvisitor.hpp>
|
||||
#include <components/sceneutil/depth.hpp>
|
||||
|
@ -315,13 +315,12 @@ namespace MWRender
|
|||
, mNightEyeFactor(0.f)
|
||||
// TODO: Near clip should not need to be bounded like this, but too small values break OSG shadow calculations
|
||||
// CPU-side. See issue: #6072
|
||||
, mNearClip(std::max(0.005f, Settings::Manager::getFloat("near clip", "Camera")))
|
||||
, mViewDistance(Settings::Manager::getFloat("viewing distance", "Camera"))
|
||||
, mNearClip(Settings::camera().mNearClip)
|
||||
, mViewDistance(Settings::camera().mViewingDistance)
|
||||
, mFieldOfViewOverridden(false)
|
||||
, mFieldOfViewOverride(0.f)
|
||||
, mFieldOfView(std::clamp(Settings::Manager::getFloat("field of view", "Camera"), 1.f, 179.f))
|
||||
, mFirstPersonFieldOfView(
|
||||
std::clamp(Settings::Manager::getFloat("first person field of view", "Camera"), 1.f, 179.f))
|
||||
, mFieldOfView(Settings::camera().mFieldOfView)
|
||||
, mFirstPersonFieldOfView(Settings::camera().mFirstPersonFieldOfView)
|
||||
{
|
||||
bool reverseZ = SceneUtil::AutoDepth::isReversed();
|
||||
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(
|
||||
|
@ -565,12 +564,11 @@ namespace MWRender
|
|||
|
||||
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);
|
||||
else
|
||||
{
|
||||
mViewer->getCamera()->setSmallFeatureCullingPixelSize(
|
||||
Settings::Manager::getFloat("small feature culling pixel size", "Camera"));
|
||||
mViewer->getCamera()->setSmallFeatureCullingPixelSize(Settings::camera().mSmallFeatureCullingPixelSize);
|
||||
cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING;
|
||||
}
|
||||
|
||||
|
@ -1365,7 +1363,7 @@ namespace MWRender
|
|||
{
|
||||
if (it->first == "Camera" && it->second == "field of view")
|
||||
{
|
||||
mFieldOfView = Settings::Manager::getFloat("field of view", "Camera");
|
||||
mFieldOfView = Settings::camera().mFieldOfView;
|
||||
updateProjection = true;
|
||||
}
|
||||
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")
|
||||
{
|
||||
setViewDistance(Settings::Manager::getFloat("viewing distance", "Camera"));
|
||||
setViewDistance(Settings::camera().mViewingDistance);
|
||||
}
|
||||
else if (it->first == "General"
|
||||
&& (it->second == "texture filter" || it->second == "texture mipmap" || it->second == "anisotropy"))
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
#include <components/resource/resourcesystem.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
#include <components/sceneutil/depth.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/shader/shadermanager.hpp>
|
||||
#include <components/stereo/multiview.hpp>
|
||||
#include <components/stereo/stereomanager.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.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)
|
||||
{
|
||||
osg::ref_ptr<osg::Camera> rttCamera(new osg::Camera);
|
||||
float nearClip = Settings::Manager::getFloat("near clip", "Camera");
|
||||
float viewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
|
||||
const float nearClip = Settings::camera().mNearClip;
|
||||
const float viewDistance = Settings::camera().mViewingDistance;
|
||||
// each cubemap side sees 90 degrees
|
||||
if (SceneUtil::AutoDepth::isReversed())
|
||||
rttCamera->setProjectionMatrix(
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace SceneUtil
|
|||
{
|
||||
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);
|
||||
if (exts && exts->isClipControlSupported)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <components/sceneutil/depth.hpp>
|
||||
#include <components/sceneutil/statesetupdater.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
namespace Stereo
|
||||
{
|
||||
|
@ -309,11 +309,8 @@ namespace Stereo
|
|||
|
||||
void Manager::update()
|
||||
{
|
||||
double near_ = 1.f;
|
||||
double far_ = 10000.f;
|
||||
|
||||
near_ = Settings::Manager::getFloat("near clip", "Camera");
|
||||
far_ = Settings::Manager::getFloat("viewing distance", "Camera");
|
||||
const double near_ = Settings::camera().mNearClip;
|
||||
const double far_ = Settings::camera().mViewingDistance;
|
||||
|
||||
if (mUpdateViewCallback)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue