[nexuiz-commits] r8250 - trunk/data/qcsrc/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Nov 8 12:52:28 EST 2009


Author: div0
Date: 2009-11-08 12:52:28 -0500 (Sun, 08 Nov 2009)
New Revision: 8250

Modified:
   trunk/data/qcsrc/client/View.qc
   trunk/data/qcsrc/client/csqc_builtins.qc
   trunk/data/qcsrc/client/miscfunctions.qc
   trunk/data/qcsrc/client/prandom.qc
   trunk/data/qcsrc/client/teamradar.qc
Log:
fix some constants


Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc	2009-11-08 17:48:03 UTC (rev 8249)
+++ trunk/data/qcsrc/client/View.qc	2009-11-08 17:52:28 UTC (rev 8250)
@@ -122,18 +122,6 @@
 }
 
 float drawtime;
-
-float tan(float x)
-{
-	return sin(x) / cos(x);
-}
-float atan2(float y, float x)
-{
-	vector v;
-	v = '1 0 0' * x + '0 1 0' * y;
-	v = vectoangles(v);
-	return v_y * 0.01745329251994329576;
-}
 float avgspeed;
 vector GetCurrentFov(float fov)
 {
@@ -199,15 +187,15 @@
 		
 	velocityzoom = bound(0, drawframetime / max(0.000000001, cvar_or("cl_velocityzoomtime", 0.3)), 1);
 	avgspeed = avgspeed * (1 - velocityzoom) + (vlen(pmove_vel) / 1000) * velocityzoom;
-	velocityzoom = pow(2.718281828459, float2range11(avgspeed * -cvar_or("cl_velocityzoom", 0) / 1) * 1);
+	velocityzoom = exp(float2range11(avgspeed * -cvar_or("cl_velocityzoom", 0) / 1) * 1);
 	
 	//print(ftos(avgspeed), " avgspeed, ", ftos(cvar_or("cl_velocityzoom", 0)), " cvar, ", ftos(velocityzoom), " return\n"); // for debugging
 	
 	float frustumx, frustumy, fovx, fovy;
-	frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom * velocityzoom;
+	frustumy = tan(fov * M_PI / 360.0) * 0.75 * current_viewzoom * velocityzoom;
 	frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
-	fovx = atan2(frustumx, 1) / 0.00872664625997164788;
-	fovy = atan2(frustumy, 1) / 0.00872664625997164788;
+	fovx = atan2(frustumx, 1) / M_PI * 360.0;
+	fovy = atan2(frustumy, 1) / M_PI * 360.0;
 
 	return '1 0 0' * fovx + '0 1 0' * fovy;
 }

Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc	2009-11-08 17:48:03 UTC (rev 8249)
+++ trunk/data/qcsrc/client/csqc_builtins.qc	2009-11-08 17:52:28 UTC (rev 8250)
@@ -285,3 +285,12 @@
 float(string s) tokenize_console = #514;
 float(float i) argv_start_index = #515;
 float(float i) argv_end_index = #516;
+
+float(float s) asin = #471; // returns angle in radians for a given sin() value, the result is in the range -PI*0.5 to PI*0.5
+float(float c) acos = #472; // returns angle in radians for a given cos() value, the result is in the range 0 to PI
+float(float t) atan = #473; // returns angle in radians for a given tan() value, the result is in the range -PI*0.5 to PI*0.5
+float(float c, float s) atan2 = #474; // returns angle in radians for a given cos() and sin() value pair, the result is in the range -PI to PI (this is identical to vectoyaw except it returns radians rather than degrees)
+float(float a) tan = #475; // returns tangent value (which is simply sin(a)/cos(a)) for the given angle in radians, the result is in the range -infinity to +infinity
+float DEG2RAD = 0.0174532925199432957692369076848861271344287188854172545609719144;
+float RAD2DEG = 57.2957795130823208767981548141051703324054724665643215491602438612;
+float PI      = 3.1415926535897932384626433832795028841971693993751058209749445923;

Modified: trunk/data/qcsrc/client/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/client/miscfunctions.qc	2009-11-08 17:48:03 UTC (rev 8249)
+++ trunk/data/qcsrc/client/miscfunctions.qc	2009-11-08 17:52:28 UTC (rev 8250)
@@ -266,8 +266,6 @@
 	return false;
 }
 
-float PI      = 3.14159265359;
-float DEG2RAD = 0.01745329252;
 vector rotate(vector v, float a)
 {
 	vector w;

Modified: trunk/data/qcsrc/client/prandom.qc
===================================================================
--- trunk/data/qcsrc/client/prandom.qc	2009-11-08 17:48:03 UTC (rev 8249)
+++ trunk/data/qcsrc/client/prandom.qc	2009-11-08 17:52:28 UTC (rev 8250)
@@ -5,7 +5,7 @@
 float prandom()
 {
 	float c;
-	c = crc16(FALSE, strcat(ftos(prandom_seed), ftos(prandom_seed + 3.1415926535)));
+	c = crc16(FALSE, strcat(ftos(prandom_seed), ftos(prandom_seed + M_PI)));
 	prandom_seed = c;
 
 #ifdef USE_PRANDOM_DEBUG

Modified: trunk/data/qcsrc/client/teamradar.qc
===================================================================
--- trunk/data/qcsrc/client/teamradar.qc	2009-11-08 17:48:03 UTC (rev 8249)
+++ trunk/data/qcsrc/client/teamradar.qc	2009-11-08 17:52:28 UTC (rev 8250)
@@ -342,10 +342,10 @@
 		vector frame_origin, frame_size;
 		frame_origin = frame_size = '0 0 0';
 
-		frame_origin_x = teamradar_origin2d_x - teamradar_size2d_x * 0.55859375;
-		frame_origin_y = teamradar_origin2d_y - teamradar_size2d_y * 0.55859375;
-		frame_size_x = teamradar_size2d_x * 1.1171875;
-		frame_size_y = teamradar_size2d_y * 1.1171875;
+		frame_origin_x = teamradar_origin2d_x - teamradar_size2d_x * 0.55859375; // matches the picture
+		frame_origin_y = teamradar_origin2d_y - teamradar_size2d_y * 0.55859375; // matches the picture
+		frame_size_x = teamradar_size2d_x * 1.1171875; // matches the picture
+		frame_size_y = teamradar_size2d_y * 1.1171875; // matches the picture
 		drawpic(frame_origin, "gfx/ons-frame.tga", frame_size, '1 1 1', sbar_alpha_fg, 0);
 		drawpic(frame_origin, "gfx/ons-frame-team.tga", frame_size, rgb, sbar_alpha_fg, 0);
 



More information about the nexuiz-commits mailing list