From 8c9daf023ed4c53cd4c0a99532c58e156edc26b2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 5 Dec 2001 19:59:55 +0000 Subject: [PATCH] possible optimisation for PF_findradius. needs more testing --- qw/source/sv_pr_cmds.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index a1b7d4955..e0e19ad57 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -600,15 +600,16 @@ PF_findradius (progs_t *pr) { edict_t *ent, *chain; float rad; - float *org, *eorigin, *emins, *emaxs; + float *eorigin, *emins, *emaxs; int i, j; - vec3_t eorg; + vec3_t eorg, org; chain = (edict_t *) sv.edicts; - org = G_VECTOR (pr, OFS_PARM0); + VectorScale (G_VECTOR (pr, OFS_PARM0), 2, org); rad = G_FLOAT (pr, OFS_PARM1); - rad *= rad; // Square early, sqrt never. + // * 4 because the * 0.5 was removed from the emins-emaxs average + rad *= 4 * rad; // Square early, sqrt never ent = NEXT_EDICT (pr, sv.edicts); for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) { @@ -621,7 +622,7 @@ PF_findradius (progs_t *pr) emaxs = SVvector (ent, maxs); for (j = 0; j < 3; j++) - eorg[j] = org[j] - (eorigin[j] + (emins[j] + emaxs[j]) * 0.5); + eorg[j] = org[j] - 2 * eorigin[j] - emins[j] - emaxs[j]; if (DotProduct (eorg, eorg) > rad) continue;