diff --git a/src/Math/TypeTraits.h b/src/Math/TypeTraits.h index 4a269fb24..6f7050df2 100644 --- a/src/Math/TypeTraits.h +++ b/src/Math/TypeTraits.h @@ -21,6 +21,16 @@ #include +/** @brief Precision when testing floats for equality */ +#ifndef FLOAT_EQUALITY_PRECISION +#define FLOAT_EQUALITY_PRECISION 1.0e-6 +#endif + +/** @brief Precision when testing doubles for equality */ +#ifndef DOUBLE_EQUALITY_PRECISION +#define DOUBLE_EQUALITY_PRECISION 1.0e-12 +#endif + namespace Magnum { namespace Math { /** @@ -99,10 +109,10 @@ template struct _TypeTraitsFloatingPoint { } }; template<> struct TypeTraits: public _TypeTraitsFloatingPoint { - constexpr inline static float epsilon() { return 1.0e-6f; } + constexpr inline static float epsilon() { return FLOAT_EQUALITY_PRECISION; } }; template<> struct TypeTraits: public _TypeTraitsFloatingPoint { - constexpr inline static double epsilon() { return 1.0e-12; } + constexpr inline static double epsilon() { return DOUBLE_EQUALITY_PRECISION; } }; #endif