r510 - in trunk/code: client qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jan 19 15:28:12 EST 2006


Author: tma
Date: 2006-01-19 15:28:12 -0500 (Thu, 19 Jan 2006)
New Revision: 510

Modified:
   trunk/code/client/snd_openal.c
   trunk/code/qcommon/q_math.c
   trunk/code/qcommon/q_shared.h
Log:
* Added Q_isnan for NaN tests with -ffast-math
* Fixed UT/OpenAL work around


Modified: trunk/code/client/snd_openal.c
===================================================================
--- trunk/code/client/snd_openal.c	2006-01-19 18:16:44 UTC (rev 509)
+++ trunk/code/client/snd_openal.c	2006-01-19 20:28:12 UTC (rev 510)
@@ -492,15 +492,12 @@
 #define S_AL_SanitiseVector(v) _S_AL_SanitiseVector(v,__LINE__)
 static void _S_AL_SanitiseVector( vec3_t v, int line )
 {
-	// NaNs can't be compared for equality, thus always fail this test
-	if( v[ 0 ] == v[ 0 ] &&
-			v[ 1 ] == v[ 1 ] &&
-			v[ 2 ] == v[ 2 ] )
-		return;
-
-	Com_DPrintf( S_COLOR_YELLOW "WARNING: vector with one or more NaN components "
-			"being passed to OpenAL at %s:%d -- zeroing\n", __FILE__, line );
-	VectorClear( v );
+	if( Q_isnan( v[ 0 ] ) || Q_isnan( v[ 1 ] ) || Q_isnan( v[ 2 ] ) )
+	{
+		Com_DPrintf( S_COLOR_YELLOW "WARNING: vector with one or more NaN components "
+				"being passed to OpenAL at %s:%d -- zeroing\n", __FILE__, line );
+		VectorClear( v );
+	}
 }
 
 /*

Modified: trunk/code/qcommon/q_math.c
===================================================================
--- trunk/code/qcommon/q_math.c	2006-01-19 18:16:44 UTC (rev 509)
+++ trunk/code/qcommon/q_math.c	2006-01-19 20:28:12 UTC (rev 510)
@@ -1252,4 +1252,24 @@
 	VectorNormalize( dst );
 }
 
+/*
+================
+Q_isnan
 
+Don't pass doubles to this
+================
+*/
+int Q_isnan( float x )
+{
+	union
+	{
+		float f;
+		unsigned int i;
+	} t;
+
+	t.f = x;
+	t.i &= 0x7FFFFFFF;
+	t.i = 0x7F800000 - t.i;
+
+	return (int)( (unsigned int)t.i >> 31 );
+}

Modified: trunk/code/qcommon/q_shared.h
===================================================================
--- trunk/code/qcommon/q_shared.h	2006-01-19 18:16:44 UTC (rev 509)
+++ trunk/code/qcommon/q_shared.h	2006-01-19 20:28:12 UTC (rev 510)
@@ -557,6 +557,7 @@
 void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]);
 void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
 void PerpendicularVector( vec3_t dst, const vec3_t src );
+int Q_isnan( float x );
 
 
 //=============================================




More information about the quake3-commits mailing list