Rewrite of 697e3325f8
This commit is contained in:
parent
44eff2d7b1
commit
c0cec4e1ba
|
|
@ -61,7 +61,7 @@ struct bspbrush_t
|
|||
* the BrushBSP will have this pointing back to the original brush in the list.
|
||||
*/
|
||||
bspbrush_t *original;
|
||||
const mapbrush_t *mapbrush;
|
||||
mapbrush_t *mapbrush;
|
||||
uint32_t file_order;
|
||||
aabb3d bounds;
|
||||
int side, testside; // side of node during construction
|
||||
|
|
@ -80,5 +80,5 @@ struct bspbrush_t
|
|||
|
||||
using bspbrush_vector_t = std::vector<std::unique_ptr<bspbrush_t>>;
|
||||
|
||||
std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents, const int hullnum);
|
||||
std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, mapbrush_t *mapbrush, const contentflags_t &contents, const int hullnum);
|
||||
bool CreateBrushWindings(bspbrush_t *brush);
|
||||
|
|
@ -626,11 +626,6 @@ struct bspbrush_t;
|
|||
struct side_t;
|
||||
class mapbrush_t;
|
||||
|
||||
struct bspbrush_t_less
|
||||
{
|
||||
bool operator()(const bspbrush_t *a, const bspbrush_t *b) const;
|
||||
};
|
||||
|
||||
struct node_t
|
||||
{
|
||||
// both leafs and nodes
|
||||
|
|
@ -666,8 +661,7 @@ struct node_t
|
|||
uint32_t firstleafbrush; // Q2
|
||||
uint32_t numleafbrushes;
|
||||
int32_t area;
|
||||
std::vector<bspbrush_t *> original_brushes; // FIXME: only valid during construction
|
||||
std::vector<const mapbrush_t *> original_mapbrushes;
|
||||
std::vector<bspbrush_t *> original_brushes;
|
||||
};
|
||||
|
||||
void InitQBSP(int argc, const char **argv);
|
||||
|
|
|
|||
|
|
@ -28,11 +28,6 @@
|
|||
#include <qbsp/map.hh>
|
||||
#include <qbsp/qbsp.hh>
|
||||
|
||||
bool bspbrush_t_less::operator()(const bspbrush_t *a, const bspbrush_t *b) const
|
||||
{
|
||||
return a->file_order < b->file_order;
|
||||
}
|
||||
|
||||
const maptexinfo_t &side_t::get_texinfo() const
|
||||
{
|
||||
return map.mtexinfos[this->texinfo];
|
||||
|
|
@ -256,7 +251,7 @@ LoadBrush
|
|||
Converts a mapbrush to a bsp brush
|
||||
===============
|
||||
*/
|
||||
std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents,
|
||||
std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, mapbrush_t *mapbrush, const contentflags_t &contents,
|
||||
const int hullnum)
|
||||
{
|
||||
// create the brush
|
||||
|
|
@ -352,7 +347,7 @@ std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *ma
|
|||
|
||||
//=============================================================================
|
||||
|
||||
static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int hullnum, content_stats_base_t &stats, bspbrush_vector_t &brushes)
|
||||
static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hullnum, content_stats_base_t &stats, bspbrush_vector_t &brushes)
|
||||
{
|
||||
// _omitbrushes 1 just discards all brushes in the entity.
|
||||
// could be useful for geometry guides, selective compilation, etc.
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ static qvec2f projectToAxisPlane(const qvec3d &snapped_normal, const qvec3d &poi
|
|||
static texdef_quake_ed_noshift_t Reverse_QuakeEd(qmat2x2f M, const qbsp_plane_t &plane, bool preserveX);
|
||||
static void SetTexinfo_QuakeEd_New(
|
||||
const qbsp_plane_t &plane, const qvec2d &shift, vec_t rotate, const qvec2d &scale, texvecf &out_vecs);
|
||||
static void TestExpandBrushes(const mapentity_t *src);
|
||||
static void TestExpandBrushes(mapentity_t *src);
|
||||
|
||||
static void AddAnimTex(const char *name)
|
||||
{
|
||||
|
|
@ -2821,7 +2821,7 @@ allow visual inspection of the clipping bevels
|
|||
from q3map
|
||||
================
|
||||
*/
|
||||
static void TestExpandBrushes(const mapentity_t *src)
|
||||
static void TestExpandBrushes(mapentity_t *src)
|
||||
{
|
||||
std::vector<std::unique_ptr<bspbrush_t>> hull1brushes;
|
||||
|
||||
|
|
|
|||
|
|
@ -414,6 +414,7 @@ static void MarkVisibleBrushSides_R(node_t *node)
|
|||
for (auto *brush : neighbour_leaf->original_brushes) {
|
||||
for (auto &side : brush->sides) {
|
||||
// fixme-brushbsp: should this be get_plane() ?
|
||||
// fixme-brushbsp: planenum
|
||||
if (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.
|
||||
|
|
|
|||
14
qbsp/qbsp.cc
14
qbsp/qbsp.cc
|
|
@ -300,20 +300,20 @@ static void ExportBrushList_r(const mapentity_t *entity, node_t *node)
|
|||
{
|
||||
if (node->is_leaf) {
|
||||
if (node->contents.native) {
|
||||
if (node->original_mapbrushes.size()) {
|
||||
node->numleafbrushes = node->original_mapbrushes.size();
|
||||
if (node->original_brushes.size()) {
|
||||
node->numleafbrushes = node->original_brushes.size();
|
||||
brush_state.total_leaf_brushes += node->numleafbrushes;
|
||||
node->firstleafbrush = map.bsp.dleafbrushes.size();
|
||||
for (auto &b : node->original_mapbrushes) {
|
||||
for (auto &b : node->original_brushes) {
|
||||
|
||||
if (!b->outputnumber.has_value()) {
|
||||
if (!b->mapbrush->outputnumber.has_value()) {
|
||||
// FIXME
|
||||
const_cast<mapbrush_t *>(b)->outputnumber = {static_cast<uint32_t>(map.bsp.dbrushes.size())};
|
||||
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++;
|
||||
|
|
@ -323,7 +323,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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
qbsp/tree.cc
27
qbsp/tree.cc
|
|
@ -78,24 +78,15 @@ void FreeTreePortals(tree_t *tree)
|
|||
static void ConvertNodeToLeaf(node_t *node, const contentflags_t &contents)
|
||||
{
|
||||
// merge the children's brush lists
|
||||
node->original_brushes = std::move(node->children[0]->original_brushes);
|
||||
node->original_brushes.insert(node->original_brushes.end(), node->children[1]->original_brushes.begin(), node->children[1]->original_brushes.end());
|
||||
size_t base = node->children[0]->original_brushes.size() > node->children[1]->original_brushes.size() ? 0 : 1;
|
||||
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());
|
||||
|
||||
if (node->original_brushes.size()) {
|
||||
std::sort(node->original_brushes.begin(), node->original_brushes.end(), bspbrush_t_less());
|
||||
auto unique_begin = std::unique(node->original_brushes.begin(), node->original_brushes.end());
|
||||
node->original_brushes.erase(unique_begin, node->original_brushes.end());
|
||||
|
||||
// migrate it over to mapbrushes
|
||||
node->original_mapbrushes.reserve(node->original_brushes.size());
|
||||
|
||||
for (auto &b : node->original_brushes) {
|
||||
node->original_mapbrushes.push_back(b->mapbrush);
|
||||
}
|
||||
|
||||
// clear original_brushes since we no longer need it
|
||||
node->original_brushes.clear();
|
||||
}
|
||||
std::sort(node->original_brushes.begin(), node->original_brushes.end(), [](const bspbrush_t *a, const bspbrush_t *b) {
|
||||
return a->file_order < b->file_order;
|
||||
});
|
||||
auto unique = std::unique(node->original_brushes.begin(), node->original_brushes.end());
|
||||
node->original_brushes.erase(unique, node->original_brushes.end());
|
||||
|
||||
node->is_leaf = true;
|
||||
|
||||
|
|
@ -127,8 +118,6 @@ static void PruneNodes_R(node_t *node, std::atomic<int32_t> &count_pruned)
|
|||
// This discards any faces on-node. Should be safe (?)
|
||||
ConvertNodeToLeaf(node, qbsp_options.target_game->create_solid_contents());
|
||||
++count_pruned;
|
||||
} else {
|
||||
node->original_brushes.clear();
|
||||
}
|
||||
|
||||
// DarkPlaces has an assertion that fails if both children are
|
||||
|
|
|
|||
Loading…
Reference in New Issue