rename VectorMA to VectorMultAdd, add VectorMultSub and use it in a few

places. Not certain how much speed difference it makes :/
This commit is contained in:
Bill Currie 2003-08-08 15:25:53 +00:00
parent 184aa7beb0
commit 6a94607d9d
23 changed files with 82 additions and 79 deletions

View file

@ -48,7 +48,8 @@ extern const vec3_t vec3_origin;
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
#define VectorMA(a,s,b,c) {(c)[0]=(a)[0]+(s)*(b)[0];(c)[1]=(a)[1]+(s)*(b)[1];(c)[2]=(a)[2]+(s)*(b)[2];}
#define VectorMultAdd(a,s,b,c) {(c)[0]=(a)[0]+(s)*(b)[0];(c)[1]=(a)[1]+(s)*(b)[1];(c)[2]=(a)[2]+(s)*(b)[2];}
#define VectorMultSub(a,s,b,c) {(c)[0]=(a)[0]-(s)*(b)[0];(c)[1]=(a)[1]-(s)*(b)[1];(c)[2]=(a)[2]-(s)*(b)[2];}
#define VectorLength(a) sqrt(DotProduct(a, a))
#define VectorScale(a,b,c) {(c)[0]=(a)[0]*(b);(c)[1]=(a)[1]*(b);(c)[2]=(a)[2]*(b);}

View file

@ -515,10 +515,11 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, i
* sizeof (trivertx16_t));
paliashdr->posedata = (byte *) verts - (byte *) paliashdr;
for (i = 0; i < paliashdr->numposes; i++) {
trivertx_t *pv = poseverts[i];
for (j = 0; j < numorder; j++) {
trivertx16_t v;
VectorMA (poseverts[i][vertexorder[j] + hdr->mdl.numverts].v,
256, poseverts[i][vertexorder[j]].v, v.v);
VectorMultSub (pv[vertexorder[j] + hdr->mdl.numverts].v,
256, pv[vertexorder[j]].v, v.v);
v.lightnormalindex =
poseverts[i][vertexorder[j]].lightnormalindex;
*verts++ = v;

View file

@ -106,8 +106,8 @@ VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
right[1] = -forward[0];
right[2] = forward[1];
d = -DotProduct(forward, right);
VectorMA (right, d, forward, right);
d = DotProduct(forward, right);
VectorMultSub (right, d, forward, right);
VectorNormalize (right);
CrossProduct(right, forward, up);
}

View file

@ -508,7 +508,7 @@ R_RocketTrail_QF (entity_t *ent)
if (numparticles >= r_maxparticles)
break;
len += dist;
VectorMA (ent->old_origin, len, vec, ent->old_origin);
VectorMultAdd (ent->old_origin, len, vec, ent->old_origin);
pscale = pscalenext;
}
}
@ -541,7 +541,7 @@ R_GrenadeTrail_QF (entity_t *ent)
if (numparticles >= r_maxparticles)
break;
len += dist;
VectorMA (ent->old_origin, len, vec, ent->old_origin);
VectorMultAdd (ent->old_origin, len, vec, ent->old_origin);
pscale = pscalenext;
}
}
@ -580,7 +580,7 @@ R_BloodTrail_QF (entity_t *ent)
if (numparticles >= r_maxparticles)
break;
len += dist;
VectorMA (ent->old_origin, len, vec, ent->old_origin);
VectorMultAdd (ent->old_origin, len, vec, ent->old_origin);
pscale = pscalenext;
}
}
@ -619,7 +619,7 @@ R_SlightBloodTrail_QF (entity_t *ent)
if (numparticles >= r_maxparticles)
break;
len += dist;
VectorMA (ent->old_origin, len, vec, ent->old_origin);
VectorMultAdd (ent->old_origin, len, vec, ent->old_origin);
pscale = pscalenext;
}
}
@ -1417,7 +1417,7 @@ R_DrawParticles (void)
}
}
VectorMA (part->org, r_frametime, part->vel, part->org);
VectorMultAdd (part->org, r_frametime, part->vel, part->org);
switch (part->type) {
case pt_static:
@ -1442,7 +1442,7 @@ R_DrawParticles (void)
break;
}
part->color = ramp1[(int) part->ramp];
VectorMA (part->vel, time4, part->vel, part->vel);
VectorMultAdd (part->vel, time4, part->vel, part->vel);
part->vel[2] -= grav;
break;
case pt_explode2:
@ -1452,11 +1452,11 @@ R_DrawParticles (void)
break;
}
part->color = ramp2[(int) part->ramp];
VectorMA (part->vel, -r_frametime, part->vel, part->vel);
VectorMultSub (part->vel, r_frametime, part->vel, part->vel);
part->vel[2] -= grav;
break;
case pt_blob:
VectorMA (part->vel, time4, part->vel, part->vel);
VectorMultAdd (part->vel, time4, part->vel, part->vel);
part->vel[2] -= grav;
break;
case pt_blob2:

