X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=mathlib.c;h=4c19dfe1d38e558af013e23da358031a563bf443;hp=119f8bf79fe75cfa4a5f6ae80833d396b83a8f67;hb=1f7645e73c1f099c486c716dbd21dda6d55297ea;hpb=bbb2827707bfbc2d2a7d3304473cafadffac5da5 diff --git a/mathlib.c b/mathlib.c index 119f8bf7..4c19dfe1 100644 --- a/mathlib.c +++ b/mathlib.c @@ -145,7 +145,7 @@ void ByteToNormal(unsigned char num, vec3_t n) // assumes "src" is normalized void PerpendicularVector( vec3_t dst, const vec3_t src ) { - // LordHavoc: optimized to death and beyond + // LadyHavoc: optimized to death and beyond int pos; float minelem; @@ -195,7 +195,7 @@ void PerpendicularVector( vec3_t dst, const vec3_t src ) #endif -// LordHavoc: like AngleVectors, but taking a forward vector instead of angles, useful! +// LadyHavoc: like AngleVectors, but taking a forward vector instead of angles, useful! void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up) { // NOTE: this is consistent to AngleVectors applied to AnglesFromVectors @@ -646,8 +646,8 @@ void AngleVectorsDuke3DFLU (const vec3_t angles, vec3_t forward, vec3_t left, ve } } -// LordHavoc: calculates pitch/yaw/roll angles from forward and up vectors -void AnglesFromVectors (vec3_t angles, const vec3_t forward, const vec3_t up, qboolean flippitch) +// LadyHavoc: calculates pitch/yaw/roll angles from forward and up vectors +void AnglesFromVectors (vec3_t angles, const vec3_t forward, const vec3_t up, qbool flippitch) { if (forward[0] == 0 && forward[1] == 0) { @@ -759,24 +759,17 @@ void AngleMatrix (const vec3_t angles, const vec3_t translate, vec_t matrix[][4] #endif -// LordHavoc: renamed this to Length, and made the normal one a #define +// LadyHavoc: renamed this to Length, and made the normal one a #define float VectorNormalizeLength (vec3_t v) { - float length, ilength; + float length; - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); + length = sqrt(DotProduct(v,v)); if (length) - { - ilength = 1/length; - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; - } + VectorScale(v, 1 / length, v); return length; - } @@ -841,7 +834,7 @@ void Mathlib_Init(void) { int a; - // LordHavoc: setup 1.0f / N table for quick recipricols of integers + // LadyHavoc: setup 1.0f / N table for quick recipricols of integers ixtable[0] = 0; for (a = 1;a < 4096;a++) ixtable[a] = 1.0f / a; @@ -894,7 +887,7 @@ void BoxFromPoints(vec3_t mins, vec3_t maxs, int numpoints, vec_t *point3f) } } -// LordHavoc: this has to be done right or you get severe precision breakdown +// LadyHavoc: this has to be done right or you get severe precision breakdown int LoopingFrameNumberFromDouble(double t, int loopframes) { if (loopframes) @@ -907,9 +900,9 @@ static unsigned int mul_Lecuyer[4] = { 0x12e15e35, 0xb500f16e, 0x2e714eb2, 0xb37 static void mul128(const unsigned int a[], const unsigned int b[], unsigned int dest[4]) { -#ifdef __GNUC__ - unsigned __int128 ia = (a[0] << 96) + (a[1] << 64) + (a[2] << 32) + (a[3]); - unsigned __int128 ib = (b[0] << 96) + (b[1] << 64) + (b[2] << 32) + (b[3]); +#if 0 //defined(__GNUC__) && defined(__x86_64__) + unsigned __int128 ia = ((__int128)a[0] << 96) | ((__int128)a[1] << 64) | ((__int128)a[2] << 32) | (a[3]); + unsigned __int128 ib = ((__int128)b[0] << 96) | ((__int128)b[1] << 64) | ((__int128)b[2] << 32) | (b[3]); unsigned __int128 id = ia * ib; dest[0] = (id >> 96) & 0xffffffff; dest[1] = (id >> 64) & 0xffffffff; @@ -968,7 +961,7 @@ static void mul128(const unsigned int a[], const unsigned int b[], unsigned int #endif } -void testmul128(unsigned int a0, unsigned int a1, unsigned int a2, unsigned int a3, unsigned int b0, unsigned int b1, unsigned int b2, unsigned int b3, unsigned int x0, unsigned int x1, unsigned int x2, unsigned int x3) +static void testmul128(unsigned int a0, unsigned int a1, unsigned int a2, unsigned int a3, unsigned int b0, unsigned int b1, unsigned int b2, unsigned int b3, unsigned int x0, unsigned int x1, unsigned int x2, unsigned int x3) { unsigned int a[4]; unsigned int b[4];