diff --git a/tools/quake3/q3map2/decals.cpp b/tools/quake3/q3map2/decals.cpp index 55ebd2ee..b2c1769b 100644 --- a/tools/quake3/q3map2/decals.cpp +++ b/tools/quake3/q3map2/decals.cpp @@ -626,7 +626,7 @@ static void ProjectDecalOntoTriangles( decalProjector_t& dp, const mapDrawSurfac */ void MakeEntityDecals( const entity_t& e ){ - int i, j, fOld; + int i, j; decalProjector_t dp; @@ -637,17 +637,14 @@ void MakeEntityDecals( const entity_t& e ){ entityOrigin.set( 0 ); /* init pacifier */ - fOld = -1; + Pacifier pacifier( numProjectors ); Timer timer; /* walk the list of decal projectors */ for ( i = 0; i < numProjectors; ++i ) { /* print pacifier */ - if ( const int f = 10 * i / numProjectors; f != fOld ) { - fOld = f; - Sys_FPrintf( SYS_VRB, "%d...", f ); - } + ++pacifier; /* get projector */ TransformDecalProjector( &projectors[ i ], g_vector3_axes, e.origin, &dp ); diff --git a/tools/quake3/q3map2/light_ydnar.cpp b/tools/quake3/q3map2/light_ydnar.cpp index bb50ea9f..0ab1ea54 100644 --- a/tools/quake3/q3map2/light_ydnar.cpp +++ b/tools/quake3/q3map2/light_ydnar.cpp @@ -158,7 +158,6 @@ Vector3b ColorToBytes( const Vector3& color, float scale ){ #define EQUAL_NORMAL_EPSILON 0.01f void SmoothNormals(){ - int fOld; float shadeAngle, defaultShadeAngle, maxShadeAngle; int indexes[ MAX_SAMPLES ]; Vector3 votes[ MAX_SAMPLES ]; @@ -209,17 +208,14 @@ void SmoothNormals(){ } /* init pacifier */ - fOld = -1; + Pacifier pacifier( numBSPDrawVerts ); Timer timer; /* go through the list of vertexes */ for ( int i = 0; i < numBSPDrawVerts; ++i ) { /* print pacifier */ - if ( const int f = 10 * i / numBSPDrawVerts; f != fOld ) { - fOld = f; - Sys_Printf( "%i...", f ); - } + ++pacifier; /* already smoothed? */ if ( smoothed[ i ] ) { diff --git a/tools/quake3/q3map2/lightmaps_ydnar.cpp b/tools/quake3/q3map2/lightmaps_ydnar.cpp index 47932311..d2df9846 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.cpp +++ b/tools/quake3/q3map2/lightmaps_ydnar.cpp @@ -1167,7 +1167,7 @@ void SetupSurfaceLightmaps(){ void StitchSurfaceLightmaps(){ int i, j, x, y, x2, y2, - numStitched, numCandidates, numLuxels, fOld; + numStitched, numCandidates, numLuxels; rawLightmap_t *lm, *a, *b, *c[ MAX_STITCH_CANDIDATES ]; float sampleSize, totalColor; @@ -1179,7 +1179,7 @@ void StitchSurfaceLightmaps(){ Sys_Printf( "--- StitchSurfaceLightmaps ---\n" ); /* init pacifier */ - fOld = -1; + Pacifier pacifier( numRawLightmaps ); Timer timer; /* walk the list of raw lightmaps */ @@ -1187,10 +1187,7 @@ void StitchSurfaceLightmaps(){ for ( i = 0; i < numRawLightmaps; ++i ) { /* print pacifier */ - if ( const int f = 10 * i / numRawLightmaps; f != fOld ) { - fOld = f; - Sys_Printf( "%i...", f ); - } + ++pacifier; /* get lightmap a */ a = &rawLightmaps[ i ]; diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 44f17914..8936871d 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1460,6 +1460,24 @@ public: }; +template +class Pacifier +{ + const int jobs; + int jobs_counter; + int counter; +public: + Pacifier( int jobs ) : jobs( jobs ), jobs_counter( jobs ), counter( 0 ){ + } + void operator++(){ + if ( ( jobs_counter += 10 ) > jobs ) { + jobs_counter -= jobs; + Sys_FPrintf( printf_flag, "%d...", counter++ ); + } + } +}; + + /* ------------------------------------------------------------------------------- prototypes diff --git a/tools/quake3/q3map2/surface_meta.cpp b/tools/quake3/q3map2/surface_meta.cpp index dac5537b..871b8b60 100644 --- a/tools/quake3/q3map2/surface_meta.cpp +++ b/tools/quake3/q3map2/surface_meta.cpp @@ -792,17 +792,14 @@ void MakeEntityMetaTriangles( const entity_t& e ){ Sys_FPrintf( SYS_VRB, "--- MakeEntityMetaTriangles ---\n" ); /* init pacifier */ - int fOld = -1; + Pacifier pacifier( numMapDrawSurfs - e.firstDrawSurf ); Timer timer; - /* walk the list of surfaces in the entity */ + /* walk the list of surfaces in the entity */ /* numMapDrawSurfs increases if patchMeta */ for ( int i = e.firstDrawSurf; i < numMapDrawSurfs; ++i ) { /* print pacifier */ - if ( const int f = 10 * ( i - e.firstDrawSurf ) / ( numMapDrawSurfs - e.firstDrawSurf ); f != fOld ) { - fOld = f; - Sys_FPrintf( SYS_VRB, "%d...", f ); - } + ++pacifier; /* get surface */ mapDrawSurface_t& ds = mapDrawSurfs[ i ]; @@ -917,7 +914,7 @@ static void CreateEdge( const Plane3f& plane, const Vector3& a, const Vector3& b void FixMetaTJunctions(){ #if 0 - int i, j, k, fOld, vertIndex, triIndex, numTJuncs; + int i, j, k, vertIndex, triIndex, numTJuncs; metaTriangle_t *tri, *newTri; shaderInfo_t *si; bspDrawVert_t *a, *b, *c, junc; @@ -933,7 +930,7 @@ void FixMetaTJunctions(){ Sys_FPrintf( SYS_VRB, "--- FixMetaTJunctions ---\n" ); /* init pacifier */ - fOld = -1; + Pacifier pacifier( numMetaTriangles ); Timer timer; /* walk triangle list */ @@ -944,10 +941,7 @@ void FixMetaTJunctions(){ tri = &metaTriangles[ i ]; /* print pacifier */ - if ( const int f = 10 * i / numMetaTriangles; f != fOld ) { - fOld = f; - Sys_FPrintf( SYS_VRB, "%d...", f ); - } + ++pacifier; /* attempt to early out */ si = tri->si; @@ -1448,11 +1442,13 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t& ds, const metaTriangle_t& creates map drawsurface(s) from the list of possibles */ -static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ +static void MetaTrianglesToSurface(){ /* allocate arrays */ DrawVerts verts; DrawIndexes indexes; + Pacifier pacifier( metaTriangles.size() ); + /* walk the list of triangles */ for ( auto& seed : metaTriangles ) { @@ -1526,7 +1522,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ /* add the first triangle */ if ( AddMetaTriangleToSurface( ds, seed, verts, indexes, texMinMax, sorted_indices, false ) ) { - ( *numAdded )++; + ++pacifier; } expand_cloud( seed ); @@ -1537,12 +1533,6 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ /* progressively walk the list until no more triangles can be added */ for( bool added = true; added; ) { - /* print pacifier */ - if ( const int f = 10 * *numAdded / metaTriangles.size(); f > *fOld ) { - *fOld = f; - Sys_FPrintf( SYS_VRB, "%d...", f ); - } - /* reset best score */ metaTriangle_t *best = nullptr; int bestScore = 0; @@ -1573,7 +1563,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ /* add best candidate */ if ( best != nullptr && bestScore > ADEQUATE_SCORE ) { if ( AddMetaTriangleToSurface( ds, *best, verts, indexes, texMinMax, sorted_indices, false ) ) { - ( *numAdded )++; + ++pacifier; expand_cloud( *best ); } @@ -1616,9 +1606,7 @@ void MergeMetaTriangles(){ Sys_FPrintf( SYS_VRB, "--- MergeMetaTriangles ---\n" ); /* init pacifier */ - int fOld = -1; Timer timer; - int numAdded = 0; #if 1 for( metaTriangle_t& tri : metaTriangles ){ for( const metaVertex_t *vert : tri.m_vertices ){ @@ -1627,7 +1615,7 @@ void MergeMetaTriangles(){ } metaTriangles.sort( CompareMetaTriangles() ); #endif - MetaTrianglesToSurface( &fOld, &numAdded ); + MetaTrianglesToSurface(); /* clear meta triangle list */ ClearMetaTriangles();