mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-12 14:55:36 +00:00
- floatified FAFcansee
This commit is contained in:
parent
8bedc1193b
commit
860dde17ca
2 changed files with 23 additions and 37 deletions
|
@ -1762,12 +1762,7 @@ inline bool FAF_ConnectArea(sectortype* sect)
|
||||||
|
|
||||||
void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3& vect, HitInfo& hit, int32_t clipmask);
|
void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3& vect, HitInfo& hit, int32_t clipmask);
|
||||||
|
|
||||||
bool FAFcansee_(int32_t xs, int32_t ys, int32_t zs, sectortype* sects, int32_t xe, int32_t ye, int32_t ze, sectortype* secte);
|
bool FAFcansee(const DVector3& start, sectortype* sects, const DVector3& end, sectortype* secte);
|
||||||
inline bool FAFcansee(const DVector3& start, sectortype* sects, const DVector3& end, sectortype* secte)
|
|
||||||
{
|
|
||||||
return FAFcansee_(int(start.X * worldtoint), int(start.Y * worldtoint), int(start.Z * zworldtoint), sects,
|
|
||||||
int(end.X * worldtoint), int(end.Y * worldtoint), int(end.Z * zworldtoint), secte);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FAFgetzrange(vec3_t pos, sectortype* sect,
|
void FAFgetzrange(vec3_t pos, sectortype* sect,
|
||||||
int32_t* hiz, Collision* ceilhit,
|
int32_t* hiz, Collision* ceilhit,
|
||||||
|
|
|
@ -250,49 +250,40 @@ inline void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3&
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool FAFcansee_(int32_t xs, int32_t ys, int32_t zs, sectortype* sects,
|
bool FAFcansee(const DVector3& start, sectortype* sects, const DVector3& end, sectortype* secte)
|
||||||
int32_t xe, int32_t ye, int32_t ze, sectortype* secte)
|
|
||||||
{
|
{
|
||||||
int loz, hiz;
|
|
||||||
auto newsect = sects;
|
auto newsect = sects;
|
||||||
int xvect, yvect, zvect;
|
|
||||||
short ang;
|
|
||||||
int dist;
|
|
||||||
bool plax_found = false;
|
bool plax_found = false;
|
||||||
vec3_t s = { xs, ys, zs };
|
|
||||||
|
|
||||||
// ASSERT(sects >= 0 && secte >= 0);
|
// ASSERT(sects >= 0 && secte >= 0);
|
||||||
|
|
||||||
// early out to regular routine
|
// early out to regular routine
|
||||||
if ((!sects || !FAF_Sector(sects)) && (!secte || !FAF_Sector(secte)))
|
if ((!sects || !FAF_Sector(sects)) && (!secte || !FAF_Sector(secte)))
|
||||||
{
|
{
|
||||||
return !!cansee(xs,ys,zs,sects,xe,ye,ze,secte);
|
return !!cansee(start, sects, end, secte);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get angle
|
// get angle
|
||||||
ang = getangle(xe - xs, ye - ys);
|
DVector3 diff = end - start;
|
||||||
|
DAngle ang = VecToAngle(diff);
|
||||||
|
DVector3 vect;
|
||||||
|
vect.XY() = ang.ToVector() * 1024;
|
||||||
|
double dist = diff.XY().Length();
|
||||||
|
|
||||||
// get x,y,z, vectors
|
// get x,y,z, vectors
|
||||||
xvect = bcos(ang);
|
|
||||||
yvect = bsin(ang);
|
|
||||||
|
|
||||||
// find the distance to the target
|
|
||||||
dist = ksqrt(SQ(xe - xs) + SQ(ye - ys));
|
|
||||||
|
|
||||||
if (dist != 0)
|
if (dist != 0)
|
||||||
{
|
{
|
||||||
if (xe - xs != 0)
|
if (end.X != start.X)
|
||||||
zvect = Scale(xvect, ze - zs, xe - xs);
|
vect.Z = vect.X * diff.Z / diff.X;
|
||||||
else if (ye - ys != 0)
|
else if (end.Y != start.Y)
|
||||||
zvect = Scale(yvect, ze - zs, ye - ys);
|
vect.Z = vect.Y * diff.Z / diff.Y;
|
||||||
else
|
else
|
||||||
zvect = 0;
|
vect.Z = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
zvect = 0;
|
vect.Z = 0;
|
||||||
|
|
||||||
HitInfo hit{};
|
HitInfo hit{};
|
||||||
hitscan(s, sects, { xvect, yvect, zvect }, hit, CLIPMASK_MISSILE);
|
hitscan(start, sects, vect, hit, CLIPMASK_MISSILE);
|
||||||
|
|
||||||
if (hit.hitSector == nullptr)
|
if (hit.hitSector == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -300,36 +291,36 @@ bool FAFcansee_(int32_t xs, int32_t ys, int32_t zs, sectortype* sects,
|
||||||
// make sure it hit JUST a sector before doing a check
|
// make sure it hit JUST a sector before doing a check
|
||||||
if (hit.hitWall == nullptr && hit.actor() == nullptr)
|
if (hit.hitWall == nullptr && hit.actor() == nullptr)
|
||||||
{
|
{
|
||||||
getzsofslopeptr(hit.hitSector, hit.int_hitpos().X, hit.int_hitpos().Y, &hiz, &loz);
|
double loz, hiz;
|
||||||
if (abs(hit.int_hitpos().Z - loz) < Z(4))
|
getzsofslopeptr(hit.hitSector, hit.hitpos.X, hit.hitpos.Y, &hiz, &loz);
|
||||||
|
if (abs(hit.hitpos.Z - loz) < 4)
|
||||||
{
|
{
|
||||||
if (FAF_ConnectFloor(hit.hitSector))
|
if (FAF_ConnectFloor(hit.hitSector))
|
||||||
{
|
{
|
||||||
updatesectorz(hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z + Z(12), &newsect);
|
updatesectorz(hit.hitpos.plusZ(12), &newsect);
|
||||||
plax_found = true;
|
plax_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (abs(hit.int_hitpos().Z - hiz) < Z(4))
|
else if (abs(hit.hitpos.Z - hiz) < 4)
|
||||||
{
|
{
|
||||||
if (FAF_ConnectCeiling(hit.hitSector))
|
if (FAF_ConnectCeiling(hit.hitSector))
|
||||||
{
|
{
|
||||||
updatesectorz(hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z - Z(12), &newsect);
|
updatesectorz(hit.hitpos.plusZ(-12), &newsect);
|
||||||
plax_found = true;
|
plax_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return !!cansee(xs,ys,zs,sects,xe,ye,ze,secte);
|
return !!cansee(start, sects, end, secte);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plax_found)
|
if (plax_found)
|
||||||
return !!cansee(hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, newsect, xe, ye, ze, secte);
|
return !!cansee(hit.hitpos, newsect, end, secte);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue