From 0361e912cbe820965bf02c7c4773b2fc39f2c9a8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 24 Nov 2016 01:01:02 +0100 Subject: [PATCH] Minor bug fix --- src/r_poly_cull.cpp | 22 ++++++++++++---------- src/r_poly_cull.h | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index 79b8d151d9..ff349690c0 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -35,18 +35,12 @@ void PolyCull::CullScene(const TriMatrix &worldToClip) frustumPlanes = FrustumPlanes(worldToClip); // Cull front to back + MaxCeilingHeight = 0.0; + MinFloorHeight = 0.0; if (numnodes == 0) - { - PvsSectors.push_back(subsectors); - MaxCeilingHeight = subsectors->sector->ceilingplane.Zat0(); - MinFloorHeight = subsectors->sector->floorplane.Zat0(); - } + CullSubsector(subsectors); else - { - MaxCeilingHeight = 0.0; - MinFloorHeight = 0.0; CullNode(nodes + numnodes - 1); // The head node is the last node output. - } ClearSolidSegments(); } @@ -65,16 +59,24 @@ void PolyCull::CullNode(void *node) // Possibly divide back space (away from the viewer). side ^= 1; + if (!CheckBBox(bsp->bbox[side])) return; node = bsp->children[side]; } - // Mark that we need to render this subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + CullSubsector(sub); +} + +void PolyCull::CullSubsector(subsector_t *sub) +{ + // Update sky heights for the scene MaxCeilingHeight = MAX(MaxCeilingHeight, sub->sector->ceilingplane.Zat0()); MinFloorHeight = MIN(MinFloorHeight, sub->sector->floorplane.Zat0()); + + // Mark that we need to render this PvsSectors.push_back(sub); // Update culling info for further bsp clipping diff --git a/src/r_poly_cull.h b/src/r_poly_cull.h index a79355f689..e011ef5837 100644 --- a/src/r_poly_cull.h +++ b/src/r_poly_cull.h @@ -46,6 +46,7 @@ private: }; void CullNode(void *node); + void CullSubsector(subsector_t *sub); int PointOnSide(const DVector2 &pos, const node_t *node); // Checks BSP node/subtree bounding box.