mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-31 09:20:59 +00:00
- replaced getclosestpointonwall_internal with a floating point version based on NearestPointLine.
This commit is contained in:
parent
c2fc7577db
commit
b31e6c0bdf
6 changed files with 68 additions and 55 deletions
|
@ -220,6 +220,16 @@ void getzsofslopeptr(const sectortype* sec, int dax, int day, int* ceilz, int* f
|
|||
*florz = int(f);
|
||||
}
|
||||
|
||||
void getcorrectzsofslope(int sectnum, int dax, int day, int* ceilz, int* florz)
|
||||
{
|
||||
DVector2 closestv;
|
||||
SquareDistToSector(dax * inttoworld, day * inttoworld, §or[sectnum], &closestv);
|
||||
float ffloorz, fceilz;
|
||||
calcSlope(§or[sectnum], closestv.X * worldtoint, closestv.Y * worldtoint, &fceilz, &ffloorz);
|
||||
if (ceilz) *ceilz = int(fceilz);
|
||||
if (florz) *florz = int(ffloorz);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -234,6 +244,36 @@ int getslopeval(sectortype* sect, int x, int y, int z, int basez)
|
|||
return i == 0? 0 : Scale((z - basez) << 8, wal->Length(), i);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Calculate the distance to the closest point in the given sector
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
double SquareDistToSector(double px, double py, const sectortype* sect, DVector2* point)
|
||||
{
|
||||
if (inside(px, py, sect))
|
||||
{
|
||||
if (point)
|
||||
*point = { px, py };
|
||||
return 0;
|
||||
}
|
||||
|
||||
double bestdist = DBL_MAX;
|
||||
DVector2 bestpt = { px, py };
|
||||
for (auto& wal : wallsofsector(sect))
|
||||
{
|
||||
DVector2 pt;
|
||||
auto dist = SquareDistToWall(px, py, &wal, &pt);
|
||||
if (dist < bestdist)
|
||||
{
|
||||
bestdist = dist;
|
||||
bestpt = pt;
|
||||
}
|
||||
}
|
||||
if (point) *point = bestpt;
|
||||
return bestdist;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue