]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.c
fix typo in cl_netinputpacketspersecond_qw cvar name which caused
[xonotic/darkplaces.git] / mathlib.c
index 6bb3f4871b2300fd40470c4f9e7df8693cd5062d..eaa1a765d8e05bc5c65328a808591ad5053941e1 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -113,7 +113,7 @@ float m_bytenormals[NUMVERTEXNORMALS][3] =
 };
 
 #if 0
-qbyte NormalToByte(const vec3_t n)
+unsigned char NormalToByte(const vec3_t n)
 {
        int i, best;
        float bestdistance, distance;
@@ -133,7 +133,7 @@ qbyte NormalToByte(const vec3_t n)
 }
 
 // note: uses byte partly to force unsigned for the validity check
-void ByteToNormal(qbyte num, vec3_t n)
+void ByteToNormal(unsigned char num, vec3_t n)
 {
        if (num < NUMVERTEXNORMALS)
                VectorCopy(m_bytenormals[num], n);
@@ -254,6 +254,24 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,
               + (t0 * vr[2] + t1 * vu[2] + vf[2] * vf[2]) * point[2];
 }
 
+/*-----------------------------------------------------------------*/
+
+// returns the smallest integer greater than or equal to "value", or 0 if "value" is too big
+unsigned int CeilPowerOf2(unsigned int value)
+{
+       unsigned int ceilvalue;
+
+       if (value > (1U << (sizeof(int) * 8 - 1)))
+               return 0;
+
+       ceilvalue = 1;
+       while (ceilvalue < value)
+               ceilvalue <<= 1;
+
+       return ceilvalue;
+}
+
+
 /*-----------------------------------------------------------------*/