]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
only reserve ONE lightmap at once, not TWO (but make this a #define to allow later...
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 20 May 2009 17:48:32 +0000 (17:48 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 20 May 2009 17:48:32 +0000 (17:48 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@367 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/q3map2/lightmaps_ydnar.c

index 35e81e54192dea03b6828976dfd7a7c63276b0f1..e680fc0ce98d2c9b96472f306d63c0cfff8681cb 100644 (file)
@@ -1918,9 +1918,10 @@ FindOutLightmaps()
 for a given surface lightmap, find output lightmap pages and positions for it
 */
 
+#define LIGHTMAP_RESERVE_COUNT 1
 static void FindOutLightmaps( rawLightmap_t *lm )
 {
-       int                                     i, j, lightmapNum, xMax, yMax, x, y, sx, sy, ox, oy, offset, temp;
+       int                                     i, j, k, lightmapNum, xMax, yMax, x, y, sx, sy, ox, oy, offset, temp;
        outLightmap_t           *olm;
        surfaceInfo_t           *info;
        float                           *luxel, *deluxel;
@@ -2015,7 +2016,7 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                        y = 0;
                        
                        /* walk the list of lightmap pages */
-                       for( i = noLightmapSearch ? numOutLightmaps - 2 : 0; i < numOutLightmaps; i++ )
+                       for( i = noLightmapSearch ? numOutLightmaps - LIGHTMAP_RESERVE_COUNT : 0; i < numOutLightmaps; i++ )
                        {
                                /* get the output lightmap */
                                olm = &outLightmaps[ i ];
@@ -2069,10 +2070,10 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                /* no match? */
                if( ok == qfalse )
                {
-                       /* allocate two new output lightmaps */
-                       numOutLightmaps += 2;
+                       /* allocate LIGHTMAP_RESERVE_COUNT new output lightmaps */
+                       numOutLightmaps += LIGHTMAP_RESERVE_COUNT;
                        olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) );
-                       if( outLightmaps != NULL && numOutLightmaps > 2 )
+                       if( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT )
                        {
                                memcpy( olm, outLightmaps, (numOutLightmaps - 2) * sizeof( outLightmap_t ) );
                                free( outLightmaps );
@@ -2080,11 +2081,11 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                        outLightmaps = olm;
                        
                        /* initialize both out lightmaps */
-                       SetupOutLightmap( lm, &outLightmaps[ numOutLightmaps - 2 ] );
-                       SetupOutLightmap( lm, &outLightmaps[ numOutLightmaps - 1 ] );
+                       for(k = numOutLightmaps - LIGHTMAP_RESERVE_COUNT; k < numOutLightmaps; ++k)
+                               SetupOutLightmap( lm, &outLightmaps[ k ] );
                        
                        /* set out lightmap */
-                       i = numOutLightmaps - 2;
+                       i = numOutLightmaps - LIGHTMAP_RESERVE_COUNT;
                        olm = &outLightmaps[ i ];
                        
                        /* set stamp xy origin to the first surface lightmap */