more partial revert
This commit is contained in:
parent
02e80645e6
commit
4b4a1738fd
|
|
@ -40,8 +40,8 @@ struct portal_t
|
|||
std::unique_ptr<winding_t> winding;
|
||||
|
||||
bool sidefound; // false if ->side hasn't been checked
|
||||
mapface_t *sides[2]; // [0] = the brush side visible on nodes[0] - it could come from a brush in nodes[1]. NULL =
|
||||
// non-visible
|
||||
side_t *sides[2]; // [0] = the brush side visible on nodes[0] - it could come from a brush in nodes[1]. NULL =
|
||||
// non-visible
|
||||
face_t *face[2]; // output face in bsp file
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ struct node_t
|
|||
uint32_t firstleafbrush; // Q2
|
||||
uint32_t numleafbrushes;
|
||||
int32_t area;
|
||||
std::vector<mapbrush_t *> original_brushes;
|
||||
std::vector<bspbrush_t *> original_brushes;
|
||||
};
|
||||
|
||||
void InitQBSP(int argc, const char **argv);
|
||||
|
|
|
|||
|
|
@ -387,8 +387,7 @@ static void LeafNode(node_t *leafnode, bspbrush_t::container brushes, bspstats_t
|
|||
leafnode->contents = qbsp_options.target_game->combine_contents(leafnode->contents, brush->contents);
|
||||
}
|
||||
for (auto &brush : brushes) {
|
||||
Q_assert(brush->mapbrush != nullptr);
|
||||
leafnode->original_brushes.push_back(brush->mapbrush);
|
||||
leafnode->original_brushes.push_back(brush->original_brush());
|
||||
}
|
||||
|
||||
qbsp_options.target_game->count_contents_in_stats(leafnode->contents, *stats.leafstats);
|
||||
|
|
@ -492,7 +491,7 @@ static twosided<bspbrush_t::ptr> SplitBrush(bspbrush_t::ptr brush, size_t planen
|
|||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
result[i] = bspbrush_t::make_ptr();
|
||||
result[i]->original_ptr = brush->original_ptr;
|
||||
result[i]->original_ptr = brush->original_ptr ? brush->original_ptr : brush;
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -472,16 +472,18 @@ see also FindPortalSide which populates p->side
|
|||
*/
|
||||
static std::unique_ptr<face_t> FaceFromPortal(portal_t *p, bool pside)
|
||||
{
|
||||
mapface_t *side = p->sides[pside];
|
||||
side_t *side = p->sides[pside];
|
||||
if (!side)
|
||||
return nullptr; // portal does not bridge different visible contents
|
||||
|
||||
Q_assert(side->source);
|
||||
|
||||
auto f = std::make_unique<face_t>();
|
||||
|
||||
f->texinfo = side->texinfo;
|
||||
f->planenum = (side->planenum & ~1) | (pside ? 1 : 0);
|
||||
f->portal = p;
|
||||
f->original_side = side;
|
||||
f->original_side = side->source;
|
||||
|
||||
#if 0
|
||||
bool make_face =
|
||||
|
|
|
|||
|
|
@ -396,13 +396,13 @@ static void MarkVisibleBrushSides_R(node_t *node)
|
|||
// optimized case: just mark the brush sides in the neighbouring
|
||||
// leaf that are coplanar
|
||||
for (auto *brush : neighbour_leaf->original_brushes) {
|
||||
for (auto &side : brush->faces) {
|
||||
for (auto &side : brush->sides) {
|
||||
// fixme-brushbsp: should this be get_plane() ?
|
||||
// fixme-brushbsp: planenum
|
||||
if (qv::epsilonEqual(side.get_positive_plane(), portal->plane)) {
|
||||
if (side.source && qv::epsilonEqual(side.get_positive_plane(), portal->plane)) {
|
||||
// we've found a brush side in an original brush in the neighbouring
|
||||
// leaf, on a portal to this (non-opaque) leaf, so mark it as visible.
|
||||
side.visible = true;
|
||||
side.source->visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -573,8 +573,8 @@ static mapentity_t *AreanodeEntityForLeaf(node_t *node)
|
|||
}
|
||||
|
||||
for (auto &brush : node->original_brushes) {
|
||||
if (brush->func_areaportal) {
|
||||
return brush->func_areaportal;
|
||||
if (brush->mapbrush->func_areaportal) {
|
||||
return brush->mapbrush->func_areaportal;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
@ -791,8 +791,8 @@ static void FindPortalSide(portal_t *p)
|
|||
return;
|
||||
|
||||
// bestside[0] is the brushside visible on portal side[0] which is the positive side of the plane, always
|
||||
mapface_t *bestside[2] = {nullptr, nullptr};
|
||||
mapface_t *exactside[2] = {nullptr, nullptr};
|
||||
side_t *bestside[2] = {nullptr, nullptr};
|
||||
side_t *exactside[2] = {nullptr, nullptr};
|
||||
float bestdot = 0;
|
||||
const qbsp_plane_t &p1 = p->onnode->get_plane();
|
||||
|
||||
|
|
@ -813,7 +813,7 @@ static void FindPortalSide(portal_t *p)
|
|||
continue;
|
||||
}
|
||||
|
||||
for (auto &side : brush->faces) {
|
||||
for (auto &side : brush->sides) {
|
||||
if (side.bevel)
|
||||
continue;
|
||||
if ((side.planenum & ~1) == p->onnode->planenum) {
|
||||
|
|
@ -898,8 +898,8 @@ static void MarkVisibleSides_r(node_t *node)
|
|||
if (!p->sidefound)
|
||||
FindPortalSide(p);
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (p->sides[i]) {
|
||||
p->sides[i]->visible = true;
|
||||
if (p->sides[i] && p->sides[i]->source) {
|
||||
p->sides[i]->source->visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
qbsp/qbsp.cc
12
qbsp/qbsp.cc
|
|
@ -306,13 +306,13 @@ static void ExportBrushList_r(const mapentity_t *entity, node_t *node)
|
|||
node->firstleafbrush = map.bsp.dleafbrushes.size();
|
||||
for (auto &b : node->original_brushes) {
|
||||
|
||||
if (!b->outputnumber.has_value()) {
|
||||
b->outputnumber = {static_cast<uint32_t>(map.bsp.dbrushes.size())};
|
||||
if (!b->mapbrush->outputnumber.has_value()) {
|
||||
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->faces) {
|
||||
for (auto &side : b->mapbrush->faces) {
|
||||
map.bsp.dbrushsides.push_back(
|
||||
{(uint32_t) ExportMapPlane(side.planenum), (int32_t)ExportMapTexinfo(side.texinfo)});
|
||||
brush.numsides++;
|
||||
|
|
@ -322,7 +322,7 @@ static void ExportBrushList_r(const mapentity_t *entity, node_t *node)
|
|||
brush_state.total_brushes++;
|
||||
}
|
||||
|
||||
map.bsp.dleafbrushes.push_back(b->outputnumber.value());
|
||||
map.bsp.dleafbrushes.push_back(b->mapbrush->outputnumber.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -486,6 +486,10 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
|
|||
|
||||
// fixme-brushbsp: return here?
|
||||
} else {
|
||||
|
||||
if (entity->outputmodelnumber.value() == 34)
|
||||
__debugbreak();
|
||||
|
||||
if (qbsp_options.forcegoodtree.value()) {
|
||||
tree = BrushBSP(entity, brushes, false);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,9 @@ 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());
|
||||
|
||||
std::sort(node->original_brushes.begin(), node->original_brushes.end());
|
||||
std::sort(node->original_brushes.begin(), node->original_brushes.end(), [](const bspbrush_t *a, const bspbrush_t *b) {
|
||||
return a->mapbrush < b->mapbrush;
|
||||
});
|
||||
auto unique = std::unique(node->original_brushes.begin(), node->original_brushes.end());
|
||||
node->original_brushes.erase(unique, node->original_brushes.end());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue