From 0a8867fde9d4a0caa01c54aa7abb43c3e4f7ffc6 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 3 Sep 2003 22:17:04 +0000 Subject: [PATCH] replace all VectorSubtract (vec3_origin, ... and VectorCopy (vec3_origin, ... with VectorNegate (... and VectorZero (..., respectively. Should be a small speedup. --- libs/video/renderer/sw/sw_rpart.c | 12 ++++++------ libs/video/renderer/sw32/sw32_rpart.c | 12 ++++++------ nq/source/sv_cl_phys.c | 8 ++++---- nq/source/sv_phys.c | 12 ++++++------ qw/source/cl_cam.c | 6 +++--- qw/source/cl_ents.c | 2 +- qw/source/cl_parse.c | 2 +- qw/source/sv_phys.c | 12 ++++++------ qw/source/sv_user.c | 4 ++-- tools/qflight/source/ltface.c | 4 ++-- tools/qfmodelgen/source/modelgen.c | 10 +++++----- tools/qfvis/source/flow.c | 6 +++--- tools/qfvis/source/qfvis.c | 4 ++-- 13 files changed, 47 insertions(+), 47 deletions(-) diff --git a/libs/video/renderer/sw/sw_rpart.c b/libs/video/renderer/sw/sw_rpart.c index d28b82f50..3bddba561 100644 --- a/libs/video/renderer/sw/sw_rpart.c +++ b/libs/video/renderer/sw/sw_rpart.c @@ -108,7 +108,7 @@ R_ReadPointFile_f (void) p->die = 99999; p->color = (-c) & 15; p->type = pt_static; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); VectorCopy (org, p->org); } @@ -379,7 +379,7 @@ R_RocketTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->ramp = (rand () & 3); @@ -416,7 +416,7 @@ R_GrenadeTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->ramp = (rand () & 3) + 2; @@ -453,7 +453,7 @@ R_BloodTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->type = pt_slowgrav; @@ -490,7 +490,7 @@ R_SlightBloodTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->type = pt_slowgrav; @@ -616,7 +616,7 @@ R_VoorTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 0.3; p->type = pt_static; diff --git a/libs/video/renderer/sw32/sw32_rpart.c b/libs/video/renderer/sw32/sw32_rpart.c index fb10c23b5..2c9c81105 100644 --- a/libs/video/renderer/sw32/sw32_rpart.c +++ b/libs/video/renderer/sw32/sw32_rpart.c @@ -109,7 +109,7 @@ R_ReadPointFile_f (void) p->die = 99999; p->color = (-c) & 15; p->type = pt_static; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); VectorCopy (org, p->org); } @@ -391,7 +391,7 @@ R_RocketTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->ramp = (rand () & 3); @@ -428,7 +428,7 @@ R_GrenadeTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->ramp = (rand () & 3) + 2; @@ -465,7 +465,7 @@ R_BloodTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->type = pt_slowgrav; @@ -502,7 +502,7 @@ R_SlightBloodTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 2; p->type = pt_slowgrav; @@ -628,7 +628,7 @@ R_VoorTrail_QF (entity_t *ent) p->next = active_particles; active_particles = p; - VectorCopy (vec3_origin, p->vel); + VectorZero (p->vel); p->die = r_realtime + 0.3; p->type = pt_static; diff --git a/nq/source/sv_cl_phys.c b/nq/source/sv_cl_phys.c index 05e1a118c..9952188be 100644 --- a/nq/source/sv_cl_phys.c +++ b/nq/source/sv_cl_phys.c @@ -158,7 +158,7 @@ SV_TryUnstick (edict_t *ent, vec3_t oldvel) trace_t steptrace; VectorCopy (SVvector (ent, origin), oldorg); - VectorCopy (vec3_origin, dir); + VectorZero (dir); for (i = 0; i < 8; i++) { // try pushing a little in an axial direction @@ -214,7 +214,7 @@ SV_TryUnstick (edict_t *ent, vec3_t oldvel) VectorCopy (oldorg, SVvector (ent, origin)); } - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 7; // still not moving } @@ -261,8 +261,8 @@ SV_WalkMove (edict_t *ent) // try moving up and forward to go up a step VectorCopy (oldorg, SVvector (ent, origin)); // back to start pos - VectorCopy (vec3_origin, upmove); - VectorCopy (vec3_origin, downmove); + VectorZero (upmove); + VectorZero (downmove); upmove[2] = STEPSIZE; downmove[2] = -STEPSIZE + oldvel[2] * sv_frametime; diff --git a/nq/source/sv_phys.c b/nq/source/sv_phys.c index b5e61abd9..b71f898be 100644 --- a/nq/source/sv_phys.c +++ b/nq/source/sv_phys.c @@ -259,7 +259,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) SVvector (ent, maxs), end, false, ent); if (trace.allsolid) { // entity is trapped in another solid - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 3; } @@ -299,7 +299,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) // cliped to another plane if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 3; } @@ -322,7 +322,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) VectorCopy (new_velocity, SVvector (ent, velocity)); } else { // go along the crease if (numplanes != 2) { - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 7; } CrossProduct (planes[0], planes[1], dir); @@ -333,7 +333,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) // if original velocity is against the original velocity, stop dead // to avoid tiny occilations in sloping corners if (DotProduct (SVvector (ent, velocity), primal_velocity) <= 0) { - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return blocked; } } @@ -655,8 +655,8 @@ SV_Physics_Toss (edict_t *ent) SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, trace.ent); - VectorCopy (vec3_origin, SVvector (ent, velocity)); - VectorCopy (vec3_origin, SVvector (ent, avelocity)); + VectorZero (SVvector (ent, velocity)); + VectorZero (SVvector (ent, avelocity)); } } // check for in water diff --git a/qw/source/cl_cam.c b/qw/source/cl_cam.c index 807664d93..59866ab18 100644 --- a/qw/source/cl_cam.c +++ b/qw/source/cl_cam.c @@ -209,7 +209,7 @@ Cam_DoTrace (vec3_t vec1, vec3_t vec2) memset (&pmove, 0, sizeof (pmove)); pmove.numphysent = 1; - VectorCopy (vec3_origin, pmove.physents[0].origin); + VectorZero (pmove.physents[0].origin); pmove.physents[0].model = cl.worldmodel; #endif @@ -327,7 +327,7 @@ InitFlyby (player_state_t * self, player_state_t * player, int checkvis) VectorCopy (vec2, vec); } // invert - VectorSubtract (vec3_origin, forward, vec2); + VectorNegate (forward, vec2); if ((f = Cam_TryFlyby (self, player, vec2, checkvis)) < max) { max = f; VectorCopy (vec2, vec); @@ -338,7 +338,7 @@ InitFlyby (player_state_t * self, player_state_t * player, int checkvis) VectorCopy (vec2, vec); } // invert - VectorSubtract (vec3_origin, right, vec2); + VectorNegate (right, vec2); if ((f = Cam_TryFlyby (self, player, vec2, checkvis)) < max) { max = f; VectorCopy (vec2, vec); diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index 6bf811f58..6a93ca7e1 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -974,7 +974,7 @@ CL_SetSolidEntities (void) packet_entities_t *pak; pmove.physents[0].model = cl.worldmodel; - VectorCopy (vec3_origin, pmove.physents[0].origin); + VectorZero (pmove.physents[0].origin); pmove.physents[0].info = 0; pmove.numphysent = 1; diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index a42537e89..efb49a847 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -1439,7 +1439,7 @@ CL_ParseServerMessage (void) for (i = 0; i < 3; i++) Con_DPrintf ("%f ", cl.simangles[i]); Con_DPrintf ("\n"); - VectorCopy (vec3_origin, cl.simvel); + VectorZero (cl.simvel); // automatic fraglogging (by elmex) // XXX: Should this _really_ called here? diff --git a/qw/source/sv_phys.c b/qw/source/sv_phys.c index 674be959b..109d4d4e6 100644 --- a/qw/source/sv_phys.c +++ b/qw/source/sv_phys.c @@ -262,7 +262,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) SVvector (ent, maxs), end, false, ent); if (trace.allsolid) { // entity is trapped in another solid - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 3; } @@ -302,7 +302,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) // cliped to another plane if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 3; } @@ -325,7 +325,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) VectorCopy (new_velocity, SVvector (ent, velocity)); } else { // go along the crease if (numplanes != 2) { - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return 7; } CrossProduct (planes[0], planes[1], dir); @@ -336,7 +336,7 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) // if original velocity is against the original velocity, stop dead // to avoid tiny occilations in sloping corners if (DotProduct (SVvector (ent, velocity), primal_velocity) <= 0) { - VectorCopy (vec3_origin, SVvector (ent, velocity)); + VectorZero (SVvector (ent, velocity)); return blocked; } } @@ -675,8 +675,8 @@ SV_Physics_Toss (edict_t *ent) SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; SVentity (ent, groundentity) = EDICT_TO_PROG (&sv_pr_state, trace.ent); - VectorCopy (vec3_origin, SVvector (ent, velocity)); - VectorCopy (vec3_origin, SVvector (ent, avelocity)); + VectorZero (SVvector (ent, velocity)); + VectorZero (SVvector (ent, avelocity)); } } // check for in water diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 63463f434..da956659e 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -444,8 +444,8 @@ SV_SpawnSpectator (void) int i; edict_t *e; - VectorCopy (vec3_origin, SVvector (sv_player, origin)); - VectorCopy (vec3_origin, SVvector (sv_player, view_ofs)); + VectorZero (SVvector (sv_player, origin)); + VectorZero (SVvector (sv_player, view_ofs)); SVvector (sv_player, view_ofs)[2] = 22; // search for an info_playerstart to spawn the spectator at diff --git a/tools/qflight/source/ltface.c b/tools/qflight/source/ltface.c index 78fe6d48c..8f67a29c8 100644 --- a/tools/qflight/source/ltface.c +++ b/tools/qflight/source/ltface.c @@ -166,7 +166,7 @@ CalcFaceVectors (lightinfo_t *l) fprintf (stderr, "Texture axis perpendicular to face"); if (distscale < 0) { distscale = -distscale; - VectorSubtract (vec3_origin, texnormal, texnormal); + VectorNegate (texnormal, texnormal); } // distscale is the ratio of the distance along the @@ -481,7 +481,7 @@ LightFace (int surfnum) VectorCopy (bsp->planes[f->planenum].normal, l.facenormal); l.facedist = bsp->planes[f->planenum].dist; if (f->side) { - VectorSubtract (vec3_origin, l.facenormal, l.facenormal); + VectorNegate (l.facenormal, l.facenormal); l.facedist = -l.facedist; } diff --git a/tools/qfmodelgen/source/modelgen.c b/tools/qfmodelgen/source/modelgen.c index 5680514b4..78e8d52e9 100644 --- a/tools/qfmodelgen/source/modelgen.c +++ b/tools/qfmodelgen/source/modelgen.c @@ -122,11 +122,11 @@ ClearModel (void) scale = 0; scale_up = 1.0; - VectorCopy (vec3_origin, adjust); - VectorCopy (vec3_origin, mins); - VectorCopy (vec3_origin, maxs); - VectorCopy (vec3_origin, framesmins); - VectorCopy (vec3_origin, framesmaxs); + VectorZero (adjust); + VectorZero (mins); + VectorZero (maxs); + VectorZero (framesmins); + VectorZero (framesmaxs); degeneratetris = 0; cdset = false; diff --git a/tools/qfvis/source/flow.c b/tools/qfvis/source/flow.c index a20ca3102..d57474150 100644 --- a/tools/qfvis/source/flow.c +++ b/tools/qfvis/source/flow.c @@ -146,7 +146,7 @@ ClipToSeparators (winding_t *source, winding_t *pass, winding_t *target, // flip the normal if the source portal is backwards if (fliptest) { - VectorSubtract (vec3_origin, plane.normal, plane.normal); + VectorNegate (plane.normal, plane.normal); plane.dist = -plane.dist; } @@ -173,7 +173,7 @@ ClipToSeparators (winding_t *source, winding_t *pass, winding_t *target, // flip the normal if we want the back side if (flipclip) { - VectorSubtract (vec3_origin, plane.normal, plane.normal); + VectorNegate (plane.normal, plane.normal); plane.dist = -plane.dist; } @@ -251,7 +251,7 @@ RecursiveClusterFlow (int clusternum, threaddata_t *thread, pstack_t *prevstack) // get plane of portal, point normal into the neighbor cluster stack.portalplane = portal->plane; - VectorSubtract (vec3_origin, portal->plane.normal, backplane.normal); + VectorNegate (portal->plane.normal, backplane.normal); backplane.dist = -portal->plane.dist; if (_VectorCompare (prevstack->portalplane.normal, backplane.normal)) diff --git a/tools/qfvis/source/qfvis.c b/tools/qfvis/source/qfvis.c index e2b64d242..773c76a06 100644 --- a/tools/qfvis/source/qfvis.c +++ b/tools/qfvis/source/qfvis.c @@ -554,7 +554,7 @@ FindPassages (winding_t *source, winding_t *pass) // flip the normal if the source portal is backwards if (fliptest) { - VectorSubtract (vec3_origin, plane.normal, plane.normal); + VectorNegate (plane.normal, plane.normal); plane.dist = -plane.dist; } @@ -731,7 +731,7 @@ LoadPortals (char *name) cluster->numportals++; portal->winding = winding; - VectorSubtract (vec3_origin, plane.normal, portal->plane.normal); + VectorNegate (plane.normal, portal->plane.normal); portal->plane.dist = -plane.dist; portal->cluster = clusternums[1]; portal++;