partial revert of 097b564cc6

This commit is contained in:
Jonathan 2022-08-10 22:43:42 -04:00
parent eb7c65362c
commit 02e80645e6
5 changed files with 9 additions and 4 deletions

View File

@ -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<side_t> sides;

View File

@ -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<bspbrush_t>(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());

View File

@ -491,7 +491,8 @@ static twosided<bspbrush_t::ptr> 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<bspbrush_t>();
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<tree_t> 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);

View File

@ -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<bspbrush_t>(std::move(*hull1brush)));
hull1brushes.emplace_back(bspbrush_t::make_ptr(std::move(*hull1brush)));
}
}

View File

@ -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());