From 6fafc19f749a3e18226e761d9e476a5326def2dc Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 21 May 2022 23:37:47 -0600 Subject: [PATCH] qbsp: fix not clearing portals --- qbsp/portals.cc | 11 +++++++++++ qbsp/qbsp.cc | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/qbsp/portals.cc b/qbsp/portals.cc index da1dc0f2..94a25d9a 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -621,6 +621,16 @@ static void CutNodePortals_r(node_t *node, portal_state_t *state) CutNodePortals_r(back, state); } +static void AssertNoPortals(node_t *node) +{ + Q_assert(!node->portals); + + if (node->planenum != PLANENUM_LEAF) { + AssertNoPortals(node->children[0]); + AssertNoPortals(node->children[1]); + } +} + /* ================== PortalizeWorld @@ -636,6 +646,7 @@ void PortalizeEntity(const mapentity_t *entity, node_t *headnode, const int hull state.iNodesDone = 0; + AssertNoPortals(headnode); MakeHeadnodePortals(entity, headnode); CutNodePortals_r(headnode, &state); diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 10f50dba..1a4d4732 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -790,8 +790,12 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum) nodes = SolidBSP(entity, false); } + FreeAllPortals(nodes); + PruneNodes(nodes); + PortalizeEntity(entity, nodes, hullnum); + MakeVisibleFaces(entity, nodes); // merge polygons