Ported RenderRadius and related code from gzdoom branch

This commit is contained in:
ZZYZX 2016-12-25 13:09:32 +02:00
commit 87b23d160b
12 changed files with 133 additions and 6 deletions

View file

@ -6640,6 +6640,97 @@ void P_CreateSecNodeList(AActor *thing)
}
//=============================================================================
//
// P_LinkRenderSectors
//
// Alters/creates the list of touched sectors for thing's render radius.
//
//=============================================================================
void P_LinkRenderSectors(AActor* thing)
{
FBoundingBox box(thing->X(), thing->Y(), std::max(thing->renderradius, thing->radius));
FBlockLinesIterator it(box);
line_t *ld;
// add to surrounding sectors
while ((ld = it.Next()))
{
if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1)
continue;
//
// create necessary lists.
if (!thing->touching_render_sectors) thing->touching_render_sectors = new std::forward_list<sector_t*>();
//
if (ld->frontsector != thing->Sector)
{
if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->frontsector) == thing->touching_render_sectors->end())
thing->touching_render_sectors->push_front(ld->frontsector);
if (!ld->frontsector->touching_render_things) ld->frontsector->touching_render_things = new std::forward_list<AActor*>();
ld->frontsector->touching_render_things->push_front(thing);
}
if (ld->backsector && ld->backsector != thing->Sector)
{
if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->backsector) == thing->touching_render_sectors->end())
thing->touching_render_sectors->push_front(ld->backsector);
if (!ld->backsector->touching_render_things) ld->backsector->touching_render_things = new std::forward_list<AActor*>();
ld->backsector->touching_render_things->push_front(thing);
}
}
// add to own sector
if (!thing->Sector->touching_render_things) thing->Sector->touching_render_things = new std::forward_list<AActor*>();
thing->Sector->touching_render_things->push_front(thing);
}
//=============================================================================
//
// P_UnlinkRenderSectors
//
// Reverses P_LinkRenderSectors.
//
//=============================================================================
void P_UnlinkRenderSectors(AActor* thing)
{
if (thing->touching_render_sectors)
{
for (std::forward_list<sector_t*>::iterator it = thing->touching_render_sectors->begin();
it != thing->touching_render_sectors->end(); it++)
{
sector_t* sec = (*it);
if (sec->touching_render_things)
{
sec->touching_render_things->remove(thing);
if (sec->touching_render_things->empty())
{
delete sec->touching_render_things;
sec->touching_render_things = NULL;
}
}
}
delete thing->touching_render_sectors;
thing->touching_render_sectors = NULL;
}
if (thing->Sector->touching_render_things)
{
thing->Sector->touching_render_things->remove(thing);
if (thing->Sector->touching_render_things->empty())
{
delete thing->Sector->touching_render_things;
thing->Sector->touching_render_things = NULL;
}
}
}
//=============================================================================
//
// P_DelPortalnode