- fixed an edge case in cansee where an actor placed directly on a two-sided wall would fail to register that wall's back sector.

This commit is contained in:
Christoph Oelckers 2022-10-17 00:28:13 +02:00
parent 88d421300a
commit e3254a8546
2 changed files with 6 additions and 3 deletions

View file

@ -140,9 +140,12 @@ inline double InterceptLineSegments(double v2x, double v2y, double v2dx, double
{
double den = v1dy * v2dx - v1dx * v2dy;
if (den == 0 || (forcansee && den < 0)) // cansee does this added check here, aside from that its logic is virtually the same.
if (den == 0)
return 0; // parallel
if (forcansee && den < 0) // cansee does this added check here, aside from that its logic is virtually the same.
return -1; // hitting the backside
// perform the division first for better parallelization.
den = 1 / den;

View file

@ -509,7 +509,7 @@ bool cansee(const DVector3& start, sectortype* sect1, const DVector3& end, secto
for (auto& wal : wallsofsector(sec))
{
double factor = InterceptLineSegments(start.X, start.Y, delta.X, delta.Y, wal.pos.X, wal.pos.Y, wal.delta().X, wal.delta().Y, nullptr, true);
if (factor <= 0 || factor >= 1) continue;
if (factor < 0 || factor >= 1) continue;
if (!wal.twoSided() || wal.cstat & CSTAT_WALL_1WAY)
return false;
@ -691,7 +691,7 @@ double checkWallHit(walltype* wal, EWallFlags flagmask, const DVector3& start, c
if (PointOnLineSide(start.XY(), wal) > 0) return -1;
double factor = InterceptLineSegments(start.X, start.Y, direction.X, direction.Y, wal->pos.X, wal->pos.Y, wal->delta().X, wal->delta().Y);
if (factor <= 0 || factor > maxfactor) return -1; // did not connect.
if (factor < 0 || factor > maxfactor) return -1; // did not connect.
result = start + factor * direction;
if (wal->twoSided() && !(wal->cstat & flagmask))