| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef BT_GEN_MINMAX_H |
| 16 |
#define BT_GEN_MINMAX_H |
| 17 |
|
| 18 |
#include "btScalar.h" |
| 19 |
|
| 20 |
namespace VHACD { |
| 21 |
|
| 22 |
template <class T> |
| 23 |
SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) |
| 24 |
{ |
| 25 |
return a < b ? a : b; |
| 26 |
} |
| 27 |
|
| 28 |
template <class T> |
| 29 |
SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) |
| 30 |
{ |
| 31 |
return a > b ? a : b; |
| 32 |
} |
| 33 |
|
| 34 |
template <class T> |
| 35 |
SIMD_FORCE_INLINE const T& btClamped(const T& a, const T& lb, const T& ub) |
| 36 |
{ |
| 37 |
return a < lb ? lb : (ub < a ? ub : a); |
| 38 |
} |
| 39 |
|
| 40 |
template <class T> |
| 41 |
SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) |
| 42 |
{ |
| 43 |
if (b < a) { |
| 44 |
a = b; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
template <class T> |
| 49 |
SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) |
| 50 |
{ |
| 51 |
if (a < b) { |
| 52 |
a = b; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
template <class T> |
| 57 |
SIMD_FORCE_INLINE void btClamp(T& a, const T& lb, const T& ub) |
| 58 |
{ |
| 59 |
if (a < lb) { |
| 60 |
a = lb; |
| 61 |
} |
| 62 |
else if (ub < a) { |
| 63 |
a = ub; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
}; |
| 68 |
|
| 69 |
#endif |