X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=mathlib.c;h=eaa1a765d8e05bc5c65328a808591ad5053941e1;hp=36e858dee589dca6c48541c8730375e5a6340db1;hb=da29a8beeb35293e2fd38b51883c91b5cf4cf4ad;hpb=c57a2ebbdf87d3d311b14eb75be65fbdf321e67c diff --git a/mathlib.c b/mathlib.c index 36e858de..eaa1a765 100644 --- a/mathlib.c +++ b/mathlib.c @@ -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; +} + + /*-----------------------------------------------------------------*/