Add utility macros to clamp all elements of 2,3,4 component vectors

This commit is contained in:
Sergey Sharybin 2014-11-04 16:31:42 +05:00
parent 1179ce6f11
commit 988b3d7188
1 changed files with 54 additions and 0 deletions

View File

@ -335,6 +335,60 @@
if ((a) < (b)) (a) = (b); \
} (void)0
#define CLAMP2(vec, b, c) { \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
} (void)0
#define CLAMP2_MIN(vec, b) { \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
} (void)0
#define CLAMP2_MAX(vec, b) { \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
} (void)0
#define CLAMP3(vec, b, c) { \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
} (void)0
#define CLAMP3_MIN(vec, b) { \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
CLAMP_MIN((vec)[2], b); \
} (void)0
#define CLAMP3_MAX(vec, b) { \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
} (void)0
#define CLAMP4(vec, b, c) { \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
CLAMP((vec)[3], b, c); \
} (void)0
#define CLAMP4_MIN(vec, b) { \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
CLAMP_MIN((vec)[2], b); \
CLAMP_MIN((vec)[3], b); \
} (void)0
#define CLAMP4_MAX(vec, b) { \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
CLAMP_MAX((vec)[3], b); \
} (void)0
#define IS_EQ(a, b) ( \
CHECK_TYPE_INLINE(a, double), CHECK_TYPE_INLINE(b, double), \
((fabs((double)((a) - (b))) >= (double) FLT_EPSILON) ? false : true))