diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 7ac80ba4..c26c0b51 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -200,8 +200,6 @@ namespace detail "'sign' only accept signed inputs"); return detail::compute_sign::is_iec559>::call(x); - - //return vecType(glm::lessThan(vecType(0), x)) - vecType(glm::lessThan(x, vecType(0))); } // floor @@ -506,7 +504,7 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'smoothstep' only accept floating-point inputs"); - genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1)); + genType const tmp(clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1))); return tmp * tmp * (genType(3) - genType(2) * tmp); } @@ -515,7 +513,7 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'smoothstep' only accept floating-point inputs"); - vecType tmp = clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1)); + vecType const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1))); return tmp * tmp * (static_cast(3) - static_cast(2) * tmp); } @@ -524,32 +522,36 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'smoothstep' only accept floating-point inputs"); - vecType tmp = clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1)); + vecType const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1))); return tmp * tmp * (static_cast(3) - static_cast(2) * tmp); } // TODO: Not working on MinGW... - template - GLM_FUNC_QUALIFIER bool isnan(genType x) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); +# if GLM_HAS_CXX11_STL + usign std::isnan; +# else + template + GLM_FUNC_QUALIFIER bool isnan(genType x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); -# if GLM_LANG & GLM_LANG_CXX11_FLAG - return std::isnan(x); -# elif GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_INTEL) - return _isnan(x) != 0; -# elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG) -# if GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L +# if GLM_LANG & GLM_LANG_CXX11_FLAG + return std::isnan(x); +# elif GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_INTEL) return _isnan(x) != 0; +# elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG) +# if GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L + return _isnan(x) != 0; +# else + return std::isnan(x); +# endif +# elif GLM_COMPILER & GLM_COMPILER_CUDA + return isnan(x) != 0; # else return std::isnan(x); # endif -# elif GLM_COMPILER & GLM_COMPILER_CUDA - return isnan(x) != 0; -# else - return std::isnan(x); -# endif - } + } +# endif template class vecType> GLM_FUNC_QUALIFIER vecType isnan(vecType const & x) @@ -559,28 +561,32 @@ namespace detail return detail::functor1::call(isnan, x); } - template - GLM_FUNC_QUALIFIER bool isinf(genType x) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isinf' only accept floating-point inputs"); +# if GLM_HAS_CXX11_STL + using std::isinf; +# else + template + GLM_FUNC_QUALIFIER bool isinf(genType x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isinf' only accept floating-point inputs"); -# if(GLM_LANG & GLM_LANG_CXX11_FLAG) - return std::isinf(x); -# elif(GLM_COMPILER & (GLM_COMPILER_INTEL | GLM_COMPILER_VC)) - return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; -# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) -# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L) - return _isinf(x) != 0; +# if(GLM_LANG & GLM_LANG_CXX11_FLAG) + return std::isinf(x); +# elif(GLM_COMPILER & (GLM_COMPILER_INTEL | GLM_COMPILER_VC)) + return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; +# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L) + return _isinf(x) != 0; +# else + return std::isinf(x); +# endif +# elif(GLM_COMPILER & GLM_COMPILER_CUDA) + // http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE_g13431dd2b40b51f9139cbb7f50c18fab.html#g13431dd2b40b51f9139cbb7f50c18fab + return isinf(double(x)) != 0; # else return std::isinf(x); # endif -# elif(GLM_COMPILER & GLM_COMPILER_CUDA) - // http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE_g13431dd2b40b51f9139cbb7f50c18fab.html#g13431dd2b40b51f9139cbb7f50c18fab - return isinf(double(x)) != 0; -# else - return std::isinf(x); -# endif } +# endif template class vecType> GLM_FUNC_QUALIFIER vecType isinf(vecType const & x) diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index 462c2d26..3da09f63 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -174,12 +174,9 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' only accept floating-point inputs"); - genType dotValue = dot(N, I); - genType k = static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue); - if(k < static_cast(0)) - return static_cast(0); - else - return eta * I - (eta * dotValue + sqrt(k)) * N; + genType const dotValue(dot(N, I)); + genType const k(static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue)); + return (eta * I - (eta * dotValue + sqrt(k)) * N) * static_cast(k >= static_cast(0)); } template class vecType> @@ -187,11 +184,8 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' only accept floating-point inputs"); - T dotValue = dot(N, I); - T k = static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue); - if(k < static_cast(0)) - return vecType(0); - else - return eta * I - (eta * dotValue + std::sqrt(k)) * N; + T const dotValue(dot(N, I)); + T const k(static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue)); + return (eta * I - (eta * dotValue + std::sqrt(k)) * N) * static_cast(k >= static_cast(0)); } }//namespace glm