diff --git a/src/r_bsp.c b/src/r_bsp.c index fb84e5d08..67fb1737b 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -709,7 +709,7 @@ static void R_AddPolyobjs(subsector_t *sub) R_BuildPolyBSP(sub); minibsp = sub->BSP; - nodecount = minibsp->numnodes-1; + nodecount = minibsp->numnodes - 1; if (nodecount == 0) R_Subsector(0); @@ -830,7 +830,7 @@ void R_Subsector(size_t num) sub = &subsectors[num]; - // Render the polyobjs in the subsector first + // Render the minibsp instead if (sub->polynodes) { R_AddPolyobjs(sub); @@ -995,23 +995,19 @@ void R_Subsector(size_t num) } // Polyobjects have planes, too! - if (minibsp && sub->polynodes) - { - polynode_t *pn = sub->polynodes; - polynodes = pn; + polynodes = sub->polynodes; - 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; - sector_t *polysec; - - if (numffloors >= MAXFFLOORS) - break; - if (!(po->flags & POF_RENDERPLANES)) // Don't draw planes continue; - polysec = po->lines[0]->backsector; + sector_t *polysec = po->lines[0]->backsector; ffloor[numffloors].plane = NULL; if (polysec->floorheight <= ceilingcenterz diff --git a/src/r_segs.c b/src/r_segs.c index fccbc151c..e29b7cb61 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2593,27 +2593,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } - numbackffloors = i; - } - - if (polynodes && numbackffloors < MAXFFLOORS) - { - polynode_t *pn = polynodes; - - for (; pn != NULL; pn = pn->pnext) + polyobj_t *po = curline->polyseg; + if (po && po->flags & POF_RENDERPLANES) { - polyobj_t *po = pn->poly; - sector_t *polysec; + sector_t *polysec = po->lines[0]->backsector; - if (!(po->flags & POF_RENDERPLANES)) // Don't draw planes - continue; - - i = 0; while (i < numffloors && ffloor[i].polyobj != po) i++; - polysec = po->lines[0]->backsector; - - if (polysec->floorheight <= frontsector->ceilingheight && + if (i < MAXFFLOORS && polysec->floorheight <= frontsector->ceilingheight && polysec->floorheight >= frontsector->floorheight && (viewz < polysec->floorheight)) { @@ -2624,10 +2611,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) i++; } - if (i >= MAXFFLOORS) - break; - - if (polysec->ceilingheight >= frontsector->floorheight && + if (i < MAXFFLOORS && polysec->ceilingheight >= frontsector->floorheight && polysec->ceilingheight <= frontsector->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); i++; } - - if (i >= MAXFFLOORS) - break; } - - numbackffloors = i; } + + numbackffloors = i; } for (i = 0; i < numffloors; i++)