mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- added vector variants of FindDistance2D and FindDistance3D
This commit is contained in:
parent
29da39dda0
commit
34f14aa4c3
12 changed files with 35 additions and 31 deletions
|
@ -3,3 +3,13 @@
|
|||
int FindDistance2D(int x, int y);
|
||||
double fFindDistance2D(int x, int y);
|
||||
int FindDistance3D(int x, int y, int z);
|
||||
|
||||
inline int FindDistance3D(const vec3_t& vec)
|
||||
{
|
||||
return FindDistance3D(vec.X, vec.Y, vec.Z);
|
||||
}
|
||||
|
||||
inline int FindDistance2D(const vec2_t& vec)
|
||||
{
|
||||
return FindDistance2D(vec.X, vec.Y);
|
||||
}
|
|
@ -2988,7 +2988,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
|
|||
}
|
||||
if (actor->temp_data[4] == 2)
|
||||
{
|
||||
int l = FindDistance2D(Owner->spr.pos.X - actor->spr.pos.X, Owner->spr.pos.Y - actor->spr.pos.Y);
|
||||
int l = FindDistance2D(Owner->spr.pos.vec2 - actor->spr.pos.vec2);
|
||||
|
||||
if (l <= 128)
|
||||
actor->spr.xvel = 0;
|
||||
|
|
|
@ -1681,7 +1681,7 @@ static void weaponcommon_d(DDukeActor* proj)
|
|||
MulScale(k, bsin(proj->spr.ang), 14), ll, CLIPMASK1, coll);
|
||||
|
||||
if (proj->spr.picnum == RPG && proj->temp_actor != nullptr)
|
||||
if (FindDistance2D(proj->spr.pos.X - proj->temp_actor->spr.pos.X, proj->spr.pos.Y - proj->temp_actor->spr.pos.Y) < 256)
|
||||
if (FindDistance2D(proj->spr.pos.vec2 - proj->temp_actor->spr.pos.vec2) < 256)
|
||||
coll.setSprite(proj->temp_actor);
|
||||
|
||||
if (!proj->spr.insector())
|
||||
|
|
|
@ -1379,7 +1379,7 @@ static void weaponcommon_r(DDukeActor *proj)
|
|||
MulScale(k, bsin(proj->spr.ang), 14), ll, CLIPMASK1, coll);
|
||||
|
||||
if ((proj->spr.picnum == RPG || (isRRRA() && isIn(proj->spr.picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr)
|
||||
if (FindDistance2D(proj->spr.pos.X - proj->temp_actor->spr.pos.X, proj->spr.pos.Y - proj->temp_actor->spr.pos.Y) < 256)
|
||||
if (FindDistance2D(proj->spr.pos.vec2 - proj->temp_actor->spr.pos.vec2) < 256)
|
||||
coll.setSprite(proj->temp_actor);
|
||||
|
||||
if (!proj->spr.insector()) // || (isRR() && proj->spr.sector()->filler == 800))
|
||||
|
|
|
@ -175,7 +175,7 @@ int hits(DDukeActor* actor)
|
|||
else zoff = 0;
|
||||
|
||||
hitscan(actor->spr.pos, actor->spr.sector(), { bcos(actor->spr.ang), bsin(actor->spr.ang), 0 }, hit, CLIPMASK1);
|
||||
return (FindDistance2D(hit.hitpos.X - actor->spr.pos.X, hit.hitpos.Y - actor->spr.pos.Y));
|
||||
return (FindDistance2D(hit.hitpos.vec2 - actor->spr.pos.vec2));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -200,7 +200,7 @@ int hitasprite(DDukeActor* actor, DDukeActor** hitsp)
|
|||
if (hit.hitWall != nullptr && (hit.hitWall->cstat & CSTAT_WALL_MASKED) && badguy(actor))
|
||||
return((1 << 30));
|
||||
|
||||
return (FindDistance2D(hit.hitpos.X - actor->spr.pos.X, hit.hitpos.Y - actor->spr.pos.Y));
|
||||
return (FindDistance2D(hit.hitpos.vec2 - actor->spr.pos.vec2));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -216,7 +216,7 @@ int hitawall(struct player_struct* p, walltype** hitw)
|
|||
hitscan(p->pos, p->cursector, { p->angle.ang.bcos(), p->angle.ang.bsin(), 0 }, hit, CLIPMASK0);
|
||||
if (hitw) *hitw = hit.hitWall;
|
||||
|
||||
return (FindDistance2D(hit.hitpos.X - p->pos.X, hit.hitpos.Y - p->pos.Y));
|
||||
return (FindDistance2D(hit.hitpos.vec2 - p->pos.vec2));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -780,7 +780,7 @@ void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors)
|
|||
|
||||
for (auto& wal : wallsofsector(sectp))
|
||||
{
|
||||
d = FindDistance2D(actor->spr.pos.X - wal.pos.X, actor->spr.pos.Y - wal.pos.Y);
|
||||
d = FindDistance2D(actor->spr.pos.vec2 - wal.pos);
|
||||
if (d < q)
|
||||
{
|
||||
q = d;
|
||||
|
@ -794,7 +794,7 @@ void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors)
|
|||
|
||||
for (auto& wal : wallsofsector(sectp))
|
||||
{
|
||||
d = FindDistance2D(actor->spr.pos.X - wal.pos.X, actor->spr.pos.Y - wal.pos.Y);
|
||||
d = FindDistance2D(actor->spr.pos.vec2 - wal.pos);
|
||||
if (d < q && &wal != actor->temp_walls[0])
|
||||
{
|
||||
q = d;
|
||||
|
|
|
@ -254,12 +254,6 @@ int CanHitPlayer(DSWActor* actor)
|
|||
else
|
||||
return false;
|
||||
|
||||
// so actors won't shoot straight up at you
|
||||
// need to be a bit of a distance away
|
||||
// before they have a valid shot
|
||||
// if (labs(zvect / FindDistance2D(targ->spr.x - actor->spr.x, targ->spr.y - actor->spr.y)) > 200)
|
||||
// return(false);
|
||||
|
||||
FAFhitscan(actor->spr.pos.X, actor->spr.pos.Y, zhs, actor->spr.sector(),
|
||||
xvect,
|
||||
yvect,
|
||||
|
|
|
@ -1900,7 +1900,7 @@ DSWActor* DoFlagRangeTest(DSWActor* actor, int range)
|
|||
if (!FAFcansee(itActor, actor))
|
||||
continue;
|
||||
|
||||
dist = FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z);
|
||||
dist = FindDistance3D(actor->spr.pos - itActor->spr.pos);
|
||||
if (dist > range)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1164,7 +1164,7 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets
|
|||
|
||||
// Only look at closest ones
|
||||
//if ((dist = Distance(actor->spr.x, actor->spr.y, itActor->spr.x, itActor->spr.y)) > PICK_DIST)
|
||||
if ((dist = FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z)) > PICK_DIST)
|
||||
if ((dist = FindDistance3D(actor->spr.pos - itActor->spr.pos)) > PICK_DIST)
|
||||
continue;
|
||||
|
||||
if (skip_targets != 2) // Used for spriteinfo mode
|
||||
|
@ -2624,7 +2624,7 @@ void DoPlayerMoveVehicle(PLAYERp pp)
|
|||
{ MOVEx(256, pp->angle.ang.asbuild()), MOVEy(256, pp->angle.ang.asbuild()), 0 },
|
||||
hit, CLIPMASK_PLAYER);
|
||||
|
||||
if (FindDistance2D(hit.hitpos.X - hit_pos.X, hit.hitpos.Y - hit_pos.Y) < 800)
|
||||
if (FindDistance2D(hit.hitpos.vec2 - hit_pos.vec2) < 800)
|
||||
{
|
||||
if (hit.hitWall)
|
||||
actor->user.coll.setWall(wallnum(hit.hitWall));
|
||||
|
@ -6784,7 +6784,7 @@ int SearchSpawnPosition(PLAYERp pp)
|
|||
|
||||
if (opp != pp) // don't test for yourself
|
||||
{
|
||||
if (FindDistance3D(spawn_sprite->spr.pos.X - opp->pos.X, spawn_sprite->spr.pos.Y - opp->pos.Y, spawn_sprite->spr.pos.Z - opp->pos.Z) < 1000)
|
||||
if (FindDistance3D(spawn_sprite->spr.pos - opp->pos) < 1000)
|
||||
{
|
||||
blocked = true;
|
||||
break;
|
||||
|
|
|
@ -173,7 +173,7 @@ void QuakeViewChange(PLAYERp pp, int *z_diff, int *x_diff, int *y_diff, short *a
|
|||
SWStatIterator it(STAT_QUAKE_ON);
|
||||
while (actor = it.Next())
|
||||
{
|
||||
dist = FindDistance3D(pp->pos.X - actor->spr.pos.X, pp->pos.Y - actor->spr.pos.Y, pp->pos.Z - actor->spr.pos.Z);
|
||||
dist = FindDistance3D(pp->pos - actor->spr.pos);
|
||||
|
||||
// shake whole level
|
||||
if (QUAKE_TestDontTaper(actor))
|
||||
|
|
|
@ -1138,7 +1138,7 @@ void WeaponExplodeSectorInRange(DSWActor* wActor)
|
|||
while (auto actor = it.Next())
|
||||
{
|
||||
// test to see if explosion is close to crack sprite
|
||||
dist = FindDistance3D(wActor->spr.pos.X - actor->spr.pos.X, wActor->spr.pos.Y - actor->spr.pos.Y, wActor->spr.pos.Z - actor->spr.pos.Z);
|
||||
dist = FindDistance3D(wActor->spr.pos - actor->spr.pos);
|
||||
|
||||
if (actor->spr.clipdist == 0)
|
||||
continue;
|
||||
|
|
|
@ -8601,7 +8601,7 @@ int DoMineRangeTest(DSWActor* actor, int range)
|
|||
if (itActor->user.ID == GIRLNINJA_RUN_R0 && !ownerisplayer)
|
||||
continue;
|
||||
|
||||
dist = FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z);
|
||||
dist = FindDistance3D(actor->spr.pos - itActor->spr.pos);
|
||||
if (dist > range)
|
||||
continue;
|
||||
|
||||
|
@ -10041,7 +10041,7 @@ void SpawnNuclearSecondaryExp(DSWActor* actor, short ang)
|
|||
expActor->user.coll = move_missile(expActor, expActor->user.xchange, expActor->user.ychange, 0,
|
||||
expActor->user.ceiling_dist, expActor->user.floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS);
|
||||
|
||||
if (FindDistance3D(expActor->spr.pos.X - actor->spr.pos.X, expActor->spr.pos.Y - actor->spr.pos.Y, expActor->spr.pos.Z - actor->spr.pos.Z) < 1024)
|
||||
if (FindDistance3D(expActor->spr.pos - actor->spr.pos) < 1024)
|
||||
{
|
||||
KillActor(expActor);
|
||||
return;
|
||||
|
@ -10312,7 +10312,7 @@ void SpawnGrenadeSecondaryExp(DSWActor* actor, int ang)
|
|||
expActor->user.coll = move_missile(expActor, expActor->user.xchange, expActor->user.ychange, 0,
|
||||
expActor->user.ceiling_dist, expActor->user.floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS);
|
||||
|
||||
if (FindDistance3D(expActor->spr.pos.X - actor->spr.pos.X, expActor->spr.pos.Y - actor->spr.pos.Y, expActor->spr.pos.Z - actor->spr.pos.Z) < 1024)
|
||||
if (FindDistance3D(expActor->spr.pos - actor->spr.pos) < 1024)
|
||||
{
|
||||
KillActor(expActor);
|
||||
return;
|
||||
|
@ -11913,7 +11913,7 @@ int InitSwordAttack(PLAYERp pp)
|
|||
if (hit.hitSector == nullptr)
|
||||
return 0;
|
||||
|
||||
if (FindDistance3D(pp->pos.X - hit.hitpos.X, pp->pos.Y - hit.hitpos.Y, pp->pos.Z - hit.hitpos.Z) < 700)
|
||||
if (FindDistance3D(pp->pos - hit.hitpos) < 700)
|
||||
{
|
||||
|
||||
if (hit.actor() != nullptr)
|
||||
|
@ -12094,7 +12094,7 @@ int InitFistAttack(PLAYERp pp)
|
|||
if (hit.hitSector == nullptr)
|
||||
return 0;
|
||||
|
||||
if (FindDistance3D(pp->pos.X - hit.hitpos.X, pp->pos.Y - hit.hitpos.Y, pp->pos.Z - hit.hitpos.Z) < 700)
|
||||
if (FindDistance3D(pp->pos - hit.hitpos) < 700)
|
||||
{
|
||||
|
||||
if (hit.actor() != nullptr)
|
||||
|
@ -12414,7 +12414,7 @@ int WeaponAutoAim(DSWActor* actor, DSWActor* mislActor, short ang, bool test)
|
|||
SET(hitActor->user.Flags, SPR_ATTACKED);
|
||||
|
||||
mislActor->spr.ang = NORM_ANGLE(getangle(hitActor->spr.pos.X - mislActor->spr.pos.X, hitActor->spr.pos.Y - mislActor->spr.pos.Y));
|
||||
dist = FindDistance2D(mislActor->spr.pos.X - hitActor->spr.pos.X, mislActor->spr.pos.Y - hitActor->spr.pos.Y);
|
||||
dist = FindDistance2D(mislActor->spr.pos.vec2 - hitActor->spr.pos.vec2);
|
||||
|
||||
if (dist != 0)
|
||||
{
|
||||
|
@ -12470,7 +12470,7 @@ int WeaponAutoAimZvel(DSWActor* actor, DSWActor* missileActor, int *zvel, short
|
|||
SET(hitActor->user.Flags, SPR_ATTACKED);
|
||||
|
||||
missileActor->spr.ang = NORM_ANGLE(getangle(hitActor->spr.pos.X - missileActor->spr.pos.X, hitActor->spr.pos.Y - missileActor->spr.pos.Y));
|
||||
dist = FindDistance2D(missileActor->spr.pos.X - hitActor->spr.pos.X, missileActor->spr.pos.Y - hitActor->spr.pos.Y);
|
||||
dist = FindDistance2D(missileActor->spr.pos.vec2 - hitActor->spr.pos.vec2);
|
||||
|
||||
if (dist != 0)
|
||||
{
|
||||
|
@ -13816,7 +13816,7 @@ int InitRipperSlash(DSWActor* actor)
|
|||
if (itActor == actor)
|
||||
break;
|
||||
|
||||
if ((unsigned)FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z) > itActor->user.Radius + actor->user.Radius)
|
||||
if ((unsigned)FindDistance3D(actor->spr.pos - itActor->spr.pos) > itActor->user.Radius + actor->user.Radius)
|
||||
continue;
|
||||
|
||||
DISTANCE(itActor->spr.pos.X, itActor->spr.pos.Y, actor->spr.pos.X, actor->spr.pos.Y, dist, a, b, c);
|
||||
|
@ -13945,7 +13945,7 @@ int DoBladeDamage(DSWActor* actor)
|
|||
if (dist > 2000)
|
||||
continue;
|
||||
|
||||
dist = FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z);
|
||||
dist = FindDistance3D(actor->spr.pos - itActor->spr.pos);
|
||||
|
||||
if (dist > 2000)
|
||||
continue;
|
||||
|
@ -13982,7 +13982,7 @@ int DoStaticFlamesDamage(DSWActor* actor)
|
|||
if (dist > 2000)
|
||||
continue;
|
||||
|
||||
dist = FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z);
|
||||
dist = FindDistance3D(actor->spr.pos - itActor->spr.pos);
|
||||
|
||||
if (dist > 2000)
|
||||
continue;
|
||||
|
@ -14777,7 +14777,7 @@ int InitEelFire(DSWActor* actor)
|
|||
if (itActor != actor->user.targetActor)
|
||||
continue;
|
||||
|
||||
if ((unsigned)FindDistance3D(actor->spr.pos.X - itActor->spr.pos.X, actor->spr.pos.Y - itActor->spr.pos.Y, actor->spr.pos.Z - itActor->spr.pos.Z) > itActor->user.Radius + actor->user.Radius)
|
||||
if ((unsigned)FindDistance3D(actor->spr.pos - itActor->spr.pos) > itActor->user.Radius + actor->user.Radius)
|
||||
continue;
|
||||
|
||||
DISTANCE(itActor->spr.pos.X, itActor->spr.pos.Y, actor->spr.pos.X, actor->spr.pos.Y, dist, a, b, c);
|
||||
|
|
Loading…
Reference in a new issue