1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-15 18:39:51 +00:00

Limit maximum FOV value

This commit is contained in:
Andrei Kortunov 2019-03-03 21:29:51 +04:00
parent 540709fdae
commit c6cb91ce61
2 changed files with 9 additions and 5 deletions

View File

@ -371,8 +371,10 @@ namespace MWRender
mNearClip = Settings::Manager::getFloat("near clip", "Camera"); mNearClip = Settings::Manager::getFloat("near clip", "Camera");
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera"); mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
mFieldOfView = Settings::Manager::getFloat("field of view", "Camera"); float fov = Settings::Manager::getFloat("field of view", "Camera");
mFirstPersonFieldOfView = Settings::Manager::getFloat("first person field of view", "Camera"); mFieldOfView = std::min(std::max(1.f, fov), 179.f);
float firstPersonFov = Settings::Manager::getFloat("first person field of view", "Camera");
mFirstPersonFieldOfView = std::min(std::max(1.f, firstPersonFov), 179.f);
mStateUpdater->setFogEnd(mViewDistance); mStateUpdater->setFogEnd(mViewDistance);
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("near", mNearClip)); mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("near", mNearClip));
@ -1200,7 +1202,9 @@ namespace MWRender
mUniformFar->set(mViewDistance); mUniformFar->set(mViewDistance);
// Since our fog is not radial yet, we should take FOV in account, otherwise terrain near viewing distance may disappear. // Since our fog is not radial yet, we should take FOV in account, otherwise terrain near viewing distance may disappear.
float distanceMult = std::cos(osg::DegreesToRadians(mFieldOfView)/2.f); // Limit FOV here just for sure, otherwise viewing distance can be too high.
fov = std::min(mFieldOfView, 140.f);
float distanceMult = std::cos(osg::DegreesToRadians(fov)/2.f);
mTerrain->setViewDistance(mViewDistance * (distanceMult ? 1.f/distanceMult : 1.f)); mTerrain->setViewDistance(mViewDistance * (distanceMult ? 1.f/distanceMult : 1.f));
} }

View File

@ -94,7 +94,7 @@ field of view
------------- -------------
:Type: floating point :Type: floating point
:Range: 0-360 :Range: 1-179
:Default: 55.0 :Default: 55.0
Sets the camera field of view in degrees. Recommended values range from 30 degrees to 110 degrees. Sets the camera field of view in degrees. Recommended values range from 30 degrees to 110 degrees.
@ -109,7 +109,7 @@ first person field of view
-------------------------- --------------------------
:Type: floating point :Type: floating point
:Range: 0-360 :Range: 1-179
:Default: 55.0 :Default: 55.0
This setting controls the field of view for first person meshes such as the player's hands and held objects. This setting controls the field of view for first person meshes such as the player's hands and held objects.