Simplify some code in R_StoreWallRange

This commit is contained in:
Lactozilla 2023-06-25 23:22:03 -03:00
parent 1127726130
commit 515b082454
2 changed files with 16 additions and 39 deletions

View file

@ -709,7 +709,7 @@ static void R_AddPolyobjs(subsector_t *sub)
R_BuildPolyBSP(sub); R_BuildPolyBSP(sub);
minibsp = sub->BSP; minibsp = sub->BSP;
nodecount = minibsp->numnodes-1; nodecount = minibsp->numnodes - 1;
if (nodecount == 0) if (nodecount == 0)
R_Subsector(0); R_Subsector(0);
@ -830,7 +830,7 @@ void R_Subsector(size_t num)
sub = &subsectors[num]; sub = &subsectors[num];
// Render the polyobjs in the subsector first // Render the minibsp instead
if (sub->polynodes) if (sub->polynodes)
{ {
R_AddPolyobjs(sub); R_AddPolyobjs(sub);
@ -995,23 +995,19 @@ void R_Subsector(size_t num)
} }
// Polyobjects have planes, too! // Polyobjects have planes, too!
if (minibsp && sub->polynodes) polynodes = sub->polynodes;
{
polynode_t *pn = sub->polynodes;
polynodes = pn;
for (; pn != NULL; pn = pn->pnext) if (minibsp && polynodes)
{
polynode_t *pn = polynodes;
for (; pn != NULL && numffloors < MAXFFLOORS; pn = pn->pnext)
{ {
polyobj_t *po = pn->poly; polyobj_t *po = pn->poly;
sector_t *polysec;
if (numffloors >= MAXFFLOORS)
break;
if (!(po->flags & POF_RENDERPLANES)) // Don't draw planes if (!(po->flags & POF_RENDERPLANES)) // Don't draw planes
continue; continue;
polysec = po->lines[0]->backsector; sector_t *polysec = po->lines[0]->backsector;
ffloor[numffloors].plane = NULL; ffloor[numffloors].plane = NULL;
if (polysec->floorheight <= ceilingcenterz if (polysec->floorheight <= ceilingcenterz

View file

@ -2593,27 +2593,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} }
} }
numbackffloors = i; polyobj_t *po = curline->polyseg;
} if (po && po->flags & POF_RENDERPLANES)
if (polynodes && numbackffloors < MAXFFLOORS)
{
polynode_t *pn = polynodes;
for (; pn != NULL; pn = pn->pnext)
{ {
polyobj_t *po = pn->poly; sector_t *polysec = po->lines[0]->backsector;
sector_t *polysec;
if (!(po->flags & POF_RENDERPLANES)) // Don't draw planes
continue;
i = 0;
while (i < numffloors && ffloor[i].polyobj != po) i++; while (i < numffloors && ffloor[i].polyobj != po) i++;
polysec = po->lines[0]->backsector; if (i < MAXFFLOORS && polysec->floorheight <= frontsector->ceilingheight &&
if (polysec->floorheight <= frontsector->ceilingheight &&
polysec->floorheight >= frontsector->floorheight && polysec->floorheight >= frontsector->floorheight &&
(viewz < polysec->floorheight)) (viewz < polysec->floorheight))
{ {
@ -2624,10 +2611,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
i++; i++;
} }
if (i >= MAXFFLOORS) if (i < MAXFFLOORS && polysec->ceilingheight >= frontsector->floorheight &&
break;
if (polysec->ceilingheight >= frontsector->floorheight &&
polysec->ceilingheight <= frontsector->ceilingheight && polysec->ceilingheight <= frontsector->ceilingheight &&
(viewz > polysec->ceilingheight)) (viewz > polysec->ceilingheight))
{ {
@ -2637,13 +2621,10 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale);
i++; i++;
} }
if (i >= MAXFFLOORS)
break;
} }
numbackffloors = i;
} }
numbackffloors = i;
} }
for (i = 0; i < numffloors; i++) for (i = 0; i < numffloors; i++)