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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Mar 17 11:14:58 EDT 2009


Author: div0
Date: 2009-03-17 11:14:58 -0400 (Tue, 17 Mar 2009)
New Revision: 6202

Modified:
   trunk/data/qcsrc/server/t_jumppads.qc
Log:
experimental new jumppad handling code, probably buggy - has to be tested a lot I think
currently dprints value calculated in old and new way, but still uses old way


Modified: trunk/data/qcsrc/server/t_jumppads.qc
===================================================================
--- trunk/data/qcsrc/server/t_jumppads.qc	2009-03-17 14:12:22 UTC (rev 6201)
+++ trunk/data/qcsrc/server/t_jumppads.qc	2009-03-17 15:14:58 UTC (rev 6202)
@@ -66,11 +66,57 @@
 	if(ht < 0)
 		if(zdist < 0)
 			vz = -vz;
+	
+	float vs2;
+	vector solution;
+	solution = solve_quadratic(0.5 * grav, -vz, zdist); // ALWAYS solvable because jumpheight >= zdist
+	if(!solution_z)
+		solution_y = solution_x; // just in case
+	if(zdist == 0)
+		solution_x = solution_y;
+	
+	if(zdist < 0)
+	{
+		// down-jump
+		if(ht < 0)
+		{
+			// almost straight line type
+			// jump apex is before the jump
+			// we must take the larger one
+			vs2 = sdist / solution_y;
+		}
+		else
+		{
+			// regular jump
+			// jump apex is during the jump
+			// we must take the larger one too
+			vs2 = sdist / solution_y;
+		}
+	}
+	else
+	{
+		// up-jump
+		if(ht < 0)
+		{
+			// almost straight line type
+			// jump apex is after the jump
+			// we must take the smaller one
+			vs2 = sdist / solution_x;
+		}
+		else
+		{
+			// regular jump
+			// jump apex is during the jump
+			// we must take the larger one
+			vs2 = sdist / solution_y;
+		}
+	}
 
 	// how far to push him?
 	if(zdist == 0)
 	{
 		trigger_push_calculatevelocity_flighttime = sqrt(jumpheight * 8 / grav);
+		print(ftos(vs), "\n");
 		vs = sdist / trigger_push_calculatevelocity_flighttime;
 			// trajsign is ignored (the high point MUST be inside the jump!)
 	}
@@ -97,6 +143,8 @@
 		// cases to test: "jump up", "jump down" with positive and negative height
 	}
 
+	dprint("jumppad new solution: vs=", ftos(vs), " vs2=", ftos(vs2), " should match\n");
+
 	// finally calculate the velocity
 	return sdir * vs + '0 0 1' * vz;
 }



More information about the nexuiz-commits mailing list