Make near clip distance configurable

c++11
scrawl 10 years ago
parent c748ea7363
commit c2131e7c31

@ -132,7 +132,7 @@ 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", "Viewing distance")) if (!Settings::Manager::getBool("small feature culling", "Camera"))
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING); cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
else else
cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING; cullingMode |= osg::CullStack::SMALL_FEATURE_CULLING;
@ -144,7 +144,8 @@ namespace MWRender
mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor)); mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor));
mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance"); mNearClip = Settings::Manager::getFloat("near clip", "Camera");
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
mFieldOfView = Settings::Manager::getFloat("field of view", "General"); mFieldOfView = Settings::Manager::getFloat("field of view", "General");
updateProjectionMatrix(); updateProjectionMatrix();
} }
@ -372,7 +373,7 @@ namespace MWRender
double fovy, aspect, zNear, zFar; double fovy, aspect, zNear, zFar;
mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar); mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
fovy = mFieldOfView; fovy = mFieldOfView;
zNear = 5.f; zNear = mNearClip;
zFar = mViewDistance; zFar = mViewDistance;
mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar); mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
} }
@ -401,9 +402,9 @@ namespace MWRender
mFieldOfView = Settings::Manager::getFloat("field of view", "General"); mFieldOfView = Settings::Manager::getFloat("field of view", "General");
updateProjectionMatrix(); updateProjectionMatrix();
} }
else if (it->first == "Viewing distance" && it->second == "viewing distance") else if (it->first == "Camera" && it->second == "viewing distance")
{ {
mViewDistance = Settings::Manager::getFloat("viewing distance", "Viewing distance"); mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
mStateUpdater->setFogEnd(mViewDistance); mStateUpdater->setFogEnd(mViewDistance);
updateProjectionMatrix(); updateProjectionMatrix();
} }

@ -137,6 +137,7 @@ namespace MWRender
osg::ref_ptr<StateUpdater> mStateUpdater; osg::ref_ptr<StateUpdater> mStateUpdater;
float mNearClip;
float mViewDistance; float mViewDistance;
float mFieldOfView; float mFieldOfView;

@ -341,7 +341,7 @@
<Property key="Range" value="10000"/> <Property key="Range" value="10000"/>
<Property key="Page" value="300"/> <Property key="Page" value="300"/>
<UserString key="SettingType" value="Slider"/> <UserString key="SettingType" value="Slider"/>
<UserString key="SettingCategory" value="Viewing distance"/> <UserString key="SettingCategory" value="Camera"/>
<UserString key="SettingName" value="viewing distance"/> <UserString key="SettingName" value="viewing distance"/>
<UserString key="SettingValueType" value="Float"/> <UserString key="SettingValueType" value="Float"/>
<UserString key="SettingMin" value="2000"/> <UserString key="SettingMin" value="2000"/>

@ -99,8 +99,9 @@ local map hud widget size = 256
[Cells] [Cells]
exterior grid size = 3 exterior grid size = 3
[Viewing distance] [Camera]
# Viewing distance at normal weather conditions near clip = 5
# The maximum distance with no pop-in will be: (see RenderingManager::configureFog) # The maximum distance with no pop-in will be: (see RenderingManager::configureFog)
# viewing distance * view frustum factor <= cell size (8192) - loading threshold (1024) # viewing distance * view frustum factor <= cell size (8192) - loading threshold (1024)
# view frustum factor takes into account that the view frustum end is a plane, so at the edges of the screen you can see further than you should be able to. # view frustum factor takes into account that the view frustum end is a plane, so at the edges of the screen you can see further than you should be able to.

Loading…
Cancel
Save