small bug in clampedlerp not updating the local lambda value to the clamped one + added some constness

This commit is contained in:
T.Alderighi 2018-11-12 14:31:27 +01:00
parent 91947c0f7e
commit 6243f9a8ac
1 changed files with 5 additions and 5 deletions

View File

@ -173,7 +173,7 @@ namespace math {
#endif
template <class SCALAR>
inline SCALAR Clamp( const SCALAR & val, const SCALAR& minval, const SCALAR& maxval)
inline SCALAR Clamp(const SCALAR & val, const SCALAR& minval, const SCALAR& maxval)
{
if(val < minval) return minval;
if(val > maxval) return maxval;
@ -181,16 +181,16 @@ inline SCALAR Clamp( const SCALAR & val, const SCALAR& minval, const SCALAR& ma
}
template <class SCALAR>
inline SCALAR Lerp(SCALAR a, SCALAR b, SCALAR lambda)
inline SCALAR Lerp(const SCALAR a, const SCALAR b, const SCALAR lambda)
{
return a * lambda + (1-lambda) * b;
}
template <class SCALAR>
inline SCALAR ClampedLerp(SCALAR a, SCALAR b, SCALAR lambda)
inline SCALAR ClampedLerp(const SCALAR a, const SCALAR b, const SCALAR lambda)
{
math::Clamp(lambda, (SCALAR)0, (SCALAR)1);
return a * lambda + (1-lambda) * b;
const clampedLambda = math::Clamp(lambda, (SCALAR)0, (SCALAR)1);
return a * clampedLambda + ((SCALAR)1-clampedLambda) * b;
}