]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '93ca259313e7902e89974877f4110fc818e9208b' into garux-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 22 Feb 2021 21:56:53 +0000 (22:56 +0100)
committerThomas Debesse <dev@illwieckz.net>
Mon, 22 Feb 2021 21:56:53 +0000 (22:56 +0100)
tools/quake3/q3map2/help.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_trace.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/model.c
tools/quake3/q3map2/surface.c

index 104213b2724062f39389878b2e37dab4bcf83032..0558c0a0935cff1b70f34d3c5e3407e6585263cc 100644 (file)
@@ -195,7 +195,8 @@ void HelpLight()
                {"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"},
                {"-extrawide", "Deprecated alias for `-super 2 -filter`"},
                {"-extra", "Deprecated alias for `-super 2`"},
-               {"-fastallocate", "Use `-fastallocate` to trade lightmap size against allocation time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"},
+//             {"-fastallocate", "Use `-fastallocate` to trade lightmap size against allocation time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"},
+               {"-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm"},
                {"-fastbounce", "Use `-fast` style lighting for radiosity"},
                {"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"},
                {"-fastgrid", "Use `-fast` style lighting for the light grid"},
index 100bed593a748c7e0e2657ce235b08ab6eef5d7a..7d3be10e592df2b826ec280ea1f336f374ef0707 100644 (file)
@@ -2119,7 +2119,7 @@ int LightMain( int argc, char **argv ){
        const char  *value;
        int lightmapMergeSize = 0;
        qboolean lightSamplesInsist = qfalse;
-       qboolean fastAllocate = qfalse;
+       qboolean fastAllocate = qtrue;
 
        /* note it */
        Sys_Printf( "--- Light ---\n" );
@@ -2694,6 +2694,11 @@ int LightMain( int argc, char **argv ){
                        Sys_Printf( "Fast allocation mode enabled\n" );
                }
 
+               else if ( !strcmp( argv[ i ], "-slowallocate" ) ) {
+                       fastAllocate = qfalse;
+                       Sys_Printf( "Slow allocation mode enabled\n" );
+               }
+
                else if ( !strcmp( argv[ i ], "-fastgrid" ) ) {
                        fastgrid = qtrue;
                        Sys_Printf( "Fast grid lighting enabled\n" );
index f9afbf7833f779b7c3bc4e6ac8da2ff064220a2a..a8b8bb56d30edd46c2a36cddba444d47c12b11ee 100644 (file)
@@ -1629,10 +1629,10 @@ static qboolean TraceLine_r( int nodeNum, const vec3_t origin, const vec3_t end,
        traceNode_t     *node;
        int side;
        float front, back, frac;
-       vec3_t origin, mid;
-       qboolean r;
+       vec3_t mid;
 
 #if TRACELINE_R_HALF_ITERATIVE
+       vec3_t origin;
        VectorCopy( start, origin );
 
        while ( 1 )
index ea36b921f8bd6a41b75be713a64286de5ae7019c..6d61b8d7be998c8e83762df7d17b75935f233c6b 100644 (file)
@@ -2335,6 +2335,16 @@ static int CompareRawLightmap( const void *a, const void *b ){
        /* get min number of surfaces */
        min = ( alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces );
 
+//#define allocate_bigger_first
+#ifdef allocate_bigger_first
+       /* compare size, allocate bigger first */
+       // fastAllocate commit part: can kick fps by unique lightmap/shader combinations*=~2 + bigger compile time
+       //return -diff; makes packing faster and rough
+       diff = ( blm->w * blm->h ) - ( alm->w * alm->h );
+       if ( diff != 0 ) {
+               return diff;
+       }
+#endif
        /* iterate */
        for ( i = 0; i < min; i++ )
        {
@@ -2356,13 +2366,13 @@ static int CompareRawLightmap( const void *a, const void *b ){
        if ( diff ) {
                return diff;
        }
-
+#ifndef allocate_bigger_first
        /* compare size */
        diff = ( blm->w * blm->h ) - ( alm->w * alm->h );
        if ( diff != 0 ) {
                return diff;
        }
-
+#endif
        /* must be equivalent */
        return 0;
 }
@@ -2481,15 +2491,13 @@ void FillOutLightmap( outLightmap_t *olm ){
        }
 }
 
-
-
 /*
    StoreSurfaceLightmaps()
    stores the surface lightmaps into the bsp as byte rgb triplets
  */
 
 void StoreSurfaceLightmaps( qboolean fastAllocate ){
-       int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples;
+       int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples, timer_start;
        int style, size, lightmapNum, lightmapNum2;
        float               *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples;
        vec3_t sample, occludedSample, dirSample, colorMins, colorMaxs;
@@ -2532,6 +2540,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        /* note it */
        Sys_FPrintf( SYS_VRB, "Subsampling..." );
 
+       timer_start = I_FloatTime();
+
        /* walk the list of raw lightmaps */
        numUsed = 0;
        numTwins = 0;
@@ -2866,6 +2876,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           convert modelspace deluxemaps to tangentspace
           ----------------------------------------------------------------- */
@@ -2875,6 +2887,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                        vec3_t worldUp, myNormal, myTangent, myBinormal;
                        float dist;
 
+                       timer_start = I_FloatTime();
+
                        Sys_Printf( "converting..." );
 
                        for ( i = 0; i < numRawLightmaps; i++ )
@@ -2944,6 +2958,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                                        }
                                }
                        }
+
+                       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
                }
        }
 
