]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Merge commit 'aa4bc3893f6c0c360c91896eba46631e53b2f0d1' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 04:18:35 +0000 (06:18 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 04:18:35 +0000 (06:18 +0200)
1  2 
tools/quake3/q3map2/help.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/model.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/surface.c

index 60631e3d72f175a38c581b28a50df232ea8289ab,53cccff9470cd10ba68650a354f16546b58c997d..fe613d042936d168d0fe75255b46a242edb78a2d
@@@ -219,7 -195,8 +219,8 @@@ 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", "Use `-fastallocate` to trade lightmap size against allocation time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"},
 +              {"-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)"},
+               {"-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm (default)"},
                {"-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"},
@@@ -533,8 -420,7 +534,8 @@@ void HelpMain(const char* arg
                                help_funcs[i]();
                                return;
                        }
-               }
+       }
 +      }
  
 -      HelpOptions("Stages", 0, 80, stages, sizeof(stages)/sizeof(struct HelpOption));
 +      HelpOptions("Stages", 0, terminalColumns, stages, sizeof(stages)/sizeof(struct HelpOption));
  }
index f14cc43c843c4f8c8efdb30d632767832898ca82,7d3be10e592df2b826ec280ea1f336f374ef0707..20252c36a9d2b113efa943cf0f4d771722e38006
@@@ -1771,17 -1774,7 +1771,17 @@@ void TraceGrid( int num )
                        }
  
                /* vortex: apply gridscale and gridambientscale here */
-                       ColorToBytes(color, bgp->ambient[i], gridScale * gridAmbientScale);
 +              if (gp->directed[i][0] || gp->directed[i][1] || gp->directed[i][2]) {
 +                      /*
 +                       * HACK: if there's a non-zero directed component, this
 +                       * lightgrid cell is useful. However, ioq3 skips grid
 +                       * cells with zero ambient. So let's force ambient to be
 +                       * nonzero unless directed is zero too.
 +                       */
 +                      ColorToBytesNonZero(color, bgp->ambient[i], gridScale * gridAmbientScale);
 +              } else {
+               ColorToBytes( color, bgp->ambient[ i ], gridScale * gridAmbientScale );
 +              }
                ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
        }
  
@@@ -2035,19 -2031,13 +2035,19 @@@ void LightWorld( const char *BSPFilePat
        /* radiosity */
        b = 1;
        bt = bounce;
 +
        while ( bounce > 0 )
        {
 +              qboolean storeForReal = !noBounceStore;
 +
                /* store off the bsp between bounces */
 -              StoreSurfaceLightmaps( fastAllocate );
 +              StoreSurfaceLightmaps( fastAllocate, storeForReal );
                UnparseEntities();
-                       Sys_Printf( "Writing %s\n", BSPFilePath );
-                       WriteBSPFile( BSPFilePath );
 +
 +              if ( storeForReal ) {
+               Sys_Printf( "Writing %s\n", BSPFilePath );
+               WriteBSPFile( BSPFilePath );
 +              }
  
                /* note it */
                Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
@@@ -2153,8 -2119,7 +2153,8 @@@ int LightMain( int argc, char **argv )
        const char  *value;
        int lightmapMergeSize = 0;
        qboolean lightSamplesInsist = qfalse;
-       qboolean fastAllocate = qfalse;
+       qboolean fastAllocate = qtrue;
 +      qboolean noBounceStore = qfalse;
  
        /* note it */
        Sys_Printf( "--- Light ---\n" );
                        Sys_Printf( "Faster mode enabled\n" );
                }
  
 -              else if ( !strcmp( argv[ i ], "-fastallocate" ) ) {
 +              else if ( !strcmp( argv[ i ], "-fastallocate" ) || !strcmp( argv[ i ], "-fastlightmapsearch" ) ) {
                        fastAllocate = qtrue;
 -                      Sys_Printf( "Fast allocation mode enabled\n" );
 +
 +                      if ( !strcmp( argv[ i ], "-fastlightmapsearch" ) ) {
 +                              Sys_Printf( "The -fastlightmapsearch argument is deprecated, use \"-fastallocate\" instead\n" );
 +                      }
 +                      else {
 +                              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 ], "-slowallocate" ) ) {
+                       fastAllocate = qfalse;
+                       Sys_Printf( "Slow allocation mode enabled\n" );
+               }
                else if ( !strcmp( argv[ i ], "-fastgrid" ) ) {
                        fastgrid = qtrue;
                        Sys_Printf( "Fast grid lighting enabled\n" );
index 3c08c8b60d13c1223ba795bdf08a556121300bf1,6d61b8d7be998c8e83762df7d17b75935f233c6b..2802ecaf4370c223b2d8c3e29ce6b8061154ca9d
@@@ -2478,8 -2496,8 +2486,8 @@@ void FillOutLightmap( outLightmap_t *ol
     stores the surface lightmaps into the bsp as byte rgb triplets
   */
  
 -void StoreSurfaceLightmaps( qboolean fastAllocate ){
 +void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
-       int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples;
+       int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples, timer_start;
        int style, size, lightmapNum, lightmapNum2;
        float               *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples;
        vec3_t sample, occludedSample, dirSample, colorMins, colorMaxs;
           allocate output lightmaps
           ----------------------------------------------------------------- */
  
 -      /* note it */
 -      Sys_FPrintf( SYS_VRB, "allocating..." );
 +      if ( storeForReal ) {
 +              /* note it */
 +              Sys_FPrintf( SYS_VRB, "allocating..." );
  
 -      /* kill all existing output lightmaps */
 -      if ( outLightmaps != NULL ) {
 -              for ( i = 0; i < numOutLightmaps; i++ )
 -              {
 -                      free( outLightmaps[ i ].lightBits );
 -                      free( outLightmaps[ i ].bspLightBytes );
+       timer_start = I_FloatTime();
 +              /* kill all existing output lightmaps */
 +              if ( outLightmaps != NULL ) {
 +                      for ( i = 0; i < numOutLightmaps; i++ )
 +                      {
 +                              free( outLightmaps[ i ].lightBits );
 +                              free( outLightmaps[ i ].bspLightBytes );
 +                      }
 +                      free( outLightmaps );
 +                      outLightmaps = NULL;
                }
 -              free( outLightmaps );
 -              outLightmaps = NULL;
 -      }
 -
 -      numLightmapShaders = 0;
 -      numOutLightmaps = 0;
 -      numBSPLightmaps = 0;
 -      numExtLightmaps = 0;
  
 -      /* find output lightmap */
 -      for ( i = 0; i < numRawLightmaps; i++ )
 -      {
 -              lm = &rawLightmaps[ sortLightmaps[ i ] ];
 -              FindOutLightmaps( lm, fastAllocate );
 -      }
 +              numLightmapShaders = 0;
 +              numOutLightmaps = 0;
 +              numBSPLightmaps = 0;
 +              numExtLightmaps = 0;
  
 -      /* set output numbers in twinned lightmaps */
 -      for ( i = 0; i < numRawLightmaps; i++ )
 -      {
 -              /* get lightmap */
 -              lm = &rawLightmaps[ sortLightmaps[ i ] ];
 +              /* find output lightmap */
 +              for ( i = 0; i < numRawLightmaps; i++ )
 +              {
 +                      lm = &rawLightmaps[ sortLightmaps[ i ] ];
 +                      FindOutLightmaps( lm, fastAllocate );
 +              }
  
 -              /* walk lightmaps */
 -              for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 +              /* set output numbers in twinned lightmaps */
 +              for ( i = 0; i < numRawLightmaps; i++ )
                {
 -                      /* get twin */
 -                      lm2 = lm->twins[ lightmapNum ];
 -                      if ( lm2 == NULL ) {
 -                              continue;
 -                      }
 -                      lightmapNum2 = lm->twinNums[ lightmapNum ];
 +                      /* get lightmap */
 +                      lm = &rawLightmaps[ sortLightmaps[ i ] ];
  
 -                      /* find output lightmap from twin */
 -                      lm->outLightmapNums[ lightmapNum ] = lm2->outLightmapNums[ lightmapNum2 ];
 -                      lm->lightmapX[ lightmapNum ] = lm2->lightmapX[ lightmapNum2 ];
 -                      lm->lightmapY[ lightmapNum ] = lm2->lightmapY[ lightmapNum2 ];
 +                      /* walk lightmaps */
 +                      for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 +                      {
 +                              /* get twin */
 +                              lm2 = lm->twins[ lightmapNum ];
 +                              if ( lm2 == NULL ) {
 +                                      continue;
 +                              }
 +                              lightmapNum2 = lm->twinNums[ lightmapNum ];
 +
 +                              /* find output lightmap from twin */
 +                              lm->outLightmapNums[ lightmapNum ] = lm2->outLightmapNums[ lightmapNum2 ];
 +                              lm->lightmapX[ lightmapNum ] = lm2->lightmapX[ lightmapNum2 ];
 +                              lm->lightmapY[ lightmapNum ] = lm2->lightmapY[ lightmapNum2 ];
 +                      }
                }
        }
  
           store output lightmaps
           ----------------------------------------------------------------- */
  
 -      /* note it */
 -      Sys_FPrintf( SYS_VRB, "storing..." );
 +      if ( storeForReal ) {
 +              /* note it */
 +              Sys_FPrintf( SYS_VRB, "storing..." );
  
 -      /* count the bsp lightmaps and allocate space */
 -      if ( bspLightBytes != NULL ) {
 -              free( bspLightBytes );
 -      }
 -      if ( numBSPLightmaps == 0 || externalLightmaps ) {
 -              numBSPLightBytes = 0;
 -              bspLightBytes = NULL;
 -      }
 -      else
 -      {
 -              numBSPLightBytes = ( numBSPLightmaps * game->lightmapSize * game->lightmapSize * 3 );
 -              bspLightBytes = safe_malloc( numBSPLightBytes );
 -              memset( bspLightBytes, 0, numBSPLightBytes );
 -      }
 -
 -      /* walk the list of output lightmaps */
 -      for ( i = 0; i < numOutLightmaps; i++ )
 -      {
 -              /* get output lightmap */
 -              olm = &outLightmaps[ i ];
 -
 -              /* fill output lightmap */
 -              if ( lightmapFill ) {
 -                      FillOutLightmap( olm );
+       timer_start = I_FloatTime();
 +              /* count the bsp lightmaps and allocate space */
 +              if ( bspLightBytes != NULL ) {
 +                      free( bspLightBytes );
 +              }
 +              if ( numBSPLightmaps == 0 || externalLightmaps ) {
 +                      numBSPLightBytes = 0;
 +                      bspLightBytes = NULL;
 +              }
 +              else
 +              {
 +                      numBSPLightBytes = ( numBSPLightmaps * game->lightmapSize * game->lightmapSize * 3 );
 +                      bspLightBytes = safe_malloc0( numBSPLightBytes );
                }
  
 -              /* is this a valid bsp lightmap? */
 -              if ( olm->lightmapNum >= 0 && !externalLightmaps ) {
 -                      /* copy lighting data */
 -                      lb = bspLightBytes + ( olm->lightmapNum * game->lightmapSize * game->lightmapSize * 3 );
 -                      memcpy( lb, olm->bspLightBytes, game->lightmapSize * game->lightmapSize * 3 );
 +              /* walk the list of output lightmaps */
 +              for ( i = 0; i < numOutLightmaps; i++ )
 +              {
 +                      /* get output lightmap */
 +                      olm = &outLightmaps[ i ];
  
 -                      /* copy direction data */
 -                      if ( deluxemap ) {
 -                              lb = bspLightBytes + ( ( olm->lightmapNum + 1 ) * game->lightmapSize * game->lightmapSize * 3 );
 -                              memcpy( lb, olm->bspDirBytes, game->lightmapSize * game->lightmapSize * 3 );
 +                      /* fill output lightmap */
 +                      if ( lightmapFill ) {
 +                              FillOutLightmap( olm );
                        }
 -              }
  
 -              /* external lightmap? */
 -              if ( olm->lightmapNum < 0 || olm->extLightmapNum >= 0 || externalLightmaps ) {
 -                      /* make a directory for the lightmaps */
 -                      Q_mkdir( dirname );
 +                      /* is this a valid bsp lightmap? */
 +                      if ( olm->lightmapNum >= 0 && !externalLightmaps ) {
 +                              /* copy lighting data */
 +                              lb = bspLightBytes + ( olm->lightmapNum * game->lightmapSize * game->lightmapSize * 3 );
 +                              memcpy( lb, olm->bspLightBytes, game->lightmapSize * game->lightmapSize * 3 );
  
 -                      /* set external lightmap number */
 -                      olm->extLightmapNum = numExtLightmaps;
 +                              /* copy direction data */
 +                              if ( deluxemap ) {
 +                                      lb = bspLightBytes + ( ( olm->lightmapNum + 1 ) * game->lightmapSize * game->lightmapSize * 3 );
 +                                      memcpy( lb, olm->bspDirBytes, game->lightmapSize * game->lightmapSize * 3 );
 +                              }
 +                      }
 +
 +                      /* external lightmap? */
 +                      if ( olm->lightmapNum < 0 || olm->extLightmapNum >= 0 || externalLightmaps ) {
 +                              /* make a directory for the lightmaps */
 +                              Q_mkdir( dirname );
  
 -                      /* write lightmap */
 -                      sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
 -                      Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
 -                      WriteTGA24( filename, olm->bspLightBytes, olm->customWidth, olm->customHeight, qtrue );
 -                      numExtLightmaps++;
 +                              /* set external lightmap number */
 +                              olm->extLightmapNum = numExtLightmaps;
  
 -                      /* write deluxemap */
 -                      if ( deluxemap ) {
 +                              /* write lightmap */
                                sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
                                Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
 -                              WriteTGA24( filename, olm->bspDirBytes, olm->customWidth, olm->customHeight, qtrue );
 +                              WriteTGA24( filename, olm->bspLightBytes, olm->customWidth, olm->customHeight, qtrue );
                                numExtLightmaps++;
  
 -                              if ( debugDeluxemap ) {
 -                                      olm->extLightmapNum++;
 +                              /* write deluxemap */
 +                              if ( deluxemap ) {
 +                                      sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
 +                                      Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
 +                                      WriteTGA24( filename, olm->bspDirBytes, olm->customWidth, olm->customHeight, qtrue );
 +                                      numExtLightmaps++;
 +
 +                                      if ( debugDeluxemap ) {
 +                                              olm->extLightmapNum++;
 +                                      }
                                }
                        }
                }
 -      }
 -
 -      if ( numExtLightmaps > 0 ) {
 -              Sys_FPrintf( SYS_VRB, "\n" );
 -      }
  
 -      /* delete unused external lightmaps */
 -      for ( i = numExtLightmaps; i; i++ )
 -      {
 -              /* determine if file exists */
 -              sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, i );
 -              if ( !FileExists( filename ) ) {
 -                      break;
 +              if ( numExtLightmaps > 0 ) {
 +                      Sys_FPrintf( SYS_VRB, "\n" );
                }
  
 -              /* delete it */
 -              remove( filename );
 +              /* delete unused external lightmaps */
 +              for ( i = numExtLightmaps; i; i++ )
 +              {
 +                      /* determine if file exists */
 +                      sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, i );
 +                      if ( !FileExists( filename ) ) {
 +                              break;
 +                      }
 +
 +                      /* delete it */
 +                      remove( filename );
 +              }
        }
  
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
        /* -----------------------------------------------------------------
           project the lightmaps onto the bsp surfaces
           ----------------------------------------------------------------- */
  
 -      /* note it */
 -      Sys_FPrintf( SYS_VRB, "projecting..." );
 +      if ( storeForReal ) {
 +              /* note it */
 +              Sys_FPrintf( SYS_VRB, "projecting..." );
  
 -      /* walk the list of surfaces */
 -      for ( i = 0; i < numBSPDrawSurfaces; i++ )
 -      {
 -              /* get the surface and info */
 -              ds = &bspDrawSurfaces[ i ];
 -              info = &surfaceInfos[ i ];
 -              lm = info->lm;
 -              olm = NULL;
 -
 -              /* handle surfaces with identical parent */
 -              if ( info->parentSurfaceNum >= 0 ) {
 -                      /* preserve original data and get parent */
 -                      parent = &bspDrawSurfaces[ info->parentSurfaceNum ];
 -                      memcpy( &dsTemp, ds, sizeof( *ds ) );
 -
 -                      /* overwrite child with parent data */
 -                      memcpy( ds, parent, sizeof( *ds ) );
 -
 -                      /* restore key parts */
 -                      ds->fogNum = dsTemp.fogNum;
 -                      ds->firstVert = dsTemp.firstVert;
 -                      ds->firstIndex = dsTemp.firstIndex;
 -                      memcpy( ds->lightmapVecs, dsTemp.lightmapVecs, sizeof( dsTemp.lightmapVecs ) );
 -
 -                      /* set vertex data */
 -                      dv = &bspDrawVerts[ ds->firstVert ];
 -                      dvParent = &bspDrawVerts[ parent->firstVert ];
 -                      for ( j = 0; j < ds->numVerts; j++ )
 -                      {
 -                              memcpy( dv[ j ].lightmap, dvParent[ j ].lightmap, sizeof( dv[ j ].lightmap ) );
 -                              memcpy( dv[ j ].color, dvParent[ j ].color, sizeof( dv[ j ].color ) );
 -                      }
+       timer_start = I_FloatTime();
 +              /* walk the list of surfaces */
 +              for ( i = 0; i < numBSPDrawSurfaces; i++ )
 +              {
 +                      /* get the surface and info */
 +                      ds = &bspDrawSurfaces[ i ];
 +                      info = &surfaceInfos[ i ];
 +                      lm = info->lm;
 +                      olm = NULL;
  
 -                      /* skip the rest */
 -                      continue;
 -              }
 +                      /* handle surfaces with identical parent */
 +                      if ( info->parentSurfaceNum >= 0 ) {
 +                              /* preserve original data and get parent */
 +                              parent = &bspDrawSurfaces[ info->parentSurfaceNum ];
 +                              memcpy( &dsTemp, ds, sizeof( *ds ) );
  
 -              /* handle vertex lit or approximated surfaces */
 -              else if ( lm == NULL || lm->outLightmapNums[ 0 ] < 0 ) {
 -                      for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 -                      {
 -                              ds->lightmapNum[ lightmapNum ] = -3;
 -                              ds->lightmapStyles[ lightmapNum ] = ds->vertexStyles[ lightmapNum ];
 -                      }
 -              }
 +                              /* overwrite child with parent data */
 +                              memcpy( ds, parent, sizeof( *ds ) );
  
 -              /* handle lightmapped surfaces */
 -              else
 -              {
 -                      /* walk lightmaps */
 -                      for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 -                      {
 -                              /* set style */
 -                              ds->lightmapStyles[ lightmapNum ] = lm->styles[ lightmapNum ];
 +                              /* restore key parts */
 +                              ds->fogNum = dsTemp.fogNum;
 +                              ds->firstVert = dsTemp.firstVert;
 +                              ds->firstIndex = dsTemp.firstIndex;
 +                              memcpy( ds->lightmapVecs, dsTemp.lightmapVecs, sizeof( dsTemp.lightmapVecs ) );
  
 -                              /* handle unused style */
 -                              if ( lm->styles[ lightmapNum ] == LS_NONE || lm->outLightmapNums[ lightmapNum ] < 0 ) {
 +                              /* set vertex data */
 +                              dv = &bspDrawVerts[ ds->firstVert ];
 +                              dvParent = &bspDrawVerts[ parent->firstVert ];
 +                              for ( j = 0; j < ds->numVerts; j++ )
 +                              {
 +                                      memcpy( dv[ j ].lightmap, dvParent[ j ].lightmap, sizeof( dv[ j ].lightmap ) );
 +                                      memcpy( dv[ j ].color, dvParent[ j ].color, sizeof( dv[ j ].color ) );
 +                              }
 +
 +                              /* skip the rest */
 +                              continue;
 +                      }
 +
 +                      /* handle vertex lit or approximated surfaces */
 +                      else if ( lm == NULL || lm->outLightmapNums[ 0 ] < 0 ) {
 +                              for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 +                              {
                                        ds->lightmapNum[ lightmapNum ] = -3;
 -                                      continue;
 +                                      ds->lightmapStyles[ lightmapNum ] = ds->vertexStyles[ lightmapNum ];
                                }
 +                      }
  
 -                              /* get output lightmap */
 -                              olm = &outLightmaps[ lm->outLightmapNums[ lightmapNum ] ];
 +                      /* handle lightmapped surfaces */
 +                      else
 +                      {
 +                              /* walk lightmaps */
 +                              for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 +                              {
 +                                      /* set style */
 +                                      ds->lightmapStyles[ lightmapNum ] = lm->styles[ lightmapNum ];
  
 -                              /* set bsp lightmap number */
 -                              ds->lightmapNum[ lightmapNum ] = olm->lightmapNum;
 +                                      /* handle unused style */
 +                                      if ( lm->styles[ lightmapNum ] == LS_NONE || lm->outLightmapNums[ lightmapNum ] < 0 ) {
 +                                              ds->lightmapNum[ lightmapNum ] = -3;
 +                                              continue;
 +                                      }
  
 -                              /* deluxemap debugging makes the deluxemap visible */
 -                              if ( deluxemap && debugDeluxemap && lightmapNum == 0 ) {
 -                                      ds->lightmapNum[ lightmapNum ]++;
 -                              }
 +                                      /* get output lightmap */
 +                                      olm = &outLightmaps[ lm->outLightmapNums[ lightmapNum ] ];
  
 -                              /* calc lightmap origin in texture space */
 -                              lmx = (float) lm->lightmapX[ lightmapNum ] / (float) olm->customWidth;
 -                              lmy = (float) lm->lightmapY[ lightmapNum ] / (float) olm->customHeight;
 +                                      /* set bsp lightmap number */
 +                                      ds->lightmapNum[ lightmapNum ] = olm->lightmapNum;
  
 -                              /* calc lightmap st coords */
 -                              dv = &bspDrawVerts[ ds->firstVert ];
 -                              ydv = &yDrawVerts[ ds->firstVert ];
 -                              for ( j = 0; j < ds->numVerts; j++ )
 -                              {
 -                                      if ( lm->solid[ lightmapNum ] ) {
 -                                              dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + ( 0.5f / (float) olm->customWidth );
 -                                              dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + ( 0.5f / (float) olm->customWidth );
 +                                      /* deluxemap debugging makes the deluxemap visible */
 +                                      if ( deluxemap && debugDeluxemap && lightmapNum == 0 ) {
 +                                              ds->lightmapNum[ lightmapNum ]++;
                                        }
 -                                      else
 +
 +                                      /* calc lightmap origin in texture space */
 +                                      lmx = (float) lm->lightmapX[ lightmapNum ] / (float) olm->customWidth;
 +                                      lmy = (float) lm->lightmapY[ lightmapNum ] / (float) olm->customHeight;
 +
 +                                      /* calc lightmap st coords */
 +                                      dv = &bspDrawVerts[ ds->firstVert ];
 +                                      ydv = &yDrawVerts[ ds->firstVert ];
 +                                      for ( j = 0; j < ds->numVerts; j++ )
                                        {
 -                                              dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + ( ydv[ j ].lightmap[ 0 ][ 0 ] / ( superSample * olm->customWidth ) );
 -                                              dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + ( ydv[ j ].lightmap[ 0 ][ 1 ] / ( superSample * olm->customHeight ) );
 +                                              if ( lm->solid[ lightmapNum ] ) {
 +                                                      dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + ( 0.5f / (float) olm->customWidth );
 +                                                      dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + ( 0.5f / (float) olm->customWidth );
 +                                              }
 +                                              else
 +                                              {
 +                                                      dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + ( ydv[ j ].lightmap[ 0 ][ 0 ] / ( superSample * olm->customWidth ) );
 +                                                      dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + ( ydv[ j ].lightmap[ 0 ][ 1 ] / ( superSample * olm->customHeight ) );
 +                                              }
                                        }
                                }
                        }
Simple merge
index e644cc8be83d94971d63b1d0e6342cde8b5993cd,f6296f1b72aae3412f8dcd4c90c175d1503195a8..720dec29053fc042f0541d74295b7e0cc0d053cf
@@@ -1879,14 -1860,9 +1879,9 @@@ int                         ImportLight
  
  void                        SetupSurfaceLightmaps( void );
  void                        StitchSurfaceLightmaps( void );
 -void                        StoreSurfaceLightmaps( qboolean fastAllocate );
 +void                        StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal );
  
  
- /* exportents.c */
- void                        ExportEntities( void );
- int                         ExportEntitiesMain( int argc, char **argv );
  /* exportents.c */
  void                        ExportEntities( void );
  int                         ExportEntitiesMain( int argc, char **argv );
Simple merge