hook up merge and subdivide stats
This commit is contained in:
parent
1f1388b2dd
commit
c9935aaa38
|
|
@ -28,4 +28,4 @@ struct face_t;
|
||||||
struct node_t;
|
struct node_t;
|
||||||
|
|
||||||
void MergeFaceToList(face_t *face, std::list<face_t *> &list);
|
void MergeFaceToList(face_t *face, std::list<face_t *> &list);
|
||||||
std::list<std::unique_ptr<face_t>> MergeFaceList(std::list<std::unique_ptr<face_t>> input);
|
std::list<std::unique_ptr<face_t>> MergeFaceList(std::list<std::unique_ptr<face_t>> input, int &num_merged);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
struct makefaces_stats_t {
|
||||||
|
int c_nodefaces;
|
||||||
|
int c_merge;
|
||||||
|
int c_subdivide;
|
||||||
|
};
|
||||||
|
|
||||||
static bool ShouldOmitFace(face_t *f)
|
static bool ShouldOmitFace(face_t *f)
|
||||||
{
|
{
|
||||||
if (!qbsp_options.includeskip.value() && map.mtexinfos.at(f->texinfo).flags.is_skip)
|
if (!qbsp_options.includeskip.value() && map.mtexinfos.at(f->texinfo).flags.is_skip)
|
||||||
|
|
@ -46,9 +52,9 @@ static bool ShouldOmitFace(face_t *f)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MergeNodeFaces(node_t *node)
|
static void MergeNodeFaces(node_t *node, int &num_merged)
|
||||||
{
|
{
|
||||||
node->facelist = MergeFaceList(std::move(node->facelist));
|
node->facelist = MergeFaceList(std::move(node->facelist), num_merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -272,8 +278,6 @@ int MakeFaceEdges(node_t *headnode)
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
static int c_nodefaces;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
AddMarksurfaces_r
|
AddMarksurfaces_r
|
||||||
|
|
@ -327,12 +331,6 @@ void MakeMarkFaces(node_t* node)
|
||||||
MakeMarkFaces(node->children[1].get());
|
MakeMarkFaces(node->children[1].get());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct makefaces_stats_t {
|
|
||||||
int c_nodefaces;
|
|
||||||
int c_merge;
|
|
||||||
int c_subdivide;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
SubdivideFace
|
SubdivideFace
|
||||||
|
|
@ -341,7 +339,7 @@ If the face is >256 in either texture direction, carve a valid sized
|
||||||
piece off and insert the remainder in the next link
|
piece off and insert the remainder in the next link
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
static std::list<std::unique_ptr<face_t>> SubdivideFace(std::unique_ptr<face_t> f)
|
static std::list<std::unique_ptr<face_t>> SubdivideFace(std::unique_ptr<face_t> f, makefaces_stats_t &stats)
|
||||||
{
|
{
|
||||||
vec_t mins, maxs;
|
vec_t mins, maxs;
|
||||||
vec_t v;
|
vec_t v;
|
||||||
|
|
@ -444,16 +442,18 @@ static std::list<std::unique_ptr<face_t>> SubdivideFace(std::unique_ptr<face_t>
|
||||||
surfaces = std::move(chopped);
|
surfaces = std::move(chopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats.c_subdivide += surfaces.size() - 1;
|
||||||
|
|
||||||
return surfaces;
|
return surfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SubdivideNodeFaces(node_t *node)
|
static void SubdivideNodeFaces(node_t *node, makefaces_stats_t &stats)
|
||||||
{
|
{
|
||||||
std::list<std::unique_ptr<face_t>> result;
|
std::list<std::unique_ptr<face_t>> result;
|
||||||
|
|
||||||
// subdivide each face and push the results onto subdivided
|
// subdivide each face and push the results onto subdivided
|
||||||
for (auto &face : node->facelist) {
|
for (auto &face : node->facelist) {
|
||||||
result.splice(result.end(), SubdivideFace(std::move(face)));
|
result.splice(result.end(), SubdivideFace(std::move(face), stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
node->facelist = std::move(result);
|
node->facelist = std::move(result);
|
||||||
|
|
@ -537,9 +537,9 @@ static void MakeFaces_r(node_t *node, makefaces_stats_t& stats)
|
||||||
|
|
||||||
// merge together all visible faces on the node
|
// merge together all visible faces on the node
|
||||||
if (!qbsp_options.nomerge.value())
|
if (!qbsp_options.nomerge.value())
|
||||||
MergeNodeFaces(node);
|
MergeNodeFaces(node, stats.c_merge);
|
||||||
if (qbsp_options.subdivide.boolValue())
|
if (qbsp_options.subdivide.boolValue())
|
||||||
SubdivideNodeFaces(node);
|
SubdivideNodeFaces(node, stats);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -581,7 +581,7 @@ void MakeFaces(node_t *node)
|
||||||
|
|
||||||
MakeFaces_r(node, stats);
|
MakeFaces_r(node, stats);
|
||||||
|
|
||||||
logging::print(logging::flag::STAT, " {:8} makefaces\n", stats.c_nodefaces);
|
logging::print(logging::flag::STAT, " {:8} makefaces\n", stats.c_nodefaces); // FIXME: what is "makefaces" exactly
|
||||||
logging::print(logging::flag::STAT, " {:8} merged\n", stats.c_merge);
|
logging::print(logging::flag::STAT, " {:8} merged\n", stats.c_merge);
|
||||||
logging::print(logging::flag::STAT, " {:8} subdivided\n", stats.c_subdivide);
|
logging::print(logging::flag::STAT, " {:8} subdivided\n", stats.c_subdivide);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ static std::unique_ptr<face_t> TryMerge(const face_t *f1, const face_t *f2)
|
||||||
MergeFaceToList
|
MergeFaceToList
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void MergeFaceToList(std::unique_ptr<face_t> face, std::list<std::unique_ptr<face_t>> &list)
|
void MergeFaceToList(std::unique_ptr<face_t> face, std::list<std::unique_ptr<face_t>> &list, int &num_merged)
|
||||||
{
|
{
|
||||||
for (auto it = list.begin(); it != list.end();) {
|
for (auto it = list.begin(); it != list.end();) {
|
||||||
#ifdef PARANOID
|
#ifdef PARANOID
|
||||||
|
|
@ -168,6 +168,7 @@ void MergeFaceToList(std::unique_ptr<face_t> face, std::list<std::unique_ptr<fac
|
||||||
// restart, now trying to merge `newf` into the list
|
// restart, now trying to merge `newf` into the list
|
||||||
face = std::move(newf);
|
face = std::move(newf);
|
||||||
it = list.begin();
|
it = list.begin();
|
||||||
|
num_merged++;
|
||||||
} else {
|
} else {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
@ -181,12 +182,12 @@ void MergeFaceToList(std::unique_ptr<face_t> face, std::list<std::unique_ptr<fac
|
||||||
MergeFaceList
|
MergeFaceList
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
std::list<std::unique_ptr<face_t>> MergeFaceList(std::list<std::unique_ptr<face_t>> input)
|
std::list<std::unique_ptr<face_t>> MergeFaceList(std::list<std::unique_ptr<face_t>> input, int &num_merged)
|
||||||
{
|
{
|
||||||
std::list<std::unique_ptr<face_t>> result;
|
std::list<std::unique_ptr<face_t>> result;
|
||||||
|
|
||||||
for (auto &face : input) {
|
for (auto &face : input) {
|
||||||
MergeFaceToList(std::move(face), result);
|
MergeFaceToList(std::move(face), result, num_merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -591,8 +591,6 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logging::print(logging::flag::STAT, " {:8} planes\n", map.planes.size());
|
|
||||||
|
|
||||||
std::unique_ptr<tree_t> tree = nullptr;
|
std::unique_ptr<tree_t> tree = nullptr;
|
||||||
if (hullnum > 0) {
|
if (hullnum > 0) {
|
||||||
tree = BrushBSP(entity);
|
tree = BrushBSP(entity);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue