[math] Split out Quat/Vector compare implementations

This renames existing VectorCompCompare (and quaternion equivalent) to
VectorCompCompareAll and makes VectorCompCompare produce a vector of
results with optional negation (converting 0,1 to 0,-1 for compatibility
with simd semantics).
This commit is contained in:
Bill Currie 2022-01-02 01:06:22 +09:00
parent 97034d9dde
commit 9aa8f18d73
4 changed files with 21 additions and 8 deletions

View File

@ -115,10 +115,17 @@ extern const vec_t *const quat_origin;
(c)[2] = (a)[2] / (b)[2]; \
(c)[3] = (a)[3] / (b)[3]; \
} while (0)
#define QuatCompCompare(x, op, y) \
#define QuatCompCompare(m, a, op, b, c) \
do { \
(c)[0] = m((a)[0] op (b)[0]); \
(c)[1] = m((a)[1] op (b)[1]); \
(c)[2] = m((a)[2] op (b)[2]); \
(c)[3] = m((a)[3] op (b)[3]); \
} while (0)
#define QuatCompCompareAll(x, op, y) \
(((x)[0] op (y)[0]) && ((x)[1] op (y)[1]) \
&& ((x)[2] op (y)[2]) && ((x)[3] op (y)[3]))
#define QuatCompare(x, y) QuatCompCompare (x, ==, y)
#define QuatCompare(x, y) QuatCompCompareAll (x, ==, y)
#define QuatCompMin(a, b, c) \
do { \
(c)[0] = min ((a)[0], (b)[0]); \

View File

@ -131,9 +131,15 @@ extern const vec_t *const vec3_origin;
(c)[1] = (a)[1] / (b)[1]; \
(c)[2] = (a)[2] / (b)[2]; \
} while (0)
#define VectorCompCompare(x, op, y) \
#define VectorCompCompare(c, m, a, op, b) \
do { \
(c)[0] = m((a)[0] op (b)[0]); \
(c)[1] = m((a)[1] op (b)[1]); \
(c)[2] = m((a)[2] op (b)[2]); \
} while (0)
#define VectorCompCompareAll(x, op, y) \
(((x)[0] op (y)[0]) && ((x)[1] op (y)[1]) && ((x)[2] op (y)[2]))
#define VectorCompare(x, y) VectorCompCompare (x, ==, y)
#define VectorCompare(x, y) VectorCompCompareAll (x, ==, y)
#define VectorCompMin(a, b, c) \
do { \
(c)[0] = min ((a)[0], (b)[0]); \

View File

@ -484,8 +484,8 @@ SV_Push (edict_t *pusher, const vec3_t tmove, const vec3_t amove)
// entity?
c_absmin = SVvector (check, absmin);
c_absmax = SVvector (check, absmax);
if (VectorCompCompare (c_absmin, >=, maxs)
|| VectorCompCompare (c_absmax, <=, mins))
if (VectorCompCompareAll (c_absmin, >=, maxs)
|| VectorCompCompareAll (c_absmax, <=, mins))
continue;
if (!SV_TestEntityPosition (check))

View File

@ -487,8 +487,8 @@ SV_Push (edict_t *pusher, const vec3_t tmove, const vec3_t amove)
// entity?
c_absmin = SVvector (check, absmin);
c_absmax = SVvector (check, absmax);
if (VectorCompCompare (c_absmin, >=, maxs)
|| VectorCompCompare (c_absmax, <=, mins))
if (VectorCompCompareAll (c_absmin, >=, maxs)
|| VectorCompCompareAll (c_absmax, <=, mins))
continue;
if (!SV_TestEntityPosition (check))