diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index 58be51e3..36f3db6d 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -66,8 +66,12 @@ struct bspbrush_t * The brushes in main brush vectors are considered originals. Brush fragments created during * the BrushBSP will have this pointing back to the original brush in the list. */ + ptr original_ptr; mapbrush_t *mapbrush; + bspbrush_t *original_brush() { return original_ptr ? original_ptr.get() : this; } + const bspbrush_t *original_brush() const { return original_ptr ? original_ptr.get() : this; } + aabb3d bounds; int side, testside; // side of node during construction std::vector sides; diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 1083fe99..5766e1a6 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -504,7 +504,7 @@ static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hulln qbsp_options.target_game->count_contents_in_stats(brush->contents, stats); dst->bounds += brush->bounds; - brushes.push_back(std::make_unique(std::move(*brush))); + brushes.push_back(bspbrush_t::make_ptr(std::move(*brush))); } logging::percent(src->mapbrushes.size(), src->mapbrushes.size(), src == map.world_entity()); diff --git a/qbsp/brushbsp.cc b/qbsp/brushbsp.cc index 6c7ca7dd..16e97153 100644 --- a/qbsp/brushbsp.cc +++ b/qbsp/brushbsp.cc @@ -491,7 +491,8 @@ static twosided SplitBrush(bspbrush_t::ptr brush, size_t planen // start with 2 empty brushes for (int i = 0; i < 2; i++) { - result[i] = std::make_unique(); + result[i] = bspbrush_t::make_ptr(); + result[i]->original_ptr = brush->original_ptr; result[i]->mapbrush = brush->mapbrush; // fixme-brushbsp: add a bspbrush_t copy constructor to make sure we get all fields result[i]->contents = brush->contents; @@ -1105,6 +1106,7 @@ std::unique_ptr BrushBSP(mapentity_t *entity, const bspbrush_t::containe logging::print(logging::flag::STAT, " {:8} nonvisible faces\n", c_nonvisfaces); auto node = tree->create_node(); + node->volume = BrushFromBounds(tree->bounds.grow(SIDESPACE)); node->bounds = tree->bounds.grow(SIDESPACE); diff --git a/qbsp/map.cc b/qbsp/map.cc index 42710daa..4f881695 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2860,7 +2860,7 @@ static void TestExpandBrushes(mapentity_t *src) qbsp_options.target_game->id == GAME_QUAKE_II ? HULL_COLLISION : 1); if (hull1brush) { - hull1brushes.emplace_back(std::make_unique(std::move(*hull1brush))); + hull1brushes.emplace_back(bspbrush_t::make_ptr(std::move(*hull1brush))); } } diff --git a/qbsp/tree.cc b/qbsp/tree.cc index e3bba442..5723b90c 100644 --- a/qbsp/tree.cc +++ b/qbsp/tree.cc @@ -82,7 +82,6 @@ static void ConvertNodeToLeaf(node_t *node, const contentflags_t &contents) node->original_brushes = std::move(node->children[base]->original_brushes); node->original_brushes.insert(node->original_brushes.end(), node->children[base ^ 1]->original_brushes.begin(), node->children[base ^ 1]->original_brushes.end()); - // sort by pointer (since mapbrush_t is in a flat vector) std::sort(node->original_brushes.begin(), node->original_brushes.end()); auto unique = std::unique(node->original_brushes.begin(), node->original_brushes.end()); node->original_brushes.erase(unique, node->original_brushes.end());