Apply runtime changes to field of view & view distance

c++11
scrawl 10 years ago
parent b7258c8d23
commit 3e86dd7df0

@ -128,8 +128,10 @@ namespace MWRender
osg::Camera::CullingMode cullingMode = osg::Camera::DEFAULT_CULLING|osg::Camera::FAR_PLANE_CULLING;
// for consistent benchmarks against the ogre branch. remove later
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
if (!Settings::Manager::getBool("small feature culling", "Viewing distance"))
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
else
cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING;
viewer.getCamera()->setCullingMode( cullingMode );
@ -137,13 +139,8 @@ namespace MWRender
mViewer.getCamera()->setCullingMode(cullingMode);
mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance");
double fovy, aspect, zNear, zFar;
mViewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
fovy = 55.f;
zNear = 5.f;
zFar = mViewDistance;
mViewer.getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
mFieldOfView = Settings::Manager::getFloat("field of view", "General");
updateProjectionMatrix();
}
RenderingManager::~RenderingManager()
@ -325,4 +322,31 @@ namespace MWRender
//mWater->addEmitter(ptr);
}
void RenderingManager::updateProjectionMatrix()
{
double fovy, aspect, zNear, zFar;
mViewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
fovy = mFieldOfView;
zNear = 5.f;
zFar = mViewDistance;
mViewer.getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
}
void RenderingManager::processChangedSettings(const Settings::CategorySettingVector &changed)
{
for (Settings::CategorySettingVector::const_iterator it = changed.begin(); it != changed.end(); ++it)
{
if (it->first == "General" && it->second == "field of view")
{
mFieldOfView = Settings::Manager::getFloat("field of view", "General");
updateProjectionMatrix();
}
else if (it->first == "Viewing distance" && it->second == "viewing distance")
{
mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance");
updateProjectionMatrix();
}
}
}
}

@ -4,6 +4,8 @@
#include <osg/ref_ptr>
#include <osg/Light>
#include <components/settings/settings.hpp>
#include "objects.hpp"
#include "renderinginterface.hpp"
@ -93,7 +95,11 @@ namespace MWRender
void setupPlayer(const MWWorld::Ptr& player);
void renderPlayer(const MWWorld::Ptr& player);
void processChangedSettings(const Settings::CategorySettingVector& settings);
private:
void updateProjectionMatrix();
osgViewer::Viewer& mViewer;
osg::ref_ptr<osg::Group> mRootNode;
osg::ref_ptr<osg::Group> mLightRoot;
@ -111,6 +117,7 @@ namespace MWRender
osg::ref_ptr<StateUpdater> mStateUpdater;
float mViewDistance;
float mFieldOfView;
void operator = (const RenderingManager&);
RenderingManager(const RenderingManager&);

@ -1971,7 +1971,7 @@ namespace MWWorld
void World::processChangedSettings(const Settings::CategorySettingVector& settings)
{
//mRendering->processChangedSettings(settings);
mRendering->processChangedSettings(settings);
}
bool World::isFlying(const MWWorld::Ptr &ptr) const

@ -132,6 +132,9 @@ fog start factor = 0.5
# Distance at which fog ends (proportional to viewing distance)
fog end factor = 1.0
# Culling of objects smaller than a pixel
small feature culling = true
[Terrain]
distant land = false

Loading…
Cancel
Save