clean up percent stuff
comment out "didn't split" message fix winding resize merge phong loops together
This commit is contained in:
parent
c81e9ace28
commit
f5cda68416
|
|
@ -64,6 +64,10 @@ static std::mutex print_mutex;
|
|||
|
||||
void print(flag logflag, const char *str)
|
||||
{
|
||||
if (!(mask & logflag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
print_mutex.lock();
|
||||
|
||||
if (logflag != flag::PERCENT) {
|
||||
|
|
@ -88,7 +92,7 @@ void print(flag logflag, const char *str)
|
|||
static time_point start_time;
|
||||
static bool is_timing = false;
|
||||
|
||||
void percent(uint64_t count, uint64_t max)
|
||||
void percent(uint64_t count, uint64_t max, bool displayElapsed)
|
||||
{
|
||||
if (!is_timing) {
|
||||
start_time = I_FloatTime();
|
||||
|
|
@ -98,7 +102,9 @@ void percent(uint64_t count, uint64_t max)
|
|||
if (count == max) {
|
||||
auto elapsed = I_FloatTime() - start_time;
|
||||
is_timing = false;
|
||||
print(flag::PERCENT, "[100%] time elapsed: {:.3}\n", elapsed);
|
||||
if (displayElapsed) {
|
||||
print(flag::PERCENT, "[100%] time elapsed: {:.3}\n", elapsed);
|
||||
}
|
||||
} else {
|
||||
print(flag::PERCENT, "[{:>3}%]\r", static_cast<uint32_t>((static_cast<float>(count) / max) * 100));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,5 +109,5 @@ inline void assert_(bool success, const char *expr, const char *file, int line)
|
|||
// bar will "finish" and be inoperable.
|
||||
// Only use this by hand if you absolutely need to; otherwise,
|
||||
// use <common/parallel.h>'s parallel_for(_each)
|
||||
void percent(uint64_t count, uint64_t max);
|
||||
void percent(uint64_t count, uint64_t max, bool displayElapsed = true);
|
||||
};
|
||||
|
|
@ -381,6 +381,7 @@ public:
|
|||
}
|
||||
|
||||
count = new_size;
|
||||
isVector = count > N;
|
||||
}
|
||||
|
||||
void clear()
|
||||
|
|
|
|||
|
|
@ -451,6 +451,29 @@ void CalculateVertexNormals(const mbsp_t *bsp)
|
|||
|
||||
// build the "face -> faces to smooth with" map
|
||||
for (auto &f : bsp->dfaces) {
|
||||
// Q2 shading groups
|
||||
const int f_phongValue = Q2_FacePhongValue(bsp, &f);
|
||||
if (f_phongValue) {
|
||||
for (int j = 0; j < f.numedges; j++) {
|
||||
const int v = Face_VertexAtIndex(bsp, &f, j);
|
||||
// walk over all faces incident to f (we will walk over neighbours multiple times, doesn't matter)
|
||||
for (const mface_t *f2 : vertsToFaces[v]) {
|
||||
if (f2 == &f)
|
||||
continue;
|
||||
|
||||
const int f2_phongValue = Q2_FacePhongValue(bsp, f2);
|
||||
if (f_phongValue != f2_phongValue)
|
||||
continue;
|
||||
|
||||
// we've already checked f_phongValue is nonzero, so smooth these two faces.
|
||||
smoothFaces[&f].insert(f2);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Q1 phong angle stuff
|
||||
const auto f_points = GLM_FacePoints(bsp, &f);
|
||||
const qvec3d f_norm = Face_Normal(bsp, &f);
|
||||
const qplane3d f_plane = Face_Plane(bsp, &f);
|
||||
|
|
@ -504,30 +527,6 @@ void CalculateVertexNormals(const mbsp_t *bsp)
|
|||
}
|
||||
}
|
||||
|
||||
// Q2: build the "face -> faces to smooth with" map
|
||||
// FIXME: merge this into the above loop
|
||||
for (auto &f : bsp->dfaces) {
|
||||
const int f_phongValue = Q2_FacePhongValue(bsp, &f);
|
||||
if (f_phongValue == 0)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < f.numedges; j++) {
|
||||
const int v = Face_VertexAtIndex(bsp, &f, j);
|
||||
// walk over all faces incident to f (we will walk over neighbours multiple times, doesn't matter)
|
||||
for (const mface_t *f2 : vertsToFaces[v]) {
|
||||
if (f2 == &f)
|
||||
continue;
|
||||
|
||||
const int f2_phongValue = Q2_FacePhongValue(bsp, f2);
|
||||
if (f_phongValue != f2_phongValue)
|
||||
continue;
|
||||
|
||||
// we've already checked f_phongValue is nonzero, so smooth these two faces.
|
||||
smoothFaces[&f].insert(f2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logging::print(logging::flag::VERBOSE, " {} faces for smoothing\n", smoothFaces.size());
|
||||
|
||||
// finally do the smoothing for each face
|
||||
|
|
|
|||
|
|
@ -1003,7 +1003,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
|
|||
dst->bounds += brush->bounds;
|
||||
}
|
||||
|
||||
logging::percent(src->nummapbrushes, src->nummapbrushes);
|
||||
logging::percent(src->nummapbrushes, src->nummapbrushes, src == pWorldEnt());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -622,7 +622,8 @@ void PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hulln
|
|||
|
||||
MakeHeadnodePortals(entity, headnode);
|
||||
CutNodePortals_r(headnode, &state);
|
||||
logging::percent(splitnodes, splitnodes);
|
||||
|
||||
logging::percent(splitnodes, splitnodes, entity == pWorldEnt());
|
||||
|
||||
if (hullnum <= 0) {
|
||||
/* save portal file for vis tracing */
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ static void PartitionSurfaces(std::vector<surface_t> &surfaces, node_t *node)
|
|||
LinkConvexFaces(surfaces, node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
logging::percent(splitnodes++, csgmergefaces);
|
||||
|
||||
node->facelist = LinkNodeFaces(*split);
|
||||
|
|
@ -826,7 +826,8 @@ node_t *SolidBSP(const mapentity_t *entity, std::vector<surface_t> &surfhead, bo
|
|||
mapsurfaces = surfhead.size();
|
||||
|
||||
PartitionSurfaces(surfhead, headnode);
|
||||
logging::percent(csgmergefaces, csgmergefaces);
|
||||
|
||||
logging::percent(csgmergefaces, csgmergefaces, entity == pWorldEnt());
|
||||
|
||||
logging::print(logging::flag::STAT, " {:8} split nodes\n", splitnodes.load());
|
||||
logging::print(logging::flag::STAT, " {:8} solid leafs\n", c_solid.load());
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ std::list<face_t *>::iterator SubdivideFace(std::list<face_t *>::iterator it, st
|
|||
|
||||
std::tie(front, back) = SplitFace(f, plane);
|
||||
if (!front || !back) {
|
||||
logging::print("didn't split\n");
|
||||
//logging::print("didn't split\n");
|
||||
break;
|
||||
// FError("Didn't split the polygon");
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ static int MakeFaceEdges_r(mapentity_t *entity, node_t *node, int progress)
|
|||
FindFaceEdges(entity, f);
|
||||
}
|
||||
|
||||
logging::percent(++progress, splitnodes.load());
|
||||
logging::percent(progress, splitnodes, entity);
|
||||
progress = MakeFaceEdges_r(entity, node->children[0], progress);
|
||||
progress = MakeFaceEdges_r(entity, node->children[1], progress);
|
||||
|
||||
|
|
@ -495,6 +495,7 @@ int MakeFaceEdges(mapentity_t *entity, node_t *headnode)
|
|||
|
||||
firstface = static_cast<int>(map.bsp.dfaces.size());
|
||||
MakeFaceEdges_r(entity, headnode, 0);
|
||||
logging::percent(splitnodes, splitnodes, entity == pWorldEnt());
|
||||
|
||||
pEdgeFaces0.clear();
|
||||
pEdgeFaces1.clear();
|
||||
|
|
|
|||
Loading…
Reference in New Issue