Browse Source

Math: move clamp() definition from Functions.h to Vector.h.

Need it for angle().
pull/433/head
Vladimír Vondruš 6 years ago
parent
commit
1c46bdb959
  1. 5
      src/Magnum/Math/Functions.h
  2. 3
      src/Magnum/Math/Vector.h

5
src/Magnum/Math/Functions.h

@ -318,9 +318,8 @@ set to @p max. Equivalent to:
<em>NaN</em>s passed in @p value parameter are propagated.
@see @ref min(), @ref max()
*/
template<class T> inline typename std::enable_if<IsScalar<T>::value, T>::type clamp(T value, T min, T max) {
return Math::min(Math::max(value, min), max);
}
/* defined in Vector.h */
template<class T> constexpr typename std::enable_if<IsScalar<T>::value, T>::type clamp(T value, T min, T max);
/** @overload */
template<std::size_t size, class T> inline Vector<size, T> clamp(const Vector<size, T>& value, const Vector<size, T>& min, const Vector<size, T>& max) {

3
src/Magnum/Math/Vector.h

@ -56,6 +56,9 @@ template<class T> constexpr typename std::enable_if<IsScalar<T>::value, T>::type
template<class T> constexpr typename std::enable_if<IsScalar<T>::value, T>::type max(T value, T max) {
return value < max ? max : value;
}
template<class T> constexpr typename std::enable_if<IsScalar<T>::value, T>::type clamp(T value, T min, T max) {
return Math::min(Math::max(value, min), max);
}
#endif
namespace Implementation {

Loading…
Cancel
Save