@@ -3000,6 +3016,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                /* note it */
                Sys_FPrintf( SYS_VRB, "collapsing..." );
 
+               timer_start = I_FloatTime();
+
                /* set all twin refs to null */
                for ( i = 0; i < numRawLightmaps; i++ )
                {
@@ -3060,6 +3078,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                                }
                        }
                }
+
+               Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
        }
 
        /* -----------------------------------------------------------------
@@ -3069,6 +3089,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        /* note it */
        Sys_FPrintf( SYS_VRB, "sorting..." );
 
+       timer_start = I_FloatTime();
+
        /* allocate a new sorted list */
        if ( sortLightmaps == NULL ) {
                sortLightmaps = safe_malloc( numRawLightmaps * sizeof( int ) );
@@ -3079,6 +3101,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                sortLightmaps[ i ] = i;
        qsort( sortLightmaps, numRawLightmaps, sizeof( int ), CompareRawLightmap );
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           allocate output lightmaps
           ----------------------------------------------------------------- */
@@ -3086,6 +3110,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        /* note it */
        Sys_FPrintf( SYS_VRB, "allocating..." );
 
+       timer_start = I_FloatTime();
+
        /* kill all existing output lightmaps */
        if ( outLightmaps != NULL ) {
                for ( i = 0; i < numOutLightmaps; i++ )
@@ -3132,6 +3158,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           store output lightmaps
           ----------------------------------------------------------------- */
@@ -3139,6 +3167,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        /* note it */
        Sys_FPrintf( SYS_VRB, "storing..." );
 
+       timer_start = I_FloatTime();
+
        /* count the bsp lightmaps and allocate space */
        if ( bspLightBytes != NULL ) {
                free( bspLightBytes );
@@ -3223,6 +3253,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                remove( filename );
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           project the lightmaps onto the bsp surfaces
           ----------------------------------------------------------------- */
@@ -3230,6 +3262,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
        /* note it */
        Sys_FPrintf( SYS_VRB, "projecting..." );
 
+       timer_start = I_FloatTime();
+
        /* walk the list of surfaces */
        for ( i = 0; i < numBSPDrawSurfaces; i++ )
        {
@@ -3506,6 +3540,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* finish */
        Sys_FPrintf( SYS_VRB, "done.\n" );
 
index 6bbbe5c532c1b1b3d11b8413bd8ae648f6e502e1..2fd322dcbced12f6c906e409fdd6db98f0a5b956 100644 (file)
@@ -230,7 +230,8 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap
        char                *skinfilecontent;
        int skinfilesize;
        char                *skinfileptr, *skinfilenextptr;
-       int ok=0, notok=0, spf = ( spawnFlags & 8088 );
+       //int ok=0, notok=0;
+       int spf = ( spawnFlags & 8088 );
        float limDepth=0;
 
 
@@ -543,7 +544,7 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap
                        ( spf == 5632 ) ||      //EXTRUDE_DOWNWARDS+EXTRUDE_UPWARDS+AXIAL_BACKPLANE
                        ( spf == 3072 ) ||      //EXTRUDE_UPWARDS+MAX_EXTRUDE
                        ( spf == 5120 ) ){      //EXTRUDE_UPWARDS+AXIAL_BACKPLANE
-                       vec3_t points[ 4 ], backs[ 3 ], cnt, bestNormal, nrm, Vnorm[3], Enorm[3];
+                       vec3_t points[ 4 ], cnt, bestNormal, nrm, Vnorm[3], Enorm[3];
                        vec4_t plane, reverse, p[3];
                        double normalEpsilon_save;
                        qboolean snpd;
index 22e41cc5dbdfd8699b8df4eec1df878950dbb196..12063360c32f8272fc00782d9e35a193f4c4c48a 100644 (file)
@@ -2115,8 +2115,8 @@ int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurfac
 
 int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
        int i, refs = 0;
-       plane_t         *p1, *p2;
-       vec4_t plane1, plane2;
+       plane_t         *p1;
+       vec4_t plane1;
        winding_t       *fat, *front, *back;
        shaderInfo_t    *si;
 
@@ -2170,12 +2170,15 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
 
                /* check if surface is planar */
                if ( ds->planeNum >= 0 ) {
+                       #if 0
+                       plane_t *p2;
+                       vec4_t plane2;
+
                        /* get surface plane */
                        p2 = &mapplanes[ ds->planeNum ];
                        VectorCopy( p2->normal, plane2 );
                        plane2[ 3 ] = p2->dist;
 
-                       #if 0
                        /* div0: this is the plague (inaccurate) */
                        vec4_t reverse;
 
@@ -2191,7 +2194,6 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
                                return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
                        }
                        #else
-                       (void) plane2;
                        /* div0: this is the cholera (doesn't hit enough) */
 
                        /* the drawsurf might have an associated plane, if so, force a filter here */