From bacaa1f7894ab87ffdf8de8ac68a7ea55be0fc92 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 9 Mar 2019 13:52:03 +0400 Subject: [PATCH] Get rid of C-style limits in the shadows code --- components/sceneutil/mwshadowtechnique.cpp | 62 +++++++++++----------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index 4125ebe7d..b9d8e4bd3 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -30,6 +30,8 @@ namespace { using namespace osgShadow; using namespace SceneUtil; +#define dbl_max std::numeric_limits::max() + ////////////////////////////////////////////////////////////////// // fragment shader // @@ -928,7 +930,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) viewProjectionMatrix(2,3)==0.0; double minZNear = 0.0; - double maxZFar = DBL_MAX; + double maxZFar = dbl_max; if (cachedNearFarMode==osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR) { @@ -1088,8 +1090,8 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) double yRange = (clsb._bb.yMax()-clsb._bb.yMin()); osg::Matrixd cornerConverter = osg::Matrixd::inverse(projectionMatrix) * osg::Matrixd::inverse(viewMatrix) * *cv.getModelViewMatrix(); - double minZ = DBL_MAX; - double maxZ = -DBL_MAX; + double minZ = dbl_max; + double maxZ = -dbl_max; clsb._bb._max[2] = 1.0; for (unsigned int i = 0; i < 8; i++) { @@ -1777,7 +1779,7 @@ bool MWShadowTechnique::computeShadowCameraSettings(Frustum& frustum, LightData& } else { - double zMax=-DBL_MAX; + double zMax=-dbl_max; OSG_INFO<<"lightDir = "<