make avg an macro (AVG) in defs.qh for slightlyb better code, and implement

it in both the usual mathematical way and such that it will work for ints,
floats and vects.
This commit is contained in:
Bill Currie 2001-07-25 19:23:26 +00:00
parent 01c70cb67b
commit 11a114965f
2 changed files with 3 additions and 6 deletions

View file

@ -1300,3 +1300,5 @@
#define AURA_INVIS 4
#include "ofndefs.qh"
#define AVG(a,b) (((a) + (b)) * 0.5)

View file

@ -507,11 +507,6 @@ void() Field_touch =
Field_touch_SUB();
};
float(float a, float b) avg =
{
return a + (b - a) / 2;
};
//===================================================================================
// creates the force field between the 2 generators (only if none currently on)
@ -574,7 +569,7 @@ void(entity gen1, entity gen2) Create_Field =
tfield.maxs = tfield.size * 0.5; // FIXME: / 2 is broken
tfield.mins = tfield.maxs * -1; // FIXME: -1 * only did first float
tfield.origin = gen1.origin + (gen2.origin - gen1.origin) * 0.5;
tfield.origin_z = avg (gen1.absmax_z, gen2.absmax_z) - tfield.maxs_z;
tfield.origin_z = AVG (gen1.absmax_z, gen2.absmax_z) - tfield.maxs_z;
tfield.absmax = tfield.origin + tfield.maxs;
tfield.absmin = tfield.origin + tfield.mins;
// tfield.angles = gen2.origin - gen1.origin; // for rotation?