X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=mathlib.c;h=4c19dfe1d38e558af013e23da358031a563bf443;hb=9fe4c204bf70b62ce92a7c2114414a16e80b974b;hp=40f03e43f3c902054e9289b166553b728cdf2048;hpb=713eeec7506784f206266b1f2953212474150f8b;p=xonotic%2Fdarkplaces.git diff --git a/mathlib.c b/mathlib.c index 40f03e43..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)