- rewrote nextsectorneighborzptr with a better parameter interface

This commit is contained in:
Christoph Oelckers 2022-08-05 18:43:48 +02:00
parent ec66f39535
commit 83c0ad55f2
9 changed files with 102 additions and 91 deletions

View file

@ -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)? &sectortype::ceilingz : &sectortype::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;
}
//==========================================================================
//
//