From 8b11f8469132140a6ef8fd8d935443ce17c77209 Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 20 May 2009 17:48:32 +0000 Subject: [PATCH] only reserve ONE lightmap at once, not TWO (but make this a #define to allow later customization) git-svn-id: svn://svn.icculus.org/netradiant/trunk@367 61c419a2-8eb2-4b30-bcec-8cead039b335 --- tools/quake3/q3map2/lightmaps_ydnar.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index 35e81e54..e680fc0c 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -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 */ -- 2.39.2