mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 15:40:58 +00:00
- use BFSSearch in clipupdatesector
This commit is contained in:
parent
7111b2470c
commit
22e554e88a
1 changed files with 26 additions and 37 deletions
|
@ -397,52 +397,41 @@ static void clipupdatesector(vec2_t const pos, int * const sectnum, int walldist
|
|||
walldist = 0x7fff;
|
||||
}
|
||||
|
||||
static int16_t sectlist[MAXSECTORS];
|
||||
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
||||
|
||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);
|
||||
|
||||
for (int sectcnt = 0; sectcnt < nsecs; sectcnt++)
|
||||
{
|
||||
int const listsectnum = sectlist[sectcnt];
|
||||
BFSSearch search(numsectors, *sectnum);
|
||||
|
||||
if (inside_p(pos.x, pos.y, listsectnum))
|
||||
SET_AND_RETURN(*sectnum, listsectnum);
|
||||
|
||||
auto const sec = §or[listsectnum];
|
||||
int const startwall = sec->wallptr;
|
||||
int const endwall = sec->wallptr + sec->wallnum;
|
||||
auto uwal = (uwallptr_t)&wall[startwall];
|
||||
|
||||
for (int j = startwall; j < endwall; j++, uwal++)
|
||||
if (uwal->nextsector >= 0 && bitmap_test(clipsectormap, uwal->nextsector))
|
||||
bfirst_search_try(sectlist, sectbitmap, &nsecs, uwal->nextsector);
|
||||
}
|
||||
|
||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);
|
||||
|
||||
for (int sectcnt = 0; sectcnt < nsecs; sectcnt++)
|
||||
for (unsigned listsectnum; (listsectnum = search.GetNext()) != BFSSearch::EOL;)
|
||||
{
|
||||
int const listsectnum = sectlist[sectcnt];
|
||||
|
||||
if (inside_p(pos.x, pos.y, listsectnum))
|
||||
{
|
||||
// add sector to clipping list so the next call to clipupdatesector()
|
||||
// finishes in the loop above this one
|
||||
addclipsect(listsectnum);
|
||||
SET_AND_RETURN(*sectnum, listsectnum);
|
||||
*sectnum = listsectnum;
|
||||
return;
|
||||
}
|
||||
|
||||
auto const sec = §or[listsectnum];
|
||||
int const startwall = sec->wallptr;
|
||||
int const endwall = sec->wallptr + sec->wallnum;
|
||||
auto uwal = (uwallptr_t)&wall[startwall];
|
||||
for (auto& wal : wallsofsector(listsectnum))
|
||||
{
|
||||
if (wal.nextsector >= 0 && bitmap_test(clipsectormap, wal.nextsector))
|
||||
search.Add(wal.nextsector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check floor curbs here?
|
||||
{
|
||||
BFSSearch search(numsectors, *sectnum);
|
||||
|
||||
for (int j = startwall; j < endwall; j++, uwal++)
|
||||
if (uwal->nextsector >= 0 && getwalldist(pos, j) <= (walldist + 8))
|
||||
bfirst_search_try(sectlist, sectbitmap, &nsecs, uwal->nextsector);
|
||||
for (unsigned listsectnum; (listsectnum = search.GetNext()) != BFSSearch::EOL;)
|
||||
{
|
||||
if (inside_p(pos.x, pos.y, listsectnum))
|
||||
{
|
||||
*sectnum = listsectnum;
|
||||
return;
|
||||
}
|
||||
for (auto& wal : wallsofsector(listsectnum))
|
||||
{
|
||||
if (wal.nextsector >= 0 && getwalldist(pos, wallnum(&wal)) <= (walldist + 8))
|
||||
search.Add(wal.nextsector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*sectnum = -1;
|
||||
|
|
Loading…
Reference in a new issue