export the final dbrush_t right in ExportBrushList_r instead of doing it ahead of time

This commit is contained in:
Jonathan 2022-08-03 05:09:39 -04:00
parent 58d1e5230e
commit 98610982c9
3 changed files with 17 additions and 19 deletions

View File

@ -76,7 +76,6 @@ class mapbrush_t
public:
std::vector<mapface_t> faces;
brushformat_t format = brushformat_t::NORMAL;
int contents = 0;
aabb3d bounds {};
std::optional<uint32_t> outputnumber; /* only set for original brushes */
};

View File

@ -2103,8 +2103,6 @@ void ProcessAreaPortal(mapentity_t *entity)
}
for (auto &brush : entity->mapbrushes) {
brush.contents = Q2_CONTENTS_AREAPORTAL;
for (auto &face : brush.faces) {
face.contents.native = Q2_CONTENTS_AREAPORTAL;
face.texinfo = map.skip_texinfo;

View File

@ -305,6 +305,23 @@ static void ExportBrushList_r(const mapentity_t *entity, node_t *node)
brush_state.total_leaf_brushes += node->numleafbrushes;
node->firstleafbrush = map.bsp.dleafbrushes.size();
for (auto &b : node->original_brushes) {
if (!b->mapbrush->outputnumber.has_value()) {
const_cast<mapbrush_t *>(b->mapbrush)->outputnumber = {static_cast<uint32_t>(map.bsp.dbrushes.size())};
dbrush_t &brush = map.bsp.dbrushes.emplace_back(
dbrush_t{static_cast<int32_t>(map.bsp.dbrushsides.size()), 0, b->contents.native});
for (auto &side : b->mapbrush->faces) {
map.bsp.dbrushsides.push_back(
{(uint32_t) ExportMapPlane(side.get_plane()), (int32_t)ExportMapTexinfo(side.texinfo)});
brush.numsides++;
brush_state.total_brush_sides++;
}
brush_state.total_brushes++;
}
map.bsp.dleafbrushes.push_back(b->mapbrush->outputnumber.value());
}
}
@ -323,22 +340,6 @@ static void ExportBrushList(mapentity_t *entity, node_t *node)
brush_state = {};
for (auto &b : entity->brushes) {
const_cast<mapbrush_t *>(b->mapbrush)->outputnumber = {static_cast<uint32_t>(map.bsp.dbrushes.size())};
dbrush_t &brush = map.bsp.dbrushes.emplace_back(
dbrush_t{static_cast<int32_t>(map.bsp.dbrushsides.size()), 0, b->contents.native});
for (auto &side : b->sides) {
map.bsp.dbrushsides.push_back(
{(uint32_t) ExportMapPlane(side.get_plane()), (int32_t)ExportMapTexinfo(side.texinfo)});
brush.numsides++;
brush_state.total_brush_sides++;
}
brush_state.total_brushes++;
}
ExportBrushList_r(entity, node);
logging::print(logging::flag::STAT, " {:8} total brushes\n", brush_state.total_brushes);