forked from mirror/openmw-tes3mp
Apply runtime changes to field of view & view distance
This commit is contained in:
parent
b7258c8d23
commit
3e86dd7df0
4 changed files with 44 additions and 10 deletions
|
@ -128,8 +128,10 @@ 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;
|
||||||
|
|
||||||
// for consistent benchmarks against the ogre branch. remove later
|
if (!Settings::Manager::getBool("small feature culling", "Viewing distance"))
|
||||||
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
|
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
|
||||||
|
else
|
||||||
|
cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING;
|
||||||
|
|
||||||
viewer.getCamera()->setCullingMode( cullingMode );
|
viewer.getCamera()->setCullingMode( cullingMode );
|
||||||
|
|
||||||
|
@ -137,13 +139,8 @@ namespace MWRender
|
||||||
mViewer.getCamera()->setCullingMode(cullingMode);
|
mViewer.getCamera()->setCullingMode(cullingMode);
|
||||||
|
|
||||||
mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance");
|
mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance");
|
||||||
|
mFieldOfView = Settings::Manager::getFloat("field of view", "General");
|
||||||
double fovy, aspect, zNear, zFar;
|
updateProjectionMatrix();
|
||||||
mViewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
|
|
||||||
fovy = 55.f;
|
|
||||||
zNear = 5.f;
|
|
||||||
zFar = mViewDistance;
|
|
||||||
mViewer.getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingManager::~RenderingManager()
|
RenderingManager::~RenderingManager()
|
||||||
|
@ -325,4 +322,31 @@ namespace MWRender
|
||||||
//mWater->addEmitter(ptr);
|
//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/ref_ptr>
|
||||||
#include <osg/Light>
|
#include <osg/Light>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "objects.hpp"
|
#include "objects.hpp"
|
||||||
|
|
||||||
#include "renderinginterface.hpp"
|
#include "renderinginterface.hpp"
|
||||||
|
@ -93,7 +95,11 @@ namespace MWRender
|
||||||
void setupPlayer(const MWWorld::Ptr& player);
|
void setupPlayer(const MWWorld::Ptr& player);
|
||||||
void renderPlayer(const MWWorld::Ptr& player);
|
void renderPlayer(const MWWorld::Ptr& player);
|
||||||
|
|
||||||
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateProjectionMatrix();
|
||||||
|
|
||||||
osgViewer::Viewer& mViewer;
|
osgViewer::Viewer& mViewer;
|
||||||
osg::ref_ptr<osg::Group> mRootNode;
|
osg::ref_ptr<osg::Group> mRootNode;
|
||||||
osg::ref_ptr<osg::Group> mLightRoot;
|
osg::ref_ptr<osg::Group> mLightRoot;
|
||||||
|
@ -111,6 +117,7 @@ namespace MWRender
|
||||||
osg::ref_ptr<StateUpdater> mStateUpdater;
|
osg::ref_ptr<StateUpdater> mStateUpdater;
|
||||||
|
|
||||||
float mViewDistance;
|
float mViewDistance;
|
||||||
|
float mFieldOfView;
|
||||||
|
|
||||||
void operator = (const RenderingManager&);
|
void operator = (const RenderingManager&);
|
||||||
RenderingManager(const RenderingManager&);
|
RenderingManager(const RenderingManager&);
|
||||||
|
|
|
@ -1971,7 +1971,7 @@ namespace MWWorld
|
||||||
|
|
||||||
void World::processChangedSettings(const Settings::CategorySettingVector& settings)
|
void World::processChangedSettings(const Settings::CategorySettingVector& settings)
|
||||||
{
|
{
|
||||||
//mRendering->processChangedSettings(settings);
|
mRendering->processChangedSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::isFlying(const MWWorld::Ptr &ptr) const
|
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)
|
# Distance at which fog ends (proportional to viewing distance)
|
||||||
fog end factor = 1.0
|
fog end factor = 1.0
|
||||||
|
|
||||||
|
# Culling of objects smaller than a pixel
|
||||||
|
small feature culling = true
|
||||||
|
|
||||||
[Terrain]
|
[Terrain]
|
||||||
distant land = false
|
distant land = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue