mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
* renamed Length() to VectorLength() for consistency with its friends.
* mathlib.c: Removed the unnecessary sqrt() prototype. (VectorLength): Made it to just return sqrt(DotProduct(arg,arg)) (VectorNormalize): Calculate the length as sqrt(DotProduct(arg,arg)). * mathlib.h (CLAMP): Renamed the macro arguments from min and max to _minval and _maxval. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@248 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
19b960c889
commit
a7d57b4b51
10 changed files with 18 additions and 30 deletions
|
@ -98,7 +98,7 @@ void Chase_UpdateForDrawing (void)
|
|||
|
||||
// make sure camera is not in or behind a wall
|
||||
TraceLine(r_refdef.vieworg, ideal, temp);
|
||||
if (Length(temp) != 0)
|
||||
if (VectorLength(temp) != 0)
|
||||
VectorCopy(temp, ideal);
|
||||
|
||||
// place camera
|
||||
|
|
|
@ -724,7 +724,7 @@ void CL_Tracepos_f (void)
|
|||
VectorScale(vpn, 8192.0, v);
|
||||
TraceLine(r_refdef.vieworg, v, w);
|
||||
|
||||
if (Length(w) == 0)
|
||||
if (VectorLength(w) == 0)
|
||||
Con_Printf ("Tracepos: trace didn't hit anything\n");
|
||||
else
|
||||
Con_Printf ("Tracepos: (%i %i %i)\n", (int)w[0], (int)w[1], (int)w[2]);
|
||||
|
|
|
@ -789,8 +789,8 @@ void Mod_LoadTexinfo (lump_t *l)
|
|||
{
|
||||
for (j=0 ; j<8 ; j++)
|
||||
out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
|
||||
len1 = Length (out->vecs[0]);
|
||||
len2 = Length (out->vecs[1]);
|
||||
len1 = VectorLength (out->vecs[0]);
|
||||
len2 = VectorLength (out->vecs[1]);
|
||||
len1 = (len1 + len2)/2;
|
||||
if (len1 < 0.32)
|
||||
out->mipadjust = 4;
|
||||
|
@ -1409,7 +1409,7 @@ float RadiusFromBounds (vec3_t mins, vec3_t maxs)
|
|||
corner[i] = fabs(mins[i]) > fabs(maxs[i]) ? fabs(mins[i]) : fabs(maxs[i]);
|
||||
}
|
||||
|
||||
return Length (corner);
|
||||
return VectorLength (corner);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -92,7 +92,7 @@ void R_RenderDlight (dlight_t *light)
|
|||
rad = light->radius * 0.35;
|
||||
|
||||
VectorSubtract (light->origin, r_origin, v);
|
||||
if (Length (v) < rad)
|
||||
if (VectorLength (v) < rad)
|
||||
{ // view is inside the dlight
|
||||
AddLightBlend (1, 0.5, 0, light->radius * 0.0003);
|
||||
return;
|
||||
|
|
|
@ -234,7 +234,7 @@ void VectorAngles (const vec3_t forward, vec3_t angles)
|
|||
temp[0] = forward[0];
|
||||
temp[1] = forward[1];
|
||||
temp[2] = 0;
|
||||
angles[PITCH] = -atan2(forward[2], Length(temp)) / M_PI_DIV_180;
|
||||
angles[PITCH] = -atan2(forward[2], VectorLength(temp)) / M_PI_DIV_180;
|
||||
angles[YAW] = atan2(forward[1], forward[0]) / M_PI_DIV_180;
|
||||
angles[ROLL] = 0;
|
||||
}
|
||||
|
@ -317,27 +317,16 @@ void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
|
|||
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
||||
}
|
||||
|
||||
double sqrt(double x);
|
||||
|
||||
vec_t Length(vec3_t v)
|
||||
vec_t VectorLength(vec3_t v)
|
||||
{
|
||||
int i;
|
||||
float length;
|
||||
|
||||
length = 0;
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
length += v[i]*v[i];
|
||||
length = sqrt (length); // FIXME
|
||||
|
||||
return length;
|
||||
return sqrt(DotProduct(v,v));
|
||||
}
|
||||
|
||||
float VectorNormalize (vec3_t v)
|
||||
{
|
||||
float length, ilength;
|
||||
|
||||
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
||||
length = sqrt (length); // FIXME
|
||||
length = sqrt(DotProduct(v,v));
|
||||
|
||||
if (length)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ extern int nanmask;
|
|||
|
||||
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
|
||||
|
||||
#define CLAMP(min, x, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) //johnfitz
|
||||
#define CLAMP(_minval, x, _maxval) ((x) < (_minval) ? (_minval) : (x) > (_maxval) ? (_maxval) : (x))
|
||||
|
||||
#define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //johnfitz -- from joequake
|
||||
|
||||
|
@ -101,7 +101,7 @@ void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
|
|||
void _VectorCopy (vec3_t in, vec3_t out);
|
||||
|
||||
int VectorCompare (vec3_t v1, vec3_t v2);
|
||||
vec_t Length (vec3_t v);
|
||||
vec_t VectorLength (vec3_t v);
|
||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
|
||||
float VectorNormalize (vec3_t v); // returns vector length
|
||||
void VectorInverse (vec3_t v);
|
||||
|
@ -121,7 +121,6 @@ int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
|
|||
float anglemod(float a);
|
||||
|
||||
|
||||
|
||||
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
||||
(((p)->type < 3)? \
|
||||
( \
|
||||
|
|
|
@ -908,7 +908,7 @@ void PF_findradius (void)
|
|||
continue;
|
||||
for (j=0 ; j<3 ; j++)
|
||||
eorg[j] = org[j] - (ent->v.origin[j] + (ent->v.mins[j] + ent->v.maxs[j])*0.5);
|
||||
if (Length(eorg) > rad)
|
||||
if (VectorLength(eorg) > rad)
|
||||
continue;
|
||||
|
||||
ent->v.chain = EDICT_TO_PROG(chain);
|
||||
|
|
|
@ -326,7 +326,7 @@ void R_SetupAliasLighting (entity_t *e)
|
|||
if (cl_dlights[i].die >= cl.time)
|
||||
{
|
||||
VectorSubtract (currententity->origin, cl_dlights[i].origin, dist);
|
||||
add = cl_dlights[i].radius - Length(dist);
|
||||
add = cl_dlights[i].radius - VectorLength(dist);
|
||||
if (add > 0)
|
||||
VectorMA (lightcolor, add, cl_dlights[i].color, lightcolor);
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ void SV_WaterMove (void)
|
|||
else
|
||||
wishvel[2] += cmd.upmove;
|
||||
|
||||
wishspeed = Length(wishvel);
|
||||
wishspeed = VectorLength(wishvel);
|
||||
if (wishspeed > sv_maxspeed.value)
|
||||
{
|
||||
VectorScale (wishvel, sv_maxspeed.value/wishspeed, wishvel);
|
||||
|
@ -255,7 +255,7 @@ void SV_WaterMove (void)
|
|||
//
|
||||
// water friction
|
||||
//
|
||||
speed = Length (velocity);
|
||||
speed = VectorLength (velocity);
|
||||
if (speed)
|
||||
{
|
||||
newspeed = speed - host_frametime * speed * sv_friction.value;
|
||||
|
@ -313,7 +313,7 @@ void SV_NoclipMove (void)
|
|||
velocity[2] = forward[2]*cmd.forwardmove + right[2]*cmd.sidemove;
|
||||
velocity[2] += cmd.upmove*2; //doubled to match running speed
|
||||
|
||||
if (Length (velocity) > sv_maxspeed.value)
|
||||
if (VectorLength (velocity) > sv_maxspeed.value)
|
||||
{
|
||||
VectorNormalize (velocity);
|
||||
VectorScale (velocity, sv_maxspeed.value, velocity);
|
||||
|
|
|
@ -121,7 +121,7 @@ float V_CalcBob (void)
|
|||
// (don't count Z, or jumping messes it up)
|
||||
|
||||
bob = sqrt(cl.velocity[0]*cl.velocity[0] + cl.velocity[1]*cl.velocity[1]) * cl_bob.value;
|
||||
//Con_Printf ("speed: %5.1f\n", Length(cl.velocity));
|
||||
//Con_Printf ("speed: %5.1f\n", VectorLength(cl.velocity));
|
||||
bob = bob*0.3 + bob*0.7*sin(cycle);
|
||||
if (bob > 4)
|
||||
bob = 4;
|
||||
|
|
Loading…
Reference in a new issue