- use the standard library's 'clamp' function instead of our homegrown variant.

This commit is contained in:
Christoph Oelckers 2021-10-30 10:21:50 +02:00
parent 1d0aed219e
commit 75c8e0af7c
4 changed files with 4 additions and 16 deletions

View file

@ -32,7 +32,7 @@
**
*/
#include "templates.h"
#include "basics.h"
#include "renderstyle.h"
#include "c_cvars.h"

View file

@ -34,7 +34,7 @@
*/
#include "hw_ihwtexture.h"
#include "templates.h"
#include "basics.h"
#include "tarray.h"
#include "xs_Float.h"
@ -68,7 +68,7 @@ static void ResampleBoxPrecalc(TArray<BoxPrecalc>& boxes, int oldDim)
BoxPrecalc& precalc = boxes[dst];
precalc.boxStart = clamp<int>(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1);
precalc.boxEnd = clamp<int>(MAX<int>(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1);
precalc.boxEnd = clamp<int>(max<int>(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1);
}
}

View file

@ -105,3 +105,4 @@ enum EStateUseFlags
using std::min;
using std::max;
using std::clamp;

View file

@ -129,18 +129,5 @@ const T MAX (const T a, const T b)
return a > b ? a : b;
}
//==========================================================================
//
// clamp
//
// Clamps in to the range [min,max].
//==========================================================================
template<typename T, typename X, typename Y>
inline constexpr
T clamp (const T in, const X min, const Y max)
{
return in <= (T) min ? (T) min : in >= (T) max ? (T) max : in;
}
#endif //__TEMPLATES_H__