]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit 'aa4bc3893f6c0c360c91896eba46631e53b2f0d1' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 04:18:35 +0000 (06:18 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 04:18:35 +0000 (06:18 +0200)
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/q3map2.h
tools/quake3/q3map2/surface.c

index 60631e3d72f175a38c581b28a50df232ea8289ab..fe613d042936d168d0fe75255b46a242edb78a2d 100644 (file)
@@ -220,6 +220,7 @@ void HelpLight()
                {"-extrawide", "Deprecated alias for `-super 2 -filter`"},
                {"-extra", "Deprecated alias for `-super 2`"},
                {"-fastallocate",  "Trade lightmap size against packing 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 (default)"},
                {"-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"},
@@ -533,7 +534,7 @@ void HelpMain(const char* arg)
                                help_funcs[i]();
                                return;
                        }
-               }
+       }
        }
 
        HelpOptions("Stages", 0, terminalColumns, stages, sizeof(stages)/sizeof(struct HelpOption));
index f14cc43c843c4f8c8efdb30d632767832898ca82..20252c36a9d2b113efa943cf0f4d771722e38006 100644 (file)
@@ -1780,7 +1780,7 @@ void TraceGrid( int num ){
                         */
                        ColorToBytesNonZero(color, bgp->ambient[i], gridScale * gridAmbientScale);
                } else {
-                       ColorToBytes(color, bgp->ambient[i], gridScale * gridAmbientScale);
+               ColorToBytes( color, bgp->ambient[ i ], gridScale * gridAmbientScale );
                }
                ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
        }
@@ -2045,8 +2045,8 @@ void LightWorld( const char *BSPFilePath, qboolean fastAllocate, qboolean noBoun
                UnparseEntities();
 
                if ( storeForReal ) {
-                       Sys_Printf( "Writing %s\n", BSPFilePath );
-                       WriteBSPFile( BSPFilePath );
+               Sys_Printf( "Writing %s\n", BSPFilePath );
+               WriteBSPFile( BSPFilePath );
                }
 
                /* note it */
@@ -2153,7 +2153,7 @@ int LightMain( int argc, char **argv ){
        const char  *value;
        int lightmapMergeSize = 0;
        qboolean lightSamplesInsist = qfalse;
-       qboolean fastAllocate = qfalse;
+       qboolean fastAllocate = qtrue;
        qboolean noBounceStore = qfalse;
 
        /* note it */
@@ -2747,6 +2747,11 @@ int LightMain( int argc, char **argv ){
                        Sys_Printf( "Slow lightmap allocation mode enabled (default)\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 3c08c8b60d13c1223ba795bdf08a556121300bf1..2802ecaf4370c223b2d8c3e29ce6b8061154ca9d 100644 (file)
@@ -2325,6 +2325,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++ )
        {
@@ -2346,13 +2356,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;
 }
@@ -2471,15 +2481,13 @@ void FillOutLightmap( outLightmap_t *olm ){
        }
 }
 
-
-
 /*
    StoreSurfaceLightmaps()
    stores the surface lightmaps into the bsp as byte rgb triplets
  */
 
 void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
-       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;
@@ -2522,6 +2530,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
        /* note it */
        Sys_FPrintf( SYS_VRB, "Subsampling..." );
 
+       timer_start = I_FloatTime();
+
        /* walk the list of raw lightmaps */
        numUsed = 0;
        numTwins = 0;
@@ -2855,6 +2865,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           convert modelspace deluxemaps to tangentspace
           ----------------------------------------------------------------- */
@@ -2864,6 +2876,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                        vec3_t worldUp, myNormal, myTangent, myBinormal;
                        float dist;
 
+                       timer_start = I_FloatTime();
+
                        Sys_Printf( "converting..." );
 
                        for ( i = 0; i < numRawLightmaps; i++ )
@@ -2933,6 +2947,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                                        }
                                }
                        }
+
+                       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
                }
        }
 
@@ -2989,6 +3005,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                /* note it */
                Sys_FPrintf( SYS_VRB, "collapsing..." );
 
+               timer_start = I_FloatTime();
+
                /* set all twin refs to null */
                for ( i = 0; i < numRawLightmaps; i++ )
                {
@@ -3049,6 +3067,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                                }
                        }
                }
+
+               Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
        }
 
        /* -----------------------------------------------------------------
@@ -3058,6 +3078,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
        /* 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 ) );
@@ -3068,6 +3090,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                sortLightmaps[ i ] = i;
        qsort( sortLightmaps, numRawLightmaps, sizeof( int ), CompareRawLightmap );
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           allocate output lightmaps
           ----------------------------------------------------------------- */
@@ -3076,6 +3100,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                /* 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++ )
@@ -3123,6 +3149,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           store output lightmaps
           ----------------------------------------------------------------- */
@@ -3131,6 +3159,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                /* note it */
                Sys_FPrintf( SYS_VRB, "storing..." );
 
+       timer_start = I_FloatTime();
+
                /* count the bsp lightmaps and allocate space */
                if ( bspLightBytes != NULL ) {
                        free( bspLightBytes );
@@ -3215,6 +3245,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* -----------------------------------------------------------------
           project the lightmaps onto the bsp surfaces
           ----------------------------------------------------------------- */
@@ -3223,6 +3255,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                /* note it */
                Sys_FPrintf( SYS_VRB, "projecting..." );
 
+       timer_start = I_FloatTime();
+
                /* walk the list of surfaces */
                for ( i = 0; i < numBSPDrawSurfaces; i++ )
                {
@@ -3500,6 +3534,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
                }
        }
 
+       Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
        /* finish */
        Sys_FPrintf( SYS_VRB, "done.\n" );
 
index 17e690e7a1c67d1a97c1523f62685aaefb2d8095..b9760e2e39c0b3f23869cf40be5fe495dc436c7b 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;
 
 
@@ -541,7 +542,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 e644cc8be83d94971d63b1d0e6342cde8b5993cd..720dec29053fc042f0541d74295b7e0cc0d053cf 100644 (file)
@@ -1887,11 +1887,6 @@ void                        ExportEntities( void );
 int                         ExportEntitiesMain( int argc, char **argv );
 
 
-/* exportents.c */
-void                        ExportEntities( void );
-int                         ExportEntitiesMain( int argc, char **argv );
-
-
 /* image.c */
 void                        ImageFree( image_t *image );
 image_t                     *ImageFind( const char *filename );
index 77765fe4ed8a63243b9c71f3895f1544c27c8848..569fbf0811aaecbb71d5263002f49ba9a9b8e715 100644 (file)
@@ -2114,8 +2114,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;
 
@@ -2169,12 +2169,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;
 
@@ -2190,7 +2193,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 */