]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
-lightmapsearchpower
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Fri, 22 May 2009 06:07:19 +0000 (06:07 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Fri, 22 May 2009 06:07:19 +0000 (06:07 +0000)
-lightmapsearchblocksize
to optimize lightmap search for darkplaces and other lightmap-merging engines

git-svn-id: svn://svn.icculus.org/netradiant/trunk@370 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/q3map2/light.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/q3map2.h

index eacfba3162800f1b34b7ab10547feb0a57ebaa82..1517ba962eef050a059ee19300662f8ed6a0c2af 100644 (file)
@@ -1845,6 +1845,7 @@ int LightMain( int argc, char **argv )
        float           f;
        char            mapSource[ 1024 ];
        const char      *value;
+       int lightmapMergeSize = 0;
        
        
        /* note it */
@@ -2171,10 +2172,24 @@ int LightMain( int argc, char **argv )
 
                else if( !strcmp( argv[ i ], "-nolightmapsearch" ) )
                {
-                       noLightmapSearch = qtrue;
+                       lightmapSearchBlockSize = 1;
                        Sys_Printf( "No lightmap searching - all lightmaps will be sequential\n" );
                }
                
+               else if( !strcmp( argv[ i ], "-lightmapsearchpower" ) )
+               {
+                       lightmapMergeSize = (game->lightmapSize << atoi(argv[i+1]));
+                       ++i;
+                       Sys_Printf( "Restricted lightmap searching enabled - optimize for lightmap merge power %d (size %d)\n", atoi(argv[i]), lightmapMergeSize );
+               }
+               
+               else if( !strcmp( argv[ i ], "-lightmapsearchblocksize" ) )
+               {
+                       lightmapSearchBlockSize = atoi(argv[i+1]);
+                       ++i;
+                       Sys_Printf( "Restricted lightmap searching enabled - block size set to %d\n", lightmapSearchBlockSize );
+               }
+               
                else if( !strcmp( argv[ i ], "-shade" ) )
                {
                        shade = qtrue;
@@ -2467,6 +2482,16 @@ int LightMain( int argc, char **argv )
                }
 
        }
+
+       /* fix up lightmap search power */
+       if(lightmapMergeSize)
+       {
+               lightmapSearchBlockSize = (lightmapMergeSize / lmCustomSize) * (lightmapMergeSize / lmCustomSize);
+               if(lightmapSearchBlockSize < 1)
+                       lightmapSearchBlockSize = 1;
+
+               Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
+       }
        
        /* clean up map name */
        strcpy( source, ExpandArg( argv[ i ] ) );
index e6875c0eb89407c647ec844e9063652091536e76..eee4f6f8e19db45c077f59a4d20e24b685d07e2f 100644 (file)
@@ -2016,7 +2016,11 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                        y = 0;
                        
                        /* walk the list of lightmap pages */
-                       for( i = ((noLightmapSearch && numOutLightmaps >= LIGHTMAP_RESERVE_COUNT) ? (numOutLightmaps - LIGHTMAP_RESERVE_COUNT) : 0); i < numOutLightmaps; i++ )
+                       if(lightmapSearchBlockSize <= 0)
+                               i = 0;
+                       else
+                               i = ((numOutLightmaps - LIGHTMAP_RESERVE_COUNT) / lightmapSearchBlockSize) * lightmapSearchBlockSize;
+                       for( ; i < numOutLightmaps; i++ )
                        {
                                /* get the output lightmap */
                                olm = &outLightmaps[ i ];
index f5ab761942e128ae85b3fbd06d57d67377f07f01..cf8eefd6e7bdecbd8e64d4ad9894be6e536c0a7a 100644 (file)
@@ -2179,7 +2179,7 @@ Q_EXTERN qboolean                 dark Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      sunOnly Q_ASSIGN( qfalse );
 Q_EXTERN int                           approximateTolerance Q_ASSIGN( 0 );
 Q_EXTERN qboolean                      noCollapse Q_ASSIGN( qfalse );
-Q_EXTERN qboolean                      noLightmapSearch Q_ASSIGN( qfalse );
+Q_EXTERN int                           lightmapSearchBlockSize Q_ASSIGN( 0 );
 Q_EXTERN qboolean                      exportLightmaps Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      externalLightmaps Q_ASSIGN( qfalse );
 Q_EXTERN int                           lmCustomSize Q_ASSIGN( LIGHTMAP_WIDTH );