From 0012eff8c732414960a7bb02765b230014b1650d Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Mon, 3 May 2021 03:08:34 +0200 Subject: [PATCH] q3map2: switch back to fastallocate option name to reduce diff with NRC, keep compatibility with fastlightmapsearch --- tools/quake3/q3map2/help.c | 5 +++-- tools/quake3/q3map2/light.c | 25 +++++++++++++++---------- tools/quake3/q3map2/lightmaps_ydnar.c | 10 +++++----- tools/quake3/q3map2/q3map2.h | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c index e56b99a0..96409f42 100644 --- a/tools/quake3/q3map2/help.c +++ b/tools/quake3/q3map2/help.c @@ -214,11 +214,11 @@ void HelpLight() {"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"}, {"-extrawide", "Deprecated alias for `-super 2 -filter`"}, {"-extra", "Deprecated alias for `-super 2`"}, - {"-fastallocate", "Deprecated alias for `-fastlightmapsearch`"}, + {"-fastallocate", "Trade lightmap size against packing time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"}, {"-fastbounce", "Use `-fast` style lighting for radiosity"}, {"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"}, {"-fastgrid", "Use `-fast` style lighting for the light grid"}, - {"-fastlightmapsearch", "Use `-fastlightmapsearch` to trade lightmap size against packing time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"}, + {"-fastlightmapsearch", "Deprecated alias for `-fastallocate`"}, {"-fast", "Ignore tiny light contributions"}, {"-fill", "Fill lightmap colors from surrounding pixels to improve JPEG compression"}, {"-filter", "Lightmap filtering"}, @@ -266,6 +266,7 @@ void HelpLight() {"-shadeangle ", "Angle for phong shading"}, {"-shade", "Enable phong shading at default shade angle"}, {"-skyscale ", "Scaling factor for sky and sun light"}, + {"-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm (default)"}, {"-smooth", "Deprecated alias for `-samples 2`"}, {"-sphericalscale ", "Scaling factor for spherical point light entities"}, {"-spotscale ", "Scaling factor for spot point light entities"}, diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index bedc3f17..99d79484 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1895,7 +1895,7 @@ void SetupGrid( void ){ does what it says... */ -void LightWorld( const char *BSPFilePath, qboolean fastLightmapSearch, qboolean noBounceStore ){ +void LightWorld( const char *BSPFilePath, qboolean fastAllocate, qboolean noBounceStore ){ vec3_t color; float f; int b, bt; @@ -2041,7 +2041,7 @@ void LightWorld( const char *BSPFilePath, qboolean fastLightmapSearch, qboolean qboolean storeForReal = !noBounceStore; /* store off the bsp between bounces */ - StoreSurfaceLightmaps( fastLightmapSearch, storeForReal ); + StoreSurfaceLightmaps( fastAllocate, storeForReal ); UnparseEntities(); if ( storeForReal ) { @@ -2113,7 +2113,7 @@ void LightWorld( const char *BSPFilePath, qboolean fastLightmapSearch, qboolean } /* ydnar: store off lightmaps */ - StoreSurfaceLightmaps( fastLightmapSearch, qtrue ); + StoreSurfaceLightmaps( fastAllocate, qtrue ); } @@ -2153,7 +2153,7 @@ int LightMain( int argc, char **argv ){ const char *value; int lightmapMergeSize = 0; qboolean lightSamplesInsist = qfalse; - qboolean fastLightmapSearch = qfalse; + qboolean fastAllocate = qfalse; qboolean noBounceStore = qfalse; /* note it */ @@ -2682,17 +2682,22 @@ int LightMain( int argc, char **argv ){ Sys_Printf( "Faster mode enabled\n" ); } - else if ( !strcmp( argv[ i ], "-fastlightmapsearch" ) || !strcmp( argv[ i ], "-fastallocate") ) { - fastLightmapSearch = qtrue; + else if ( !strcmp( argv[ i ], "-fastallocate" ) || !strcmp( argv[ i ], "-fastlightmapsearch" ) ) { + fastAllocate = qtrue; - if ( !strcmp( argv[ i ], "-fastallocate" ) ) { - Sys_Printf( "The -fastallocate argument is deprecated, use \"-fastlightmapsearch\" instead\n" ); + if ( !strcmp( argv[ i ], "-fastlightmapsearch" ) ) { + Sys_Printf( "The -fastlightmapsearch argument is deprecated, use \"-fastallocate\" instead\n" ); } else { - Sys_Printf( "Fast lightmap search enabled\n" ); + Sys_Printf( "Fast lightmap allocation mode enabled\n" ); } } + else if ( !strcmp( argv[ i ], "-slowallocate" ) ) { + fastAllocate = qfalse; + Sys_Printf( "Slow lightmap allocation mode enabled (default)\n" ); + } + else if ( !strcmp( argv[ i ], "-fastgrid" ) ) { fastgrid = qtrue; Sys_Printf( "Fast grid lighting enabled\n" ); @@ -3059,7 +3064,7 @@ int LightMain( int argc, char **argv ){ SetupTraceNodes(); /* light the world */ - LightWorld( BSPFilePath, fastLightmapSearch, noBounceStore ); + LightWorld( BSPFilePath, fastAllocate, noBounceStore ); /* write out the bsp */ UnparseEntities(); diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index f6203f53..37bb6da4 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -1966,7 +1966,7 @@ static void SetupOutLightmap( rawLightmap_t *lm, outLightmap_t *olm ){ */ #define LIGHTMAP_RESERVE_COUNT 1 -static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastLightmapSearch ){ +static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastAllocate ){ int i, j, k, lightmapNum, xMax, yMax, x = -1, y = -1, sx, sy, ox, oy, offset; outLightmap_t *olm; surfaceInfo_t *info; @@ -2085,7 +2085,7 @@ static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastLightmapSearch ){ } /* if fast allocation, skip lightmap files that are more than 90% complete */ - if ( fastLightmapSearch == qtrue ) { + if ( fastAllocate == qtrue ) { if (olm->freeLuxels < (olm->customWidth * olm->customHeight) / 10) { continue; } @@ -2109,7 +2109,7 @@ static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastLightmapSearch ){ } /* if fast allocation, do not test allocation on every pixels, especially for large lightmaps */ - if ( fastLightmapSearch == qtrue ) { + if ( fastAllocate == qtrue ) { xIncrement = MAX(1, lm->w / 15); yIncrement = MAX(1, lm->h / 15); } @@ -2452,7 +2452,7 @@ void FillOutLightmap( outLightmap_t *olm ){ stores the surface lightmaps into the bsp as byte rgb triplets */ -void StoreSurfaceLightmaps( qboolean fastLightmapSearch, qboolean storeForReal ){ +void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples; int style, size, lightmapNum, lightmapNum2; float *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples; @@ -3070,7 +3070,7 @@ void StoreSurfaceLightmaps( qboolean fastLightmapSearch, qboolean storeForReal ) for ( i = 0; i < numRawLightmaps; i++ ) { lm = &rawLightmaps[ sortLightmaps[ i ] ]; - FindOutLightmaps( lm, fastLightmapSearch ); + FindOutLightmaps( lm, fastAllocate ); } /* set output numbers in twinned lightmaps */ diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 767a118b..eac4ec38 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1874,7 +1874,7 @@ int ImportLightmapsMain( int argc, char **argv ); void SetupSurfaceLightmaps( void ); void StitchSurfaceLightmaps( void ); -void StoreSurfaceLightmaps( qboolean fastLightmapSearch, qboolean storeForReal ); +void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ); /* exportents.c */ -- 2.39.2