Skip to content

Commit

Permalink
- fixed last commit and optimized wall lookup code a bit.
Browse files Browse the repository at this point in the history
No need to continue if a matching wall has been found.
  • Loading branch information
coelckers committed Jan 14, 2022
1 parent ef711f0 commit 7b1d993
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions source/core/rendering/scene/hw_walls.cpp
Expand Up @@ -72,30 +72,29 @@ static walltype* IsOnWall(tspritetype* tspr, int height, DVector2& outpos)
// In Wanton Destruction's airplane level there's such a sprite assigned to the wrong sector.
if (d.X == 0)
{
if (fabs(tspr->pos.X - wal.pos.X) < maxorthdist);
if (fabs(tspr->pos.X - wal.pos.X) < maxorthdist)
{
closest = &wal;
return &wal;
}
}
else if (d.Y == 0)
{
if (fabs(tspr->pos.Y - wal.pos.Y) < maxorthdist);
if (fabs(tspr->pos.Y - wal.pos.Y) < maxorthdist)
{
closest = &wal;
return &wal;
}
}
else
{
double wdist = SquareDistToWall(tspr->pos.X, tspr->pos.Y, &wal, &outpos);
if (wdist <= maxdistsq)
{
closest = &wal;
return &wal;
}
}
}
}
// todo: cache this in the sprite to avoid recalculation.
return closest;
return nullptr;
}

//==========================================================================
Expand Down

0 comments on commit 7b1d993

Please sign in to comment.