View file

@ -126,7 +126,8 @@ R_AddDynamicLights_1 (msurface_t *surf)
VectorSubtract (r_dlights[lnum].origin, currententity->origin, local);
dist = DotProduct (local, surf->plane->normal) - surf->plane->dist;
VectorMA (r_dlights[lnum].origin, -dist, surf->plane->normal, impact);
VectorMultSub (r_dlights[lnum].origin, dist, surf->plane->normal,
impact);
i = DotProduct (impact, surf->texinfo->vecs[0]) +
surf->texinfo->vecs[0][3] - surf->texturemins[0];
@ -190,7 +191,8 @@ R_AddDynamicLights_3 (msurface_t *surf)
VectorSubtract (r_dlights[lnum].origin, currententity->origin, local);
dist = DotProduct (local, surf->plane->normal) - surf->plane->dist;
VectorMA (r_dlights[lnum].origin, -dist, surf->plane->normal, impact);
VectorMultSub (r_dlights[lnum].origin, dist, surf->plane->normal,
impact);
i = DotProduct (impact, surf->texinfo->vecs[0]) +
surf->texinfo->vecs[0][3] - surf->texturemins[0];

View file

@ -106,7 +106,7 @@ GL_DrawAliasFrameTri (vert_order_t *vo)
qfglBegin (GL_TRIANGLES);
do {
qfglTexCoord2fv (tex_coord->st);
VectorMA (ambientcolor, verts->lightdot, shadecolor, color);
VectorMultAdd (ambientcolor, verts->lightdot, shadecolor, color);
qfglColor4fv (color);
qfglVertex3fv (verts->vert);
@ -159,7 +159,7 @@ GL_DrawAliasFrameTriMulti (vert_order_t *vo)
tex_coord++;
// normals and vertexes come from the frame list
VectorMA (ambientcolor, verts->lightdot, shadecolor, color);
VectorMultAdd (ambientcolor, verts->lightdot, shadecolor, color);
qfglColor4fv (color);
qfglVertex3fv (verts->vert);
@ -196,7 +196,7 @@ GL_DrawAliasFrame (vert_order_t *vo)
order += 2;
// normals and vertexes come from the frame list
VectorMA (ambientcolor, verts->lightdot, shadecolor, color);
VectorMultAdd (ambientcolor, verts->lightdot, shadecolor, color);
qfglColor4fv (color);
@ -272,7 +272,7 @@ GL_DrawAliasFrameMulti (vert_order_t *vo)
order += 2;
// normals and vertexes come from the frame list
VectorMA (ambientcolor, verts->lightdot, shadecolor, color);
VectorMultAdd (ambientcolor, verts->lightdot, shadecolor, color);
qfglColor4fv (color);
@ -637,8 +637,8 @@ R_DrawAliasModel (entity_t *e)
d;
if (add > 0.0)
VectorMA (ambientcolor, add, r_dlights[lnum].color,
ambientcolor);
VectorMultAdd (ambientcolor, add, r_dlights[lnum].color,
ambientcolor);
}
}

View file

@ -147,21 +147,21 @@ R_DrawSpriteModel_f (entity_t *e)
qfglColor4fv (color);
qfglTexCoord2f (0, 1);
VectorMA (e->origin, frame->down, up, point1);
VectorMA (point1, frame->left, right, point);
VectorMultAdd (e->origin, frame->down, up, point1);
VectorMultAdd (point1, frame->left, right, point);
qfglVertex3fv (point);
qfglTexCoord2f (0, 0);
VectorMA (e->origin, frame->up, up, point2);
VectorMA (point2, frame->left, right, point);
VectorMultAdd (e->origin, frame->up, up, point2);
VectorMultAdd (point2, frame->left, right, point);
qfglVertex3fv (point);
qfglTexCoord2f (1, 0);
VectorMA (point2, frame->right, right, point);
VectorMultAdd (point2, frame->right, right, point);
qfglVertex3fv (point);
qfglTexCoord2f (1, 1);
VectorMA (point1, frame->right, right, point);
VectorMultAdd (point1, frame->right, right, point);
qfglVertex3fv (point);
qfglEnd ();
@ -217,18 +217,18 @@ R_DrawSpriteModel_VA_f (entity_t *e)
if (modelalpha < 255)
qfglDepthMask (GL_FALSE);
VectorMA (e->origin, frame->down, up, point1);
VectorMA (point1, frame->left, right, VA[0].vertex);
VectorMultAdd (e->origin, frame->down, up, point1);
VectorMultAdd (point1, frame->left, right, VA[0].vertex);
memcpy (VA[1].color, color, 4);
VectorMA (e->origin, frame->up, up, point2);
VectorMA (point2, frame->left, right, VA[1].vertex);
VectorMultAdd (e->origin, frame->up, up, point2);
VectorMultAdd (point2, frame->left, right, VA[1].vertex);
memcpy (VA[2].color, color, 4);
VectorMA (point2, frame->right, right, VA[2].vertex);
VectorMultAdd (point2, frame->right, right, VA[2].vertex);
memcpy (VA[3].color, color, 4);
VectorMA (point1, frame->right, right, VA[3].vertex);
VectorMultAdd (point1, frame->right, right, VA[3].vertex);
// VA += 4;
// vacount += 4;

