Merge branch 'nobigfirst' into 'master'
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 7 Oct 2016 13:57:13 +0000 (13:57 +0000)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 7 Oct 2016 13:57:13 +0000 (13:57 +0000)
revert "allocate bigger first"

partial revert of d4fa608 ([L2313](https://gitlab.com/xonotic/netradiant/commit/8bc246a01343d9c9dd3a8b678681710cf04a2953#416ec0c19ddc04c6485e9853a0c8a125f98dca13_2295_2313))
see #54 ([13326399](https://gitlab.com/xonotic/netradiant/issues/54#note_13326399))

"allocate bigger first" change was meant to save allocation time keeping same lightmap file size, actually wastes both time and size

See merge request !32

tools/quake3/q3map2/lightmaps_ydnar.c

index 19791c4..462331f 100644 (file)
@@ -2310,12 +2310,6 @@ static int CompareRawLightmap( const void *a, const void *b ){
        /* get min number of surfaces */
        min = ( alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces );
 
-       /* compare size, allocate bigger first */
-       diff = ( blm->w * blm->h ) - ( alm->w * alm->h );
-       if ( diff != 0 ) {
-               return diff;
-       }
-
        /* iterate */
        for ( i = 0; i < min; i++ )
        {
@@ -2338,6 +2332,12 @@ static int CompareRawLightmap( const void *a, const void *b ){
                return diff;
        }
 
+       /* compare size */
+       diff = ( blm->w * blm->h ) - ( alm->w * alm->h );
+       if ( diff != 0 ) {
+               return diff;
+       }
+
        /* must be equivalent */
        return 0;
 }