Optimize DEG2RAD a little, plus some whitespace.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-09-10 04:20:27 +00:00
parent 8ca44af043
commit fb7918d4f8

View file

@ -44,20 +44,18 @@
#include "QF/qtypes.h" #include "QF/qtypes.h"
#include "QF/sys.h" #include "QF/sys.h"
vec3_t vec3_origin = { 0, 0, 0 }; int nanmask = 255 << 23;
int nanmask = 255 << 23; mplane_t frustum[4];
mplane_t frustum[4]; vec3_t vec3_origin = { 0, 0, 0 };
/*-----------------------------------------------------------------*/ #define DEG2RAD(a) (a * (M_PI / 180.0))
#define DEG2RAD( a ) ( a * M_PI ) / 180.0F
void void
ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal) ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal)
{ {
float d; float inv_denom, d;
vec3_t n; vec3_t n;
float inv_denom;
inv_denom = 1.0F / DotProduct (normal, normal); inv_denom = 1.0F / DotProduct (normal, normal);
@ -76,10 +74,9 @@ ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal)
void void
PerpendicularVector (vec3_t dst, const vec3_t src) PerpendicularVector (vec3_t dst, const vec3_t src)
{ {
int pos; int pos, i;
int i; float minelem = 1.0F;
float minelem = 1.0F; vec3_t tempvec;
vec3_t tempvec;
/* find the smallest magnitude axially aligned vector */ /* find the smallest magnitude axially aligned vector */
for (pos = 0, i = 0; i < 3; i++) { for (pos = 0, i = 0; i < 3; i++) {
@ -170,8 +167,8 @@ RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point,
R_ConcatRotations (tmpmat, im, rot); R_ConcatRotations (tmpmat, im, rot);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
dst[i] = dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] *
rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2]; point[2];
} }
} }
@ -179,8 +176,6 @@ RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point,
# pragma optimize( "", on ) # pragma optimize( "", on )
#endif #endif
/*-----------------------------------------------------------------*/
float float
anglemod (float a) anglemod (float a)
{ {
@ -235,67 +230,51 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
// general case // general case
switch (p->signbits) { switch (p->signbits) {
case 0: case 0:
dist1 = dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
dist2 = dist2 = p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
break; break;
case 1: case 1:
dist1 = dist1 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
dist2 = dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
break; break;
case 2: case 2:
dist1 = dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
dist2 = dist2 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
break; break;
case 3: case 3:
dist1 = dist1 = p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
dist2 = dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
break; break;
case 4: case 4:
dist1 = dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
dist2 = dist2 = p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
break; break;
case 5: case 5:
dist1 = dist1 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
dist2 = dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
break; break;
case 6: case 6:
dist1 = dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emins[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
dist2 = dist2 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emins[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
break; break;
case 7: case 7:
dist1 = dist1 = p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[0] * emins[0] + p->normal[1] * emins[1] +
p->normal[2] * emins[2]; p->normal[2] * emins[2];
dist2 = dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] +
p->normal[2] * emaxs[2]; p->normal[2] * emaxs[2];
break; break;
default: default:
@ -344,8 +323,7 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
void void
AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{ {
float angle; float angle, sr, sp, sy, cr, cp, cy;
float sr, sp, sy, cr, cp, cy;
angle = angles[YAW] * (M_PI * 2 / 360); angle = angles[YAW] * (M_PI * 2 / 360);
sy = sin (angle); sy = sin (angle);
@ -431,8 +409,8 @@ double sqrt (double x);
vec_t vec_t
_Length (vec3_t v) _Length (vec3_t v)
{ {
int i; float length;
float length; int i;
length = 0; length = 0;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
@ -445,7 +423,7 @@ _Length (vec3_t v)
float float
VectorNormalize (vec3_t v) VectorNormalize (vec3_t v)
{ {
float length, ilength; float length, ilength;
length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
length = sqrt (length); // FIXME length = sqrt (length); // FIXME
@ -549,8 +527,8 @@ R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
void void
FloorDivMod (double numer, double denom, int *quotient, int *rem) FloorDivMod (double numer, double denom, int *quotient, int *rem)
{ {
int q, r; double x;
double x; int q, r;
#ifndef PARANOID #ifndef PARANOID
if (denom <= 0.0) if (denom <= 0.0)