]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/lightmaps_ydnar.c
Merge commit 'b243946c9ffd022cd5d82f2cf474ebfb125929b9' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / lightmaps_ydnar.c
index f6203f538652e52d9aefd4297ca56f9fa47f54d7..3c08c8b60d13c1223ba795bdf08a556121300bf1 100644 (file)
@@ -695,16 +695,33 @@ qboolean AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){
                }
        }
 
-       if ( sampleSize != lm->sampleSize && lmLimitSize == 0 ) {
-               Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
-                                        info->mins[0],
-                                        info->mins[1],
-                                        info->mins[2],
-                                        info->maxs[0],
-                                        info->maxs[1],
-                                        info->maxs[2],
-                                        lm->sampleSize,
-                                        (int) sampleSize );
+       if ( sampleSize != lm->sampleSize && lmLimitSize == 0 ){
+               if ( debugSampleSize == 1 || lm->customWidth > 128 ){
+                       Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
+                                               info->mins[0],
+                                               info->mins[1],
+                                               info->mins[2],
+                                               info->maxs[0],
+                                               info->maxs[1],
+                                               info->maxs[2],
+                                               lm->sampleSize,
+                                               (int) sampleSize );
+               }
+               else if ( debugSampleSize == 0 ){
+                       Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
+                                               info->mins[0],
+                                               info->mins[1],
+                                               info->mins[2],
+                                               info->maxs[0],
+                                               info->maxs[1],
+                                               info->maxs[2],
+                                               lm->sampleSize,
+                                               (int) sampleSize );
+                       debugSampleSize--;
+               }
+               else{
+                       debugSampleSize--;
+               }
        }
 
        /* set actual sample size */
@@ -1089,7 +1106,8 @@ void SetupSurfaceLightmaps( void ){
                        /* determine if surface requires a lightmap */
                        if ( ds->surfaceType == MST_TRIANGLE_SOUP ||
                                 ds->surfaceType == MST_FOLIAGE ||
-                                ( info->si->compileFlags & C_VERTEXLIT ) ) {
+                               ( info->si->compileFlags & C_VERTEXLIT ) ||
+                               nolm == qtrue ) {
                                numSurfsVertexLit++;
                        }
                        else
@@ -1196,6 +1214,10 @@ void SetupSurfaceLightmaps( void ){
                FinishRawLightmap( lm );
        }
 
+       if ( debugSampleSize < -1 ){
+               Sys_FPrintf( SYS_VRB, "+%d similar occurrences;\t-debugSampleSize to show ones\n", -debugSampleSize - 1 );
+       }
+
        /* allocate vertex luxel storage */
        for ( k = 0; k < MAX_LIGHTMAPS; k++ )
        {
@@ -1966,7 +1988,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 +2107,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 +2131,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);
                                }
@@ -2151,6 +2173,10 @@ static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastLightmapSearch ){
                        /* allocate LIGHTMAP_RESERVE_COUNT new output lightmaps */
                        numOutLightmaps += LIGHTMAP_RESERVE_COUNT;
                        olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) );
+                       if ( !olm ){
+                               Error( "FindOutLightmaps: Failed to allocate memory.\n" );
+                       }
+
                        if ( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT ) {
                                memcpy( olm, outLightmaps, ( numOutLightmaps - LIGHTMAP_RESERVE_COUNT ) * sizeof( outLightmap_t ) );
                                free( outLightmaps );
@@ -2452,7 +2478,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 +3096,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 */