version of code in VectorNormalize() is used. Yes, I put the old code back
in there, and it's active if MATHLIB_VECTOR_NORMALIZE_PRECISION_FIX is 0.
Right now it's 1, so the fixed code is active. I need this quick way to
test regression tests.
git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk@424
8a3a26a2-13c4-0310-b231-
cf6edde360e5
void VectorMA( const vec3_t va, vec_t scale, const vec3_t vb, vec3_t vc );
void _CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
+// I need this define in order to test some of the regression tests from time to time.
+// This define affect the precision of VectorNormalize() function only.
+#define MATHLIB_VECTOR_NORMALIZE_PRECISION_FIX 1
vec_t VectorNormalize (const vec3_t in, vec3_t out);
vec_t ColorNormalize( const vec3_t in, vec3_t out );
void VectorInverse (vec3_t v);
vec_t VectorNormalize( const vec3_t in, vec3_t out ) {
+#if MATHLIB_VECTOR_NORMALIZE_PRECISION_FIX
+
// 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
out[2] = (vec_t) (z / length);
return (vec_t) length;
+
+#else
+
+ vec_t length, ilength;
+
+ length = (vec_t)sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]);
+ if (length == 0)
+ {
+ VectorClear (out);
+ return 0;
+ }
+
+ ilength = 1.0f/length;
+ out[0] = in[0]*ilength;
+ out[1] = in[1]*ilength;
+ out[2] = in[2]*ilength;
+
+ return length;
+
+#endif
+
}
vec_t ColorNormalize( const vec3_t in, vec3_t out ) {