From: Rudolf Polzer Date: Thu, 13 Jan 2011 20:10:43 +0000 (+0100) Subject: more fixes X-Git-Tag: xonotic-v0.5.0~65 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dfb4b5c8c1a4deaf3749cf09e0d5a0ef342a4d0f;p=xonotic%2Fnetradiant.git more fixes --- diff --git a/libs/mathlib/mathlib.c b/libs/mathlib/mathlib.c index aca5ab73..98fb972a 100644 --- a/libs/mathlib/mathlib.c +++ b/libs/mathlib/mathlib.c @@ -816,151 +816,3 @@ vec_accu_t VectorNormalizeAccu(const vec3_accu_t in, vec3_accu_t out) } -//////////////////////////////////////////////////////////////////////////////// -// Below is double-precision math stuff. This was initially needed by the new -// "base winding" code in q3map2 brush processing in order to fix the famous -// "disappearing triangles" issue. These definitions can be used wherever extra -// precision is needed. -//////////////////////////////////////////////////////////////////////////////// - -/* -================= -VectorLengthAccu -================= -*/ -vec_accu_t VectorLengthAccu(const vec3_accu_t v) -{ - return (vec_accu_t) sqrt((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2])); -} - -/* -================= -DotProductAccu -================= -*/ -vec_accu_t DotProductAccu(const vec3_accu_t a, const vec3_accu_t b) -{ - return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]); -} - -/* -================= -VectorSubtractAccu -================= -*/ -void VectorSubtractAccu(const vec3_accu_t a, const vec3_accu_t b, vec3_accu_t out) -{ - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; -} - -/* -================= -VectorAddAccu -================= -*/ -void VectorAddAccu(const vec3_accu_t a, const vec3_accu_t b, vec3_accu_t out) -{ - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; -} - -/* -================= -VectorCopyAccu -================= -*/ -void VectorCopyAccu(const vec3_accu_t in, vec3_accu_t out) -{ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; -} - -/* -================= -VectorScaleAccu -================= -*/ -void VectorScaleAccu(const vec3_accu_t in, vec_accu_t scaleFactor, vec3_accu_t out) -{ - out[0] = in[0] * scaleFactor; - out[1] = in[1] * scaleFactor; - out[2] = in[2] * scaleFactor; -} - -/* -================= -CrossProductAccu -================= -*/ -void CrossProductAccu(const vec3_accu_t a, const vec3_accu_t b, vec3_accu_t out) -{ - out[0] = (a[1] * b[2]) - (a[2] * b[1]); - out[1] = (a[2] * b[0]) - (a[0] * b[2]); - out[2] = (a[0] * b[1]) - (a[1] * b[0]); -} - -/* -================= -Q_rintAccu -================= -*/ -vec_accu_t Q_rintAccu(vec_accu_t val) -{ - return (vec_accu_t) floor(val + 0.5); -} - -/* -================= -VectorCopyAccuToRegular -================= -*/ -void VectorCopyAccuToRegular(const vec3_accu_t in, vec3_t out) -{ - out[0] = (vec_t) in[0]; - out[1] = (vec_t) in[1]; - out[2] = (vec_t) in[2]; -} - -/* -================= -VectorCopyRegularToAccu -================= -*/ -void VectorCopyRegularToAccu(const vec3_t in, vec3_accu_t out) -{ - out[0] = (vec_accu_t) in[0]; - out[1] = (vec_accu_t) in[1]; - out[2] = (vec_accu_t) in[2]; -} - -/* -================= -VectorNormalizeAccu -================= -*/ -vec_accu_t VectorNormalizeAccu(const vec3_accu_t in, vec3_accu_t out) -{ - // The sqrt() function takes double as an input and returns double as an - // output according the the man pages on Debian and on FreeBSD. Therefore, - // I don't see a reason why using a double outright (instead of using the - // vec_accu_t alias for example) could possibly be frowned upon. - - vec_accu_t length; - - length = (vec_accu_t) sqrt((in[0] * in[0]) + (in[1] * in[1]) + (in[2] * in[2])); - if (length == 0) - { - VectorClear(out); - return 0; - } - - out[0] = in[0] / length; - out[1] = in[1] / length; - out[2] = in[2] / length; - - return length; -}