r718 - in trunk: . game

lordhavoc at icculus.org lordhavoc at icculus.org
Fri May 12 08:34:10 EDT 2006


Author: lordhavoc
Date: 2006-05-12 08:34:09 -0400 (Fri, 12 May 2006)
New Revision: 718

Modified:
   trunk/game/g_entity.c
   trunk/game/g_entityclass.c
   trunk/mathlib.h
Log:
turned IsNAN into a macro in mathlib.h and moved the NAN velocity checks
to G_Entity_PlayerPhysics


Modified: trunk/game/g_entity.c
===================================================================
--- trunk/game/g_entity.c	2006-05-12 11:19:17 UTC (rev 717)
+++ trunk/game/g_entity.c	2006-05-12 12:34:09 UTC (rev 718)
@@ -506,8 +506,12 @@
 
 void G_Entity_PlayerPhysics(G_Entity *self, Nvec3 wishvel, Nvec groundfriction, Nvec groundaccel, Nvec groundstopspeed, Nvec airfriction, Nvec airaccel, Nvec airstopspeed, Nvec jumpspeed, Nvec gravityscale, Nvec3 thrustvel)
 {
+	NUint32 j;
 	Nvec f;
 	Nvec3 gravityimpulse, countergravityimpulse;
+	for (j = 0; j < 3; j++)
+		if (IS_NAN(self->position.velocity[j]))
+			self->position.velocity[j] = 0;
 	VectorScale(G.globalgravity, G.frametime * gravityscale, gravityimpulse);
 	if (self->groundentity)
 	{
@@ -575,6 +579,9 @@
 	}
 	if (thrustvel)
 		VectorMA(self->position.velocity, G.frametime, thrustvel, self->position.velocity);
+	for (j = 0; j < 3; j++)
+		if (IS_NAN(self->position.velocity[j]))
+			self->position.velocity[j] = 0;
 }
 
 static Collision_Brush boxbrush;

Modified: trunk/game/g_entityclass.c
===================================================================
--- trunk/game/g_entityclass.c	2006-05-12 11:19:17 UTC (rev 717)
+++ trunk/game/g_entityclass.c	2006-05-12 12:34:09 UTC (rev 718)
@@ -100,15 +100,6 @@
 {
 }
 
-Nbool IsNAN(float f)
-{
-	return (*((int*)&f)&0x7fc00000) == 0x7fc00000;
-}
-//Nbool IsNAN(double f)
-//{
-//	return (*((int*)&f)&0x7fe00000) == 0x7fe00000;
-//}
-
 static void G_Object_Infantry_Frame(G_Entity *self)
 {
 	NUint32 buttonbits;
@@ -163,15 +154,6 @@
 	else
 		G_Entity_PlayerPhysics(self, rotatedmovement, self->eclass->friction, self->eclass->acceleration, self->eclass->stopspeed, self->eclass->airfriction, self->eclass->airacceleration, self->eclass->airstopspeed, (buttonbits & G_BUTTON_MOVEUP) ? self->eclass->jumpvelocity : 0, 1, NULL);
 
-	{
-		int j;
-		for (j = 0; j < 3; j++)
-		{
-			if (IsNAN(self->position.velocity[j]))
-				self->position.velocity[j] = 0;
-		}
-	}
-
 	G_Entity_Move(self, user->noclipmode ? 0 : G_SCOPE_BLOCK_PLAYER, self->eclass->stepheight, 0);
 
 	//Matrix4x4_ConcatQuakeEntity(&self->position.m, movement[0], movement[1], movement[2], turn[0], turn[1], turn[2], 1);

Modified: trunk/mathlib.h
===================================================================
--- trunk/mathlib.h	2006-05-12 11:19:17 UTC (rev 717)
+++ trunk/mathlib.h	2006-05-12 12:34:09 UTC (rev 718)
@@ -2,6 +2,7 @@
 #ifndef MATHLIB_H
 #define MATHLIB_H
 
+#define IS_NAN(x) (((*(int *)&x)&0x7fc00000) == 0x7fc00000)
 
 #define Min( a, b )				( ((a) < (b)) ? (a) : (b) )
 #define Max( a, b )				( ((a) > (b)) ? (a) : (b) )




More information about the neither-commits mailing list