diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3e8186ad0..fb3e71c09 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2384,31 +2384,19 @@ doaddline: // HWR_CheckBBox // Checks BSP node/subtree bounding box. // Returns true -// if some part of the bbox might be visible. +// if some part of the bbox might be visible. // // modified to use local variables static boolean HWR_CheckBBox(const fixed_t *bspcoord) { - INT32 boxpos; fixed_t px1, py1, px2, py2; angle_t angle1, angle2; // Find the corners of the box // that define the edges from current viewpoint. - if (viewx <= bspcoord[BOXLEFT]) - boxpos = 0; - else if (viewx < bspcoord[BOXRIGHT]) - boxpos = 1; - else - boxpos = 2; - - if (viewy >= bspcoord[BOXTOP]) - boxpos |= 0; - else if (viewy > bspcoord[BOXBOTTOM]) - boxpos |= 1<<2; - else - boxpos |= 2<<2; + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -3137,18 +3125,18 @@ static void HWR_RenderBSPNode(INT32 bspnum) INT32 side; ps_numbspcalls.value.i++; - while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? + while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector { bsp = &nodes[bspnum]; // Decide which side the view point is on. side = R_PointOnSideFast(viewx, viewy, bsp); - // Recursively divide front space. + // Recursively divide front space (toward the viewer). if (HWR_PortalCheckBBox(bsp->bbox[side])) HWR_RenderBSPNode(bsp->children[side]); - // Possibly divide back space + // Possibly divide back space (away from the viewer). if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) return; @@ -5305,12 +5293,12 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // Set transform. GL_SetTransform(&atransform); - validcount++; - ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); + validcount++; + if (cv_glbatching.value) HWR_StartBatching();