[nexuiz-commits] r8251 - in trunk/data/qcsrc: client common menu server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Nov 8 13:03:30 EST 2009


Author: div0
Date: 2009-11-08 13:03:28 -0500 (Sun, 08 Nov 2009)
New Revision: 8251

Modified:
   trunk/data/qcsrc/client/csqc_builtins.qc
   trunk/data/qcsrc/common/mathlib.qc
   trunk/data/qcsrc/common/mathlib.qh
   trunk/data/qcsrc/menu/mbuiltin.qh
   trunk/data/qcsrc/server/extensions.qh
Log:
log() function is now a builtin (this means we need the current engine if any code uses log())


Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc	2009-11-08 17:52:28 UTC (rev 8250)
+++ trunk/data/qcsrc/client/csqc_builtins.qc	2009-11-08 18:03:28 UTC (rev 8251)
@@ -294,3 +294,4 @@
 float DEG2RAD = 0.0174532925199432957692369076848861271344287188854172545609719144;
 float RAD2DEG = 57.2957795130823208767981548141051703324054724665643215491602438612;
 float PI      = 3.1415926535897932384626433832795028841971693993751058209749445923;
+float log(float f) = #532;

Modified: trunk/data/qcsrc/common/mathlib.qc
===================================================================
--- trunk/data/qcsrc/common/mathlib.qc	2009-11-08 17:52:28 UTC (rev 8250)
+++ trunk/data/qcsrc/common/mathlib.qc	2009-11-08 18:03:28 UTC (rev 8251)
@@ -105,31 +105,6 @@
 {
 	return x * pow(2, e);
 }
-float log(float x)
-{
-	// TODO improve speed
-	float i;
-	float r, r0;
-	if(x <= 0)
-		return nan("log");
-	if(!isfinite(x))
-		return x;
-	if(x >= 8)
-		return -log(1 / x); // faster
-	if(x < 0.0009765625)
-		return 2 * log(sqrt(x)); // faster
-	r = 1;
-	r0 = 0;
-	for(i = 1; fabs(r - r0) >= 0.00001; ++i)
-	{
-		// Newton iteration on exp(r) = x:
-		//   r <- r - (exp(r) - x) / (exp(r))
-		//   r <- r - 1 + x / exp(r)
-		r0 = r;
-		r = r0 - 1 + x / exp(r0);
-	}
-	return r;
-}
 float log10(float x)
 {
 	return log(x) * M_LOG10E;

Modified: trunk/data/qcsrc/common/mathlib.qh
===================================================================
--- trunk/data/qcsrc/common/mathlib.qh	2009-11-08 17:52:28 UTC (rev 8250)
+++ trunk/data/qcsrc/common/mathlib.qh	2009-11-08 18:03:28 UTC (rev 8251)
@@ -61,7 +61,7 @@
 vector frexp(float x); // returns mantissa as _x, exponent as _y
 int ilogb(float x);
 float ldexp(float x, int e);
-float log(float x);
+//float log(float x);
 float log10(float x);
 float log1p(float x);
 float log2(float x);

Modified: trunk/data/qcsrc/menu/mbuiltin.qh
===================================================================
--- trunk/data/qcsrc/menu/mbuiltin.qh	2009-11-08 17:52:28 UTC (rev 8250)
+++ trunk/data/qcsrc/menu/mbuiltin.qh	2009-11-08 18:03:28 UTC (rev 8251)
@@ -347,3 +347,4 @@
 string(float, float) getgamedirinfo = #626;
 #define GETGAMEDIRINFO_NAME 0
 #define GETGAMEDIRINFO_DESCRIPTION 1
+float log(float f) = #532;

Modified: trunk/data/qcsrc/server/extensions.qh
===================================================================
--- trunk/data/qcsrc/server/extensions.qh	2009-11-08 17:52:28 UTC (rev 8250)
+++ trunk/data/qcsrc/server/extensions.qh	2009-11-08 18:03:28 UTC (rev 8251)
@@ -800,6 +800,13 @@
 //description:
 //returns the playing time of the current cdtrack when passed to gettime()
 
+//DP_QC_LOG
+//darkplaces implementation: div0
+//builtin definitions:
+float log(float f) = #532;
+//description:
+//logarithm
+
 //DP_QC_MINMAXBOUND
 //idea: LordHavoc
 //darkplaces implementation: LordHavoc



More information about the nexuiz-commits mailing list