From 5c5e6e1ea71a715f33b2244d10e655d697f2ac81 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 19 Jun 2022 17:32:18 -0600 Subject: [PATCH] qbsp: fix brush_clipping_order --- qbsp/portals.cc | 5 ++++- qbsp/qbsp.cc | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qbsp/portals.cc b/qbsp/portals.cc index d08c0ff5..db5e142e 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -453,8 +453,11 @@ static void FindPortalSide(portal_t *p) node_t *n = p->nodes[j]; auto p1 = map.planes.at(p->onnode->planenum); - for (brush_t *brush : n->original_brushes) + // iterate the n->original_brushes vector in reverse order, so later brushes + // in the map file order are prioritized + for (auto it = n->original_brushes.rbegin(); it != n->original_brushes.rend(); ++it) { + auto *brush = *it; if (!options.target_game->contents_contains(brush->contents, viscontents)) continue; for (face_t &side : brush->faces) diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index fb044970..4df23eba 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -896,15 +896,14 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum) tree = BrushBSP(entity, false); } - FreeTreePortals_r(tree->headnode); - - PruneNodes(tree->headnode); - MakeTreePortals(tree); MarkVisibleSides(tree, entity); MakeFaces(tree->headnode); + FreeTreePortals_r(tree->headnode); + PruneNodes(tree->headnode); + if (hullnum <= 0 && entity == map.world_entity() && !map.leakfile) { WritePortalFile(tree); }