stop stupid clamp asserts

This commit is contained in:
Ricardo Luís Vaz Silva 2025-06-30 23:20:07 -03:00
commit 54f1f5ad9d
3 changed files with 12 additions and 7 deletions

View file

@ -5,6 +5,8 @@
#include "bitmap.h"
#include "memarena.h"
#include "common/utility/basics.h"
#ifndef MAKE_ID
#ifndef __BIG_ENDIAN__
#define MAKE_ID(a,b,c,d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24)))
@ -13,11 +15,6 @@
#endif
#endif
using std::min;
using std::max;
using std::clamp;
class FImageSource;
using PrecacheInfo = TMap<int, std::pair<int, int>>;
extern FMemArena ImageArena;

View file

@ -68,4 +68,10 @@ const double M_PI = 3.14159265358979323846; // matches value in gcc v2 math.h
using std::min;
using std::max;
using std::clamp;
//using std::clamp;
template<typename T>
T clamp(T val, T minval, T maxval)
{
return std::max<T>(std::min<T>(val, maxval), minval);
}

View file

@ -46,6 +46,8 @@
#include <string.h>
#include <algorithm>
#include "common/utility/basics.h"
// this is needed to properly normalize angles. We cannot do that with compiler provided conversions because they differ too much
#include "xs_Float.h"
@ -1585,7 +1587,7 @@ constexpr inline TVector2<T> clamp(const TVector2<T> &vec, const TVector2<T> &mi
template<class T>
constexpr inline TVector3<T> clamp(const TVector3<T> &vec, const TVector3<T> &min, const TVector3<T> &max)
{
return TVector3<T>(std::clamp<T>(vec.X, min.X, max.X), std::clamp<T>(vec.Y, min.Y, max.Y), std::clamp<T>(vec.Z, min.Z, max.Z));
return TVector3<T>(clamp<T>(vec.X, min.X, max.X), clamp<T>(vec.Y, min.Y, max.Y), clamp<T>(vec.Z, min.Z, max.Z));
}
template<class T>