mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- Use 64-bit coordinates for a few spots in the FPathTraverse constructor and P_SightPathTraverse().
- Allow FTraceInfo::TrlaceTraverse to pass the endpoints to FPathTraverse as deltas instead of as absolute coordinates. SVN r3487 (trunk)
This commit is contained in:
parent
cfd5b84535
commit
b2abe9d11e
4 changed files with 54 additions and 25 deletions
|
@ -347,6 +347,7 @@ public:
|
|||
#define PT_ADDLINES 1
|
||||
#define PT_ADDTHINGS 2
|
||||
#define PT_COMPATIBLE 4
|
||||
#define PT_DELTA 8 // x2,y2 is passed as a delta, not as an endpoint
|
||||
|
||||
AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, int, void *), void *params = NULL);
|
||||
AActor *P_RoughMonsterSearch (AActor *mo, int distance);
|
||||
|
|
|
@ -1165,10 +1165,9 @@ intercept_t *FPathTraverse::Next()
|
|||
|
||||
FPathTraverse::FPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags)
|
||||
{
|
||||
fixed_t xt1;
|
||||
fixed_t yt1;
|
||||
fixed_t xt2;
|
||||
fixed_t yt2;
|
||||
fixed_t xt1, xt2;
|
||||
fixed_t yt1, yt2;
|
||||
long long _x1, _x2, _y1, _y2;
|
||||
|
||||
fixed_t xstep;
|
||||
fixed_t ystep;
|
||||
|
@ -1197,18 +1196,42 @@ FPathTraverse::FPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, in
|
|||
|
||||
trace.x = x1;
|
||||
trace.y = y1;
|
||||
trace.dx = x2 - x1;
|
||||
trace.dy = y2 - y1;
|
||||
if (flags & PT_DELTA)
|
||||
{
|
||||
trace.dx = x2;
|
||||
trace.dy = y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
trace.dx = x2 - x1;
|
||||
trace.dy = y2 - y1;
|
||||
}
|
||||
|
||||
_x1 = (long long)x1 - bmaporgx;
|
||||
_y1 = (long long)y1 - bmaporgy;
|
||||
x1 -= bmaporgx;
|
||||
y1 -= bmaporgy;
|
||||
xt1 = GetSafeBlockX(x1);
|
||||
yt1 = GetSafeBlockY(y1);
|
||||
xt1 = int(_x1 >> MAPBLOCKSHIFT);
|
||||
yt1 = int(_y1 >> MAPBLOCKSHIFT);
|
||||
|
||||
x2 -= bmaporgx;
|
||||
y2 -= bmaporgy;
|
||||
xt2 = GetSafeBlockX(x2);
|
||||
yt2 = GetSafeBlockY(y2);
|
||||
if (flags & PT_DELTA)
|
||||
{
|
||||
_x2 = _x1 + x2;
|
||||
_y2 = _y1 + y2;
|
||||
xt2 = int(_x2 >> MAPBLOCKSHIFT);
|
||||
yt2 = int(_y2 >> MAPBLOCKSHIFT);
|
||||
x2 = (int)_x2;
|
||||
y2 = (int)_y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_x2 = (long long)x2 - bmaporgx;
|
||||
_y2 = (long long)y2 - bmaporgy;
|
||||
x2 -= bmaporgx;
|
||||
y2 -= bmaporgy;
|
||||
xt2 = int(_x2 >> MAPBLOCKSHIFT);
|
||||
yt2 = int(_y2 >> MAPBLOCKSHIFT);
|
||||
}
|
||||
|
||||
if (xt2 > xt1)
|
||||
{
|
||||
|
@ -1228,7 +1251,7 @@ FPathTraverse::FPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, in
|
|||
partialx = FRACUNIT;
|
||||
ystep = 256*FRACUNIT;
|
||||
}
|
||||
yintercept = (y1>>MAPBTOFRAC) + FixedMul (partialx, ystep);
|
||||
yintercept = int(_y1>>MAPBTOFRAC) + FixedMul (partialx, ystep);
|
||||
|
||||
|
||||
if (yt2 > yt1)
|
||||
|
@ -1249,7 +1272,7 @@ FPathTraverse::FPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, in
|
|||
partialy = FRACUNIT;
|
||||
xstep = 256*FRACUNIT;
|
||||
}
|
||||
xintercept = (x1>>MAPBTOFRAC) + FixedMul (partialy, xstep);
|
||||
xintercept = int(_x1>>MAPBTOFRAC) + FixedMul (partialy, xstep);
|
||||
|
||||
// [RH] Fix for traces that pass only through blockmap corners. In that case,
|
||||
// xintercept and yintercept can both be set ahead of mapx and mapy, so the
|
||||
|
|
|
@ -443,6 +443,7 @@ bool SightCheck::P_SightTraverseIntercepts ()
|
|||
bool SightCheck::P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2)
|
||||
{
|
||||
fixed_t xt1,yt1,xt2,yt2;
|
||||
long long _x1,_y1,_x2,_y2;
|
||||
fixed_t xstep,ystep;
|
||||
fixed_t partialx, partialy;
|
||||
fixed_t xintercept, yintercept;
|
||||
|
@ -482,15 +483,19 @@ bool SightCheck::P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_
|
|||
trace.dx = x2 - x1;
|
||||
trace.dy = y2 - y1;
|
||||
|
||||
_x1 = (long long)x1 - bmaporgx;
|
||||
_y1 = (long long)y1 - bmaporgy;
|
||||
x1 -= bmaporgx;
|
||||
y1 -= bmaporgy;
|
||||
xt1 = GetSafeBlockX(x1);
|
||||
yt1 = GetSafeBlockY(y1);
|
||||
xt1 = int(_x1 >> MAPBLOCKSHIFT);
|
||||
yt1 = int(_y1 >> MAPBLOCKSHIFT);
|
||||
|
||||
_x2 = (long long)x2 - bmaporgx;
|
||||
_y2 = (long long)y2 - bmaporgy;
|
||||
x2 -= bmaporgx;
|
||||
y2 -= bmaporgy;
|
||||
xt2 = GetSafeBlockX(x2);
|
||||
yt2 = GetSafeBlockY(y2);
|
||||
xt2 = int(_x2 >> MAPBLOCKSHIFT);
|
||||
yt2 = int(_y2 >> MAPBLOCKSHIFT);
|
||||
|
||||
// points should never be out of bounds, but check once instead of
|
||||
// each block
|
||||
|
@ -516,7 +521,7 @@ bool SightCheck::P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_
|
|||
partialx = FRACUNIT;
|
||||
ystep = 256*FRACUNIT;
|
||||
}
|
||||
yintercept = (y1>>MAPBTOFRAC) + FixedMul (partialx, ystep);
|
||||
yintercept = int(_y1>>MAPBTOFRAC) + FixedMul (partialx, ystep);
|
||||
|
||||
|
||||
if (yt2 > yt1)
|
||||
|
@ -537,7 +542,7 @@ bool SightCheck::P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_
|
|||
partialy = FRACUNIT;
|
||||
xstep = 256*FRACUNIT;
|
||||
}
|
||||
xintercept = (x1>>MAPBTOFRAC) + FixedMul (partialy, xstep);
|
||||
xintercept = int(_x1>>MAPBTOFRAC) + FixedMul (partialy, xstep);
|
||||
|
||||
// [RH] Fix for traces that pass only through blockmap corners. In that case,
|
||||
// xintercept and yintercept can both be set ahead of mapx and mapy, so the
|
||||
|
|
|
@ -175,19 +175,19 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
|
|||
#endif
|
||||
|
||||
// check for overflows and clip if necessary
|
||||
SQWORD xd= (SQWORD)x + ( ( SQWORD(vx) * SQWORD(maxDist) )>>16);
|
||||
SQWORD xd = (SQWORD)x + ( ( SQWORD(vx) * SQWORD(maxDist) )>>16);
|
||||
|
||||
if (xd>SQWORD(32767)*FRACUNIT)
|
||||
{
|
||||
maxDist = inf.MaxDist=FixedDiv(FIXED_MAX-x,vx);
|
||||
maxDist = inf.MaxDist = FixedDiv(FIXED_MAX - x, vx);
|
||||
}
|
||||
else if (xd<-SQWORD(32767)*FRACUNIT)
|
||||
{
|
||||
maxDist = inf.MaxDist=FixedDiv(FIXED_MIN-x,vx);
|
||||
maxDist = inf.MaxDist = FixedDiv(FIXED_MIN - x, vx);
|
||||
}
|
||||
|
||||
|
||||
SQWORD yd= (SQWORD)y + ( ( SQWORD(vy) * SQWORD(maxDist) )>>16);
|
||||
SQWORD yd = (SQWORD)y + ( ( SQWORD(vy) * SQWORD(maxDist) )>>16);
|
||||
|
||||
if (yd>SQWORD(32767)*FRACUNIT)
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector,
|
|||
|
||||
bool FTraceInfo::TraceTraverse (int ptflags)
|
||||
{
|
||||
FPathTraverse it(StartX, StartY, StartX + FixedMul (Vx, MaxDist), StartY + FixedMul (Vy, MaxDist), ptflags);
|
||||
FPathTraverse it(StartX, StartY, FixedMul (Vx, MaxDist), FixedMul (Vy, MaxDist), ptflags | PT_DELTA);
|
||||
intercept_t *in;
|
||||
|
||||
while ((in = it.Next()))
|
||||
|
|
Loading…
Reference in a new issue