[nexuiz-commits] r8594 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Jan 30 04:46:44 EST 2010


Author: div0
Date: 2010-01-30 04:46:44 -0500 (Sat, 30 Jan 2010)
New Revision: 8594

Modified:
   trunk/data/qcsrc/server/cl_physics.qc
Log:
make CPMA_PM_AirControl more gamepad friendly. Otherwise unchanged.

Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc	2010-01-30 08:19:21 UTC (rev 8593)
+++ trunk/data/qcsrc/server/cl_physics.qc	2010-01-30 09:46:44 UTC (rev 8594)
@@ -384,12 +384,31 @@
 	self.angles_z =  smoothangles_z;
 }
 
+float IsMoveInDirection(vector mv, float angle)
+{
+	angle = RAD2DEG * atan2(mv_y, mv_x);
+	angle = remainder(angle, 360) / 22.5;
+	if(angle >  1)
+		return 0;
+	if(angle < -1)
+		return 0;
+	return 1 - angle * angle;
+}
+
 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
 {
 	float zspeed, xyspeed, dot, k;
 
+#if 0
+	// this doesn't play well with analog input
 	if(self.movement_x == 0 || self.movement_y != 0)
 		return; // can't control movement if not moving forward or backward
+	k = 32;
+#else
+	k = 32 * IsMoveInDirection(self.movement, 0);
+	if(k <= 0)
+		return;
+#endif
 
 	zspeed = self.velocity_z;
 	self.velocity_z = 0;
@@ -397,7 +416,6 @@
 	self.velocity = normalize(self.velocity);
 
 	dot = self.velocity * wishdir;
-	k = 32;
 	k *= sv_aircontrol*dot*dot*frametime;
 
 	if(dot > 0) // we can't change direction while slowing down
@@ -1120,6 +1138,9 @@
 			if(sv_airstopaccelerate)
 				if(self.velocity * wishdir < 0)
 					airaccel = sv_airstopaccelerate*maxspd_mod;
+			// this doesn't play well with analog input, but can't r
+			// fixed like the AirControl can. So, don't set the maxa
+			// cvars when you want to support analog input.
 			if(self.movement_x == 0 && self.movement_y != 0)
 			{
 				if(sv_maxairstrafespeed)



More information about the nexuiz-commits mailing list