Remove vdist
FossilOrigin-Name: 62594248024eb944735c20b4877f3e6ea07cd93e7f723e718986e86d3c43e944
This commit is contained in:
parent
daa4c19312
commit
d8f4f44468
8 changed files with 34 additions and 18 deletions
|
@ -271,7 +271,8 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
self.yaw = self.targetYaw;
|
||||
}
|
||||
|
||||
vdist(disttoenemy, vectoenemy, self.origin, self.enemy.origin);
|
||||
float disttoenemy =
|
||||
OFDistanceOfVectors3D(self.origin, self.enemy.origin);
|
||||
self.pitch =
|
||||
atan2(self.enemy.origin.z - self.origin.z, disttoenemy) * 180 / PI;
|
||||
|
||||
|
@ -469,7 +470,8 @@ enemylos(Monster *m, OFVector3D *v)
|
|||
}
|
||||
} else {
|
||||
v.z += monster.eyeHeight;
|
||||
vdist(dist, t, monster.origin, v);
|
||||
float dist =
|
||||
OFDistanceOfVectors3D(monster.origin, v);
|
||||
v.z -= monster.eyeHeight;
|
||||
|
||||
if (dist < 4)
|
||||
|
|
|
@ -286,10 +286,6 @@ extern bool demoplayback;
|
|||
#define PI (3.1415927f)
|
||||
#define PI2 (2 * PI)
|
||||
|
||||
// simplistic vector ops
|
||||
#define vdist(d, v, e, s) \
|
||||
OFVector3D v = OFSubtractVectors3D(s, e); \
|
||||
float d = sqrtf(OFDotProductOfVectors3D(v, v));
|
||||
#define vreject(v, u, max) \
|
||||
((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
|
||||
(v).y > (u).y + (max) || (v).y < (u).y - (max))
|
||||
|
|
|
@ -321,7 +321,7 @@ checkitems()
|
|||
|
||||
OFVector3D v = OFMakeVector3D(
|
||||
e.x, e.y, (float)S(e.x, e.y)->floor + player1.eyeHeight);
|
||||
vdist(dist, t, player1.origin, v);
|
||||
float dist = OFDistanceOfVectors3D(player1.origin, v);
|
||||
|
||||
if (dist < (e.type == TELEPORT ? 4 : 2.5))
|
||||
pickup(i, player1);
|
||||
|
|
|
@ -152,7 +152,8 @@ particle_splash(int type, int num, int fade, const OFVector3D *p)
|
|||
void
|
||||
particle_trail(int type, int fade, const OFVector3D *s, const OFVector3D *e)
|
||||
{
|
||||
vdist(d, v, *s, *e);
|
||||
float d = OFDistanceOfVectors3D(*s, *e);
|
||||
OFVector3D v = OFSubtractVectors3D(*s, *e);
|
||||
v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f));
|
||||
OFVector3D p = *s;
|
||||
for (int i = 0; i < ((int)d * 2); i++) {
|
||||
|
|
|
@ -497,7 +497,8 @@ demoplaybackstep()
|
|||
fixwrap(a, player1);
|
||||
fixwrap(c, player1);
|
||||
fixwrap(z, player1);
|
||||
vdist(dist, v, z.origin, c.origin);
|
||||
float dist =
|
||||
OFDistanceOfVectors3D(z.origin, c.origin);
|
||||
// if teleport or spawn, don't interpolate
|
||||
if (dist < 16) {
|
||||
catmulrom(z.origin, a.origin, b.origin,
|
||||
|
|
12
src/sound.m
12
src/sound.m
|
@ -111,10 +111,15 @@ static void
|
|||
updatechanvol(int chan, const OFVector3D *loc)
|
||||
{
|
||||
int vol = soundvol, pan = 255 / 2;
|
||||
|
||||
if (loc) {
|
||||
vdist(dist, v, *loc, player1.origin);
|
||||
vol -= (int)(dist * 3 * soundvol /
|
||||
255); // simple mono distance attenuation
|
||||
OFVector3D origin = player1.origin;
|
||||
float dist = OFDistanceOfVectors3D(*loc, origin);
|
||||
OFVector3D v = OFSubtractVectors3D(*loc, origin);
|
||||
|
||||
// simple mono distance attenuation
|
||||
vol -= (int)(dist * 3 * soundvol / 255);
|
||||
|
||||
if (stereo && (v.x != 0 || v.y != 0)) {
|
||||
// relative angle of sound along X-Y axis
|
||||
float yaw =
|
||||
|
@ -123,6 +128,7 @@ updatechanvol(int chan, const OFVector3D *loc)
|
|||
pan = (int)(255.9f * (0.5 * sin(yaw) + 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
vol = (vol * MAXVOL) / 255;
|
||||
Mix_Volume(chan, vol);
|
||||
Mix_SetPanning(chan, 255 - pan, pan);
|
||||
|
|
20
src/weapon.m
20
src/weapon.m
|
@ -73,7 +73,7 @@ COMMAND(weapon, ARG_3STR, ^(OFString *a1, OFString *a2, OFString *a3) {
|
|||
void
|
||||
createrays(const OFVector3D *from, const OFVector3D *to)
|
||||
{
|
||||
vdist(dist, dvec, *from, *to);
|
||||
float dist = OFDistanceOfVectors3D(*from, *to);
|
||||
float f = dist * SGSPREAD / 1000;
|
||||
for (int i = 0; i < SGRAYS; i++)
|
||||
#define RNDD (rnd(101) - 50) * f
|
||||
|
@ -186,13 +186,19 @@ radialeffect(
|
|||
{
|
||||
if (o.state != CS_ALIVE)
|
||||
return;
|
||||
vdist(dist, temp, *v, o.origin);
|
||||
|
||||
OFVector3D origin = o.origin;
|
||||
float dist = OFDistanceOfVectors3D(*v, origin);
|
||||
OFVector3D temp = OFSubtractVectors3D(*v, origin);
|
||||
dist -= 2; // account for eye distance imprecision
|
||||
|
||||
if (dist < RL_DAMRAD) {
|
||||
if (dist < 0)
|
||||
dist = 0;
|
||||
|
||||
int damage = (int)(qdam * (1 - (dist / RL_DAMRAD)));
|
||||
hit(cn, damage, o, at);
|
||||
|
||||
temp =
|
||||
OFMultiplyVector3D(temp, (RL_DAMRAD - dist) * damage / 800);
|
||||
o.velocity = OFAddVectors3D(o.velocity, temp);
|
||||
|
@ -264,7 +270,9 @@ moveprojectiles(float time)
|
|||
int qdam = guns[p.gun].damage * (p.owner.quadMillis ? 4 : 1);
|
||||
if ([p.owner isKindOfClass:Monster.class])
|
||||
qdam /= MONSTERDAMAGEFACTOR;
|
||||
vdist(dist, v, p.o, p.to);
|
||||
OFVector3D po = p.o, pto = pto;
|
||||
float dist = OFDistanceOfVectors3D(po, pto);
|
||||
OFVector3D v = OFSubtractVectors3D(po, pto);
|
||||
float dtime = dist * 1000 / p.speed;
|
||||
if (time > dtime)
|
||||
dtime = time;
|
||||
|
@ -348,7 +356,8 @@ hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at,
|
|||
const OFVector3D *from, const OFVector3D *to)
|
||||
{
|
||||
hit(target, damage, d, at);
|
||||
vdist(dist, v, *from, *to);
|
||||
float dist = OFDistanceOfVectors3D(*from, *to);
|
||||
OFVector3D v = OFSubtractVectors3D(*from, *to);
|
||||
v = OFMultiplyVector3D(v, damage / dist / 50);
|
||||
d.velocity = OFAddVectors3D(d.velocity, v);
|
||||
}
|
||||
|
@ -398,7 +407,8 @@ shoot(DynamicEntity *d, const OFVector3D *targ)
|
|||
OFVector3D to = *targ;
|
||||
from.z -= 0.2f; // below eye
|
||||
|
||||
vdist(dist, unitv, from, to);
|
||||
float dist = OFDistanceOfVectors3D(from, to);
|
||||
OFVector3D unitv = OFSubtractVectors3D(from, to);
|
||||
unitv = OFMultiplyVector3D(unitv, 1.0f / dist);
|
||||
OFVector3D kickback =
|
||||
OFMultiplyVector3D(unitv, guns[d.gunSelect].kickamount * -0.01f);
|
||||
|
|
|
@ -298,7 +298,7 @@ closestent() // used for delent and edit mode ent display
|
|||
return;
|
||||
|
||||
OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
|
||||
vdist(dist, t, player1.origin, v);
|
||||
float dist = OFDistanceOfVectors3D(player1.origin, v);
|
||||
if (dist < bdist) {
|
||||
best = i;
|
||||
bdist = dist;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue