- Code: Select all
`error: call of overloaded ‘Clamp(double&, double&, double&)’ is ambiguous`

I took a look at MathDefs.h and I feel like there are two big improvements that can be made.

1) Use templates

This:

- Code: Select all
`inline float Clamp(float value, float min, float max)`

{

if (value < min)

return min;

else if (value > max)

return max;

else

return value;

}

should be this:

- Code: Select all
`template <class T>`

inline T Clamp(T value, T min, T max)

{

if (value < min)

return min;

else if (value > max)

return max;

return value;

}

2) We should be using std::numeric_limits instead of trying to define our own epsilon, our own infinity etc.

This:

- Code: Select all
`inline bool Equals(float lhs, float rhs) { return lhs + M_EPSILON >= rhs && lhs - M_EPSILON <= rhs; }`

would be much better as:

- Code: Select all
`template <class T>`

bool Equals(T lhs, T rhs) { return lhs + std::numeric_limits<T>::epsilon >= rhs && lhs - std::numeric_limits<T>::epsilon <= rhs; }

that way these defines can be eliminated:

- Code: Select all
`static const int M_MIN_INT = 0x80000000;`

static const int M_MAX_INT = 0x7fffffff;

static const unsigned M_MIN_UNSIGNED = 0x00000000;

static const unsigned M_MAX_UNSIGNED = 0xffffffff;

static const float M_EPSILON = 0.000001f;

static const float M_LARGE_EPSILON = 0.00005f;

static const float M_LARGE_VALUE = 100000000.0f;

static const float M_INFINITY = (float)HUGE_VAL;

Can I apply these changes and make a PR, or are there objections?