View file

@ -509,13 +509,13 @@ R_Mirror (void)
memcpy (r_base_world_matrix, r_world_matrix, sizeof (r_base_world_matrix));
d = DotProduct (r_refdef.vieworg, mirror_plane->normal) -
d = 2 * DotProduct (r_refdef.vieworg, mirror_plane->normal) -
mirror_plane->dist;
VectorMA (r_refdef.vieworg, -2 * d, mirror_plane->normal,
r_refdef.vieworg);
VectorMultSub (r_refdef.vieworg, d, mirror_plane->normal,
r_refdef.vieworg);
d = DotProduct (vpn, mirror_plane->normal);
VectorMA (vpn, -2 * d, mirror_plane->normal, vpn);
d = 2 * DotProduct (vpn, mirror_plane->normal);
VectorMultSub (vpn, d, mirror_plane->normal, vpn);
r_refdef.viewangles[0] = -asin (vpn[2]) / M_PI * 180;
r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180;

View file

@ -194,8 +194,7 @@ real_mark_surfaces (float dist, msurface_t *surf, const vec3_t lightorigin,
vec3_t impact;
dist2 = dist * dist;
dist = -dist;
VectorMA (light->origin, dist, surf->plane->normal, impact);
VectorMultSub (light->origin, dist, surf->plane->normal, impact);
d = DotProduct (impact, surf->texinfo->vecs[0])
+ surf->texinfo->vecs[0][3] - surf->texturemins[0];
@ -383,7 +382,7 @@ calc_lighting_3 (msurface_t *surf, int ds, int dt)
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
maps++) {
scale = d_lightstylevalue[surf->styles[maps]] / 256.0;
VectorMA (ambientcolor, scale, lightmap, ambientcolor);
VectorMultAdd (ambientcolor, scale, lightmap, ambientcolor);
lightmap += se_size;
}
}

View file

@ -547,7 +547,7 @@ CL_RelinkEntities (void)
VectorCopy (state->msg_angles[0], ent->angles);
ent->pose1 = ent->pose2 = -1;
} else {
VectorMA (state->msg_origins[1], f, delta, ent->origin);
VectorMultAdd (state->msg_origins[1], f, delta, ent->origin);
// interpolate the origin and angles
for (j = 0; j < 3; j++) {
d = state->msg_angles[0][j] - state->msg_angles[1][j];
@ -573,7 +573,7 @@ CL_RelinkEntities (void)
if (dl) {
AngleVectors (ent->angles, fv, rv, uv);
VectorMA (ent->origin, 18, fv, dl->origin);
VectorMultAdd (ent->origin, 18, fv, dl->origin);
dl->origin[2] += 16;
dl->radius = 200 + (rand () & 31);
dl->die = cl.time + 0.1;

View file

@ -229,7 +229,7 @@ beam_setup (beam_t *b)
d = 0;
while (ent_count--) {
ent = &b->ent_list[ent_count];
VectorMA (org, d, dist, ent->origin);
VectorMultAdd (org, d, dist, ent->origin);
d += 1.0;
ent->model = b->model;
ent->angles[0] = pitch;
@ -494,7 +494,7 @@ CL_UpdateBeams (void)
(*ent)->angles[1] = yaw;
(*ent)->angles[2] = rand () % 360;
VectorMA(org, 30, dist, org);
VectorMultAdd(org, 30, dist, org);
d -= 30;
}
}

View file

@ -356,8 +356,8 @@ SV_Physics_Client (edict_t *ent, int num)
case MOVETYPE_NOCLIP:
if (!SV_RunThink (ent))
return;
VectorMA (SVvector (ent, origin), sv_frametime, SVvector (ent, velocity),
SVvector (ent, origin));
VectorMultAdd (SVvector (ent, origin), sv_frametime,
SVvector (ent, velocity), SVvector (ent, origin));
break;
default:

View file

@ -252,8 +252,8 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
if (VectorIsZero (SVvector (ent, velocity)))
break;
VectorMA (SVvector (ent, origin), time_left, SVvector (ent, velocity),
end);
VectorMultAdd (SVvector (ent, origin), time_left,
SVvector (ent, velocity), end);
trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins),
SVvector (ent, maxs), end, false, ent);
@ -561,10 +561,10 @@ SV_Physics_Noclip (edict_t *ent)
if (!SV_RunThink (ent))
return;
VectorMA (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
VectorMA (SVvector (ent, origin), sv_frametime, SVvector (ent, velocity),
SVvector (ent, origin));
VectorMultAdd (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
VectorMultAdd (SVvector (ent, origin), sv_frametime,
SVvector (ent, velocity), SVvector (ent, origin));
SV_LinkEdict (ent, false);
}
@ -629,8 +629,8 @@ SV_Physics_Toss (edict_t *ent)
SV_AddGravity (ent);
// move angles
VectorMA (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
VectorMultAdd (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
// move origin
VectorScale (SVvector (ent, velocity), sv_frametime, move);

View file

@ -887,7 +887,7 @@ PF_aim (progs_t *pr)
// try sending a trace straight
VectorCopy (*sv_globals.v_forward, dir);
VectorMA (start, 2048, dir, end);
VectorMultAdd (start, 2048, dir, end);
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
if (tr.ent && SVfloat (tr.ent, takedamage) == DAMAGE_AIM
&& (!teamplay->int_val || SVfloat (ent, team) <= 0

View file

@ -229,7 +229,7 @@ Cam_TryFlyby (player_state_t * self, player_state_t * player, vec3_t vec,
vectoangles (vec, v);
VectorCopy (v, pmove.angles);
VectorNormalize (vec);
VectorMA (player->origin, 800, vec, v);
VectorMultAdd (player->origin, 800, vec, v);
// v is endpos
// fake a player move
trace = Cam_DoTrace (player->origin, v);

View file

@ -1168,7 +1168,7 @@ CL_MuzzleFlash (void)
else
AngleVectors (pl->viewangles, fv, rv, uv);
VectorMA (pl->origin, 18, fv, dl->origin);
VectorMultAdd (pl->origin, 18, fv, dl->origin);
dl->radius = 200 + (rand () & 31);
dl->die = cl.time + 0.1;
dl->minlight = 32;

View file

@ -232,7 +232,7 @@ beam_setup (beam_t *b)
d = 0;
while (ent_count--) {
ent = &b->ent_list[ent_count];
VectorMA (org, d, dist, ent->origin);
VectorMultAdd (org, d, dist, ent->origin);
d += 1.0;
ent->model = b->model;
ent->angles[0] = pitch;

View file

@ -133,7 +133,7 @@ PM_FlyMove (void)
if (VectorIsZero (pmove.velocity))
break;
VectorMA (pmove.origin, time_left, pmove.velocity, end);
VectorMultAdd (pmove.origin, time_left, pmove.velocity, end);
trace = PM_PlayerMove (pmove.origin, end);
@ -240,7 +240,7 @@ PM_FlymodeMove (void)
}
PM_Accelerate (pmtmp, pmspeed, movevars.wateraccelerate);
VectorMA (pmove.origin, frametime, pmove.velocity, dest);
VectorMultAdd (pmove.origin, frametime, pmove.velocity, dest);
VectorCopy (dest, start);
start[2] += STEPSIZE + 1;
trace = PM_PlayerMove (start, dest);
@ -472,7 +472,7 @@ PM_WaterMove (void)
PM_Accelerate (wishdir, wishspeed, movevars.wateraccelerate);
// assume it is a stair or a slope, so press down from stepheight above
VectorMA (pmove.origin, frametime, pmove.velocity, dest);
VectorMultAdd (pmove.origin, frametime, pmove.velocity, dest);
VectorCopy (dest, start);
start[2] += STEPSIZE + 1;
trace = PM_PlayerMove (start, dest);
@ -667,7 +667,7 @@ CheckWaterJump (void)
flatforward[2] = 0;
VectorNormalize (flatforward);
VectorMA (pmove.origin, 24, flatforward, spot);
VectorMultAdd (pmove.origin, 24, flatforward, spot);
spot[2] += 8;
cont = PM_PointContents (spot);
if (cont != CONTENTS_SOLID)
@ -784,7 +784,7 @@ SpectatorMove (void)
pmove.velocity[i] += accelspeed * wishdir[i];
// move
VectorMA (pmove.origin, frametime, pmove.velocity, pmove.origin);
VectorMultAdd (pmove.origin, frametime, pmove.velocity, pmove.origin);
}
/*

View file

@ -255,8 +255,8 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
if (VectorIsZero (SVvector (ent, velocity)))
break;
VectorMA (SVvector (ent, origin), time_left, SVvector (ent, velocity),
end);
VectorMultAdd (SVvector (ent, origin), time_left,
SVvector (ent, velocity), end);
trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins),
SVvector (ent, maxs), end, false, ent);
@ -578,10 +578,10 @@ SV_Physics_Noclip (edict_t *ent)
if (!SV_RunThink (ent))
return;
VectorMA (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
VectorMA (SVvector (ent, origin), sv_frametime, SVvector (ent, velocity),
SVvector (ent, origin));
VectorMultAdd (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
VectorMultAdd (SVvector (ent, origin), sv_frametime,
SVvector (ent, velocity), SVvector (ent, origin));
SV_LinkEdict (ent, false);
}
@ -649,8 +649,8 @@ SV_Physics_Toss (edict_t *ent)
SV_AddGravity (ent);
// move angles
VectorMA (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
VectorMultAdd (SVvector (ent, angles), sv_frametime,
SVvector (ent, avelocity), SVvector (ent, angles));
// move origin
VectorScale (SVvector (ent, velocity), sv_frametime, move);

View file

@ -919,7 +919,7 @@ PF_aim (progs_t *pr)
// try sending a trace straight
VectorCopy (*sv_globals.v_forward, dir);
VectorMA (start, 2048, dir, end);
VectorMultAdd (start, 2048, dir, end);
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
if (tr.ent && SVfloat (tr.ent, takedamage) == DAMAGE_AIM
&& (!teamplay->int_val || SVfloat (ent, team) <= 0

View file

@ -98,7 +98,7 @@ BaseWindingForPlane (plane_t *p)
}
v = DotProduct (vup, p->normal);
VectorMA (vup, -v, p->normal, vup);
VectorMultSub (vup, v, p->normal, vup);
_VectorNormalize (vup);
VectorScale (p->normal, p->dist, org);

View file

@ -141,7 +141,7 @@ FindEdge (vec3_t p1, vec3_t p2, vec_t *t1, vec_t *t2)
*t1 = DotProduct (p1, dir);
*t2 = DotProduct (p2, dir);
VectorMA (p1, -*t1, dir, origin);
VectorMultSub (p1, *t1, dir, origin);
if (*t1 > *t2) {
temp = *t1;
@ -358,7 +358,7 @@ FixFaceEdges (face_t *f)
for (k = superface->numpoints; k > j; k--) {
VectorCopy (superface->pts[k - 1], superface->pts[k]);
}
VectorMA (w->origin, v->t, w->dir, superface->pts[j]);
VectorMultAdd (w->origin, v->t, w->dir, superface->pts[j]);
superface->numpoints++;
goto restart;
}

View file

@ -177,7 +177,7 @@ CalcFaceVectors (lightinfo_t *l)
len = VectorLength (l->worldtotex[i]);
dist = DotProduct (l->worldtotex[i], l->facenormal);
dist *= distscale;
VectorMA (l->worldtotex[i], -dist, texnormal, l->textoworld[i]);
VectorMultSub (l->worldtotex[i], dist, texnormal, l->textoworld[i]);
VectorScale (l->textoworld[i], (1 / len) * (1 / len),
l->textoworld[i]);
}
@ -190,7 +190,7 @@ CalcFaceVectors (lightinfo_t *l)
// project back to the face plane
dist = DotProduct (l->texorg, l->facenormal) - l->facedist - 1;
dist *= distscale;
VectorMA (l->texorg, -dist, texnormal, l->texorg);
VectorMultSub (l->texorg, dist, texnormal, l->texorg);
}
/*
@ -330,7 +330,7 @@ CalcPoints (lightinfo_t *l)
// move surf 8 pixels towards the center
VectorSubtract (facemid, surf, move);
_VectorNormalize (move);
VectorMA (surf, 8, move, surf);
VectorMultAdd (surf, 8, move, surf);
}
if (i == 2)
c_bad++;