1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 16:29:55 +00:00

Resolve computed near plane issues with extremely high viewing distances.

This commit is contained in:
AnyOldName3 2018-05-29 00:52:43 +01:00
parent 759e6fb804
commit 50fdd0be99

View file

@ -927,6 +927,9 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
//OSG_NOTICE<<"maxZFar "<<maxZFar<<std::endl;
// Workaround for absurdly huge viewing distances where OSG would otherwise push the near plane out.
cv.setNearFarRatio(minZNear / maxZFar);
Frustum frustum(&cv, minZNear, maxZFar);
if (_debugHud)
_debugHud->setFrustumVertices(new osg::Vec3dArray(8, &frustum.corners[0]));
@ -2252,7 +2255,7 @@ bool MWShadowTechnique::adjustPerspectiveShadowMapCameraSettings(osgUtil::Render
double nearDist = frustum.frustumCenterLine.x() * nearPoint.x() + frustum.frustumCenterLine.y() * nearPoint.y() + frustum.frustumCenterLine.z() * nearPoint.z();
double farDist = -frustum.frustumCenterLine.x() * farPoint.x() - frustum.frustumCenterLine.y() * farPoint.y() - frustum.frustumCenterLine.z() * farPoint.z();
convexHull.clip(osg::Plane(frustum.frustumCenterLine, -nearDist));
convexHull.clip(osg::Plane(-frustum.frustumCenterLine, -farDist));