mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
- redid Exhumed's BelowNear function.
Use BFSSearch, only run one iteration of the search and only run the search if the result is actually used.
This commit is contained in:
parent
12c26976f0
commit
6fc43287b3
2 changed files with 36 additions and 64 deletions
|
@ -55,6 +55,11 @@ public:
|
|||
return ~0;
|
||||
}
|
||||
|
||||
void Rewind()
|
||||
{
|
||||
curpos = startpos;
|
||||
}
|
||||
|
||||
void Add(unsigned elem)
|
||||
{
|
||||
if (!Check(elem))
|
||||
|
|
|
@ -225,53 +225,6 @@ void clipwall()
|
|||
|
||||
int BelowNear(DExhumedActor* pActor, int x, int y, int walldist, int nSector)
|
||||
{
|
||||
unsigned nearstart = GlobalSectorList.Size();
|
||||
GlobalSectorList.Push(nSector);
|
||||
|
||||
unsigned i = nearstart;
|
||||
|
||||
while (i < GlobalSectorList.Size())
|
||||
{
|
||||
int nSector = GlobalSectorList[i];
|
||||
|
||||
int nWall = sector[nSector].wallptr;
|
||||
int nWallCount = sector[nSector].wallnum;
|
||||
|
||||
while (1)
|
||||
{
|
||||
nWallCount--;
|
||||
if (nWallCount < 0)
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
|
||||
short nNextSector = wall[nWall].nextsector;
|
||||
|
||||
if (nNextSector >= 0)
|
||||
{
|
||||
unsigned j = nearstart;
|
||||
for (; j < GlobalSectorList.Size(); j++)
|
||||
{
|
||||
// loc_14F4D:
|
||||
if (nNextSector == GlobalSectorList[j])
|
||||
break;
|
||||
}
|
||||
|
||||
if (j >= GlobalSectorList.Size())
|
||||
{
|
||||
vec2_t pos = { x, y };
|
||||
if (clipinsidebox(&pos, nWall, walldist))
|
||||
{
|
||||
GlobalSectorList.Push(wall[nWall].nextsector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nWall++;
|
||||
}
|
||||
}
|
||||
|
||||
auto pSprite = &pActor->s();
|
||||
nSector = pSprite->sectnum;
|
||||
int z = pSprite->z;
|
||||
|
@ -286,13 +239,28 @@ int BelowNear(DExhumedActor* pActor, int x, int y, int walldist, int nSector)
|
|||
{
|
||||
z2 = sector[nSector].floorz + SectDepth[nSector];
|
||||
|
||||
if (GlobalSectorList.Size() > nearstart)
|
||||
{
|
||||
int edx = 0;
|
||||
BFSSearch search(numsectors, nSector);
|
||||
|
||||
for (unsigned i = nearstart; i < GlobalSectorList.Size(); i++)
|
||||
int edx = 0;
|
||||
for (unsigned nCurSector; (nCurSector = search.GetNext()) != BFSSearch::EOL;)
|
||||
{
|
||||
int nSect2 = GlobalSectorList[i];
|
||||
for (auto& wal : wallsofsector(nCurSector))
|
||||
{
|
||||
int nNextSector = wal.nextsector;
|
||||
if (nNextSector >= 0)
|
||||
{
|
||||
if (!search.Check(nNextSector))
|
||||
{
|
||||
vec2_t pos = { x, y };
|
||||
if (clipinsidebox(&pos, wallnum(&wal), walldist))
|
||||
{
|
||||
search.Add(nNextSector);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nSect2 = nCurSector;
|
||||
|
||||
while (nSect2 >= 0)
|
||||
{
|
||||
|
@ -310,8 +278,7 @@ int BelowNear(DExhumedActor* pActor, int x, int y, int walldist, int nSector)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GlobalSectorList.Resize(nearstart);
|
||||
|
||||
|
||||
if (z2 < pSprite->z)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue