Commit bad0b246 authored by hybrid's avatar hybrid

Fixed lerp usage for non-scalars. Added refs to allow max and min to be used...

Fixed lerp usage for non-scalars. Added refs to allow max and min to be used for other ordered structures.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@905 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a1e7be33
...@@ -24,7 +24,6 @@ namespace irr ...@@ -24,7 +24,6 @@ namespace irr
namespace core namespace core
{ {
//! Rounding error constant often used when comparing f32 values. //! Rounding error constant often used when comparing f32 values.
#ifdef IRRLICHT_FAST_MATH #ifdef IRRLICHT_FAST_MATH
...@@ -64,50 +63,50 @@ namespace core ...@@ -64,50 +63,50 @@ namespace core
//! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems) //! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
template<class T> template<class T>
inline const T min_(const T a, const T b) inline const T& min_(const T& a, const T& b)
{ {
return a < b ? a : b; return a < b ? a : b;
} }
//! returns minimum of three values. Own implementation to get rid of the STL (VS6 problems) //! returns minimum of three values. Own implementation to get rid of the STL (VS6 problems)
template<class T> template<class T>
inline const T min_(const T a, const T b, const T c) inline const T& min_(const T& a, const T& b, const T& c)
{ {
return a < b ? min_(a, c) : min_(b, c); return a < b ? min_(a, c) : min_(b, c);
} }
//! returns maximum of two values. Own implementation to get rid of the STL (VS6 problems) //! returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)
template<class T> template<class T>
inline T max_(const T a, const T b) inline const T& max_(const T& a, const T& b)
{ {
return a < b ? b : a; return a < b ? b : a;
} }
//! returns minimum of three values. Own implementation to get rid of the STL (VS6 problems) //! returns minimum of three values. Own implementation to get rid of the STL (VS6 problems)
template<class T> template<class T>
inline const T max_(const T a, const T b, const T c) inline const T& max_(const T& a, const T& b, const T& c)
{ {
return a < b ? max_(b, c) : max_(a, c); return a < b ? max_(b, c) : max_(a, c);
} }
//! returns abs of two values. Own implementation to get rid of STL (VS6 problems) //! returns abs of two values. Own implementation to get rid of STL (VS6 problems)
template<class T> template<class T>
inline T abs_(const T a) inline T abs_(const T& a)
{ {
return a < 0 ? -a : a; return a < (T)0 ? -a : a;
} }
//! returns linear interpolation of a and b with ratio t //! returns linear interpolation of a and b with ratio t
//! \return: a if t==0, b if t==1, and the linear interpolation else //! \return: a if t==0, b if t==1, and the linear interpolation else
template<class T> template<class T>
inline T lerp(const T a, const T b, const T t) inline T lerp(const T& a, const T& b, const f32 t)
{ {
return (a*(1-t)) + (b*t); return (a*(1.f-t)) + (b*t);
} }
//! clamps a value between low and high //! clamps a value between low and high
template <class T> template <class T>
inline const T clamp (const T value, const T low, const T high) inline const T clamp (const T& value, const T& low, const T& high)
{ {
return min_ (max_(value,low), high); return min_ (max_(value,low), high);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment