]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/lightmaps_ydnar.c
Merge commit '0709fce07d9c630ca0455ebeb58e3806427ca8ce' into garux-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / lightmaps_ydnar.c
index 83f0776d1104bc12f6fa7d512a74845fee978e08..ea36b921f8bd6a41b75be713a64286de5ae7019c 100644 (file)
@@ -35,7 +35,7 @@
 
 /* dependencies */
 #include "q3map2.h"
-
+#include <glib.h>
 
 
 
@@ -693,16 +693,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 */
@@ -890,7 +907,6 @@ static int CompareSurfaceInfo( const void *a, const void *b ){
                return -1;
        }
 
-
        /* then lightmap sample size */
        if ( aInfo->sampleSize < bInfo->sampleSize ) {
                return 1;
@@ -1092,7 +1108,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
@@ -1201,6 +1218,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++ )
        {
@@ -2162,6 +2183,10 @@ static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastAllocate ){
                        /* 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 );
@@ -2342,6 +2367,8 @@ static int CompareRawLightmap( const void *a, const void *b ){
        return 0;
 }
 
+
+
 void FillOutLightmap( outLightmap_t *olm ){
        int x, y;
        int ofs;
@@ -2454,6 +2481,8 @@ void FillOutLightmap( outLightmap_t *olm ){
        }
 }
 
+
+
 /*
    StoreSurfaceLightmaps()
    stores the surface lightmaps into the bsp as byte rgb triplets
@@ -2477,8 +2506,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        char dirname[ 1024 ], filename[ 1024 ];
        shaderInfo_t        *csi;
        char lightmapName[ 128 ];
-       const char              *rgbGenValues[ 256 ];
-       const char              *alphaGenValues[ 256 ];
+       const char          *rgbGenValues[ 256 ];
+       const char          *alphaGenValues[ 256 ];
 
 
        /* note it */
@@ -2501,7 +2530,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "Subsampling..." );
+       Sys_FPrintf( SYS_VRB, "Subsampling..." );
 
        /* walk the list of raw lightmaps */
        numUsed = 0;
@@ -2969,7 +2998,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
 
        if ( noCollapse == qfalse && deluxemap == qfalse ) {
                /* note it */
-               Sys_Printf( "collapsing..." );
+               Sys_FPrintf( SYS_VRB, "collapsing..." );
 
                /* set all twin refs to null */
                for ( i = 0; i < numRawLightmaps; i++ )
@@ -3038,7 +3067,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "sorting..." );
+       Sys_FPrintf( SYS_VRB, "sorting..." );
 
        /* allocate a new sorted list */
        if ( sortLightmaps == NULL ) {
@@ -3055,7 +3084,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "allocating..." );
+       Sys_FPrintf( SYS_VRB, "allocating..." );
 
        /* kill all existing output lightmaps */
        if ( outLightmaps != NULL ) {
@@ -3108,7 +3137,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "storing..." );
+       Sys_FPrintf( SYS_VRB, "storing..." );
 
        /* count the bsp lightmaps and allocate space */
        if ( bspLightBytes != NULL ) {
@@ -3178,7 +3207,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        }
 
        if ( numExtLightmaps > 0 ) {
-               Sys_Printf( "\n" );
+               Sys_FPrintf( SYS_VRB, "\n" );
        }
 
        /* delete unused external lightmaps */
@@ -3199,7 +3228,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "projecting..." );
+       Sys_FPrintf( SYS_VRB, "projecting..." );
 
        /* walk the list of surfaces */
        for ( i = 0; i < numBSPDrawSurfaces; i++ )
@@ -3478,7 +3507,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        }
 
        /* finish */
-       Sys_Printf( "done.\n" );
+       Sys_FPrintf( SYS_VRB, "done.\n" );
 
        /* calc num stored */
        numStored = numBSPLightBytes / 3;