mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-31 09:20:59 +00:00
- rewrote nextsectorneighborzptr with a better parameter interface
This commit is contained in:
parent
ec66f39535
commit
83c0ad55f2
9 changed files with 102 additions and 91 deletions
|
@ -515,6 +515,38 @@ int inside(double x, double y, const sectortype* sect)
|
|||
return -1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// find the closest neighboring sector plane in the given direction.
|
||||
// Does not consider slopes, just like the original!
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
sectortype* nextsectorneighborzptr(sectortype* sectp, int startz, int flags)
|
||||
{
|
||||
int factor = (flags & Find_Up)? -1 : 1;
|
||||
int bestz = INT_MAX;
|
||||
sectortype* bestsec = (flags & Find_Safe)? sectp : nullptr;
|
||||
const auto planez = (flags & Find_Ceiling)? §ortype::ceilingz : §ortype::floorz;
|
||||
|
||||
startz *= factor;
|
||||
for(auto& wal : wallsofsector(sectp))
|
||||
{
|
||||
if (wal.twoSided())
|
||||
{
|
||||
auto nextsec = wal.nextSector();
|
||||
auto nextz = factor * nextsec->*planez;
|
||||
|
||||
if (startz < nextz && nextz < bestz)
|
||||
{
|
||||
bestz = nextz;
|
||||
bestsec = nextsec;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestsec;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue