diff --git a/common/mathlib.cc b/common/mathlib.cc index e8d54f04..ccdd906e 100644 --- a/common/mathlib.cc +++ b/common/mathlib.cc @@ -102,6 +102,26 @@ VecStrf(const vec3_t vec) return buf; } +void ClearBounds(vec3_t mins, vec3_t maxs) +{ + for (int i=0; i<3; i++) { + mins[i] = VECT_MAX; + maxs[i] = -VECT_MAX; + } +} + +void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs) +{ + for (int i=0; i<3; i++) { + const vec_t val = v[i]; + + if (val < mins[i]) + mins[i] = val; + if (val > maxs[i]) + maxs[i] = val; + } +} + // from http://mathworld.wolfram.com/SpherePointPicking.html // eqns 6,7,8 void diff --git a/include/common/mathlib.hh b/include/common/mathlib.hh index 3b4d5f66..543c0f0a 100644 --- a/include/common/mathlib.hh +++ b/include/common/mathlib.hh @@ -142,6 +142,9 @@ VectorCopyFromGLM(const qvec3f &in, vec3_t out) out[2] = in[2]; } +void ClearBounds(vec3_t mins, vec3_t maxs); +void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs); + static inline qvec3f VectorToGLM(const vec3_t in) {