Adding MATHLIB_VECTOR_NORMALIZE_PRECISION_FIX in mathlib to control which
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: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@424 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
@@ -176,6 +176,8 @@ void _VectorCopy (vec3_t in, vec3_t out)
|
||||
|
||||
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
|
||||
@@ -199,6 +201,27 @@ vec_t VectorNormalize( const vec3_t in, vec3_t out ) {
|
||||
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 ) {
|
||||
|
||||
Reference in New Issue
Block a user