mirror of
https://github.com/ZDoom/Raze.git
synced 2025-04-21 23:40:48 +00:00
- split off one part of clipmove into a utility function.
This commit is contained in:
parent
ef9efe30b6
commit
3c72eb43f9
2 changed files with 49 additions and 0 deletions
|
@ -1606,6 +1606,54 @@ void collectClipObjects(MoveClipper& clip, int spritemask)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FindBestSector(const DVector3& pos)
|
||||
{
|
||||
int bestnum = 1;
|
||||
double bestdist = FLT_MAX;
|
||||
for (int secnum = (int)sector.Size() - 1; secnum >= 0; secnum--)
|
||||
{
|
||||
auto sect = §or[secnum];
|
||||
if (inside(pos.X, pos.Y, sect))
|
||||
{
|
||||
double ceilz, floorz;
|
||||
calcSlope(sect, pos.X, pos.Y, &ceilz, &floorz);
|
||||
|
||||
if (pos.Z < ceilz)
|
||||
{
|
||||
// above ceiling
|
||||
double dist = ceilz - pos.Z;
|
||||
if (dist < bestdist)
|
||||
{
|
||||
bestnum = secnum;
|
||||
bestdist = dist;
|
||||
}
|
||||
}
|
||||
else if (pos.Z > floorz)
|
||||
{
|
||||
// below floor
|
||||
double dist = pos.Z - floorz;
|
||||
if (dist < bestdist)
|
||||
{
|
||||
bestnum = secnum;
|
||||
bestdist = dist;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// inside sector
|
||||
return secnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestnum;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool isAwayFromWall(DCoreActor* ac, double delta)
|
||||
{
|
||||
sectortype* s1;
|
||||
|
|
|
@ -312,6 +312,7 @@ struct MoveClipper
|
|||
};
|
||||
|
||||
void collectClipObjects(MoveClipper& clip, int spritemask);
|
||||
int FindBestSector(const DVector3& pos);
|
||||
|
||||
int FindBestSector(const DVector3& pos);
|
||||
|
||||
|
|
Loading…
Reference in a new issue