]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/light_ydnar.c
some warning fixes
[xonotic/netradiant.git] / tools / quake3 / q3map2 / light_ydnar.c
index d1a5ca75ae989fecd73101e00002705a3262eaff..f291e7a5871da5303bceeb9bb8fc688f1401026a 100644 (file)
@@ -1154,13 +1154,18 @@ void MapRawLightmap( int rawLightmapNum )
                                                if( MapQuad( lm, info, dv ) )
                                                        continue;
                                                
-                                               /* get drawverts and map first triangle */
-                                               MapTriangle( lm, info, dv, mapNonAxial );
-                                               
-                                               /* get drawverts and map second triangle */
-                                               dv[ 1 ] = &verts[ pw[ r + 2 ] ];
-                                               dv[ 2 ] = &verts[ pw[ r + 3 ] ];
-                                               MapTriangle( lm, info, dv, mapNonAxial );
+                                               for( mapNonAxial = 0; mapNonAxial < 2; mapNonAxial++ )
+                                               {
+                                                       /* get drawverts and map first triangle */
+                                                       dv[ 1 ] = &verts[ pw[ r + 1 ] ];
+                                                       dv[ 2 ] = &verts[ pw[ r + 2 ] ];
+                                                       MapTriangle( lm, info, dv, mapNonAxial );
+                                                       
+                                                       /* get drawverts and map second triangle */
+                                                       dv[ 1 ] = &verts[ pw[ r + 2 ] ];
+                                                       dv[ 2 ] = &verts[ pw[ r + 3 ] ];
+                                                       MapTriangle( lm, info, dv, mapNonAxial );
+                                               }
                                        }
                                }
                                
@@ -1471,7 +1476,7 @@ float DirtForSample( trace_t *trace )
                        
                        /* trace */
                        TraceLine( trace );
-                       if( trace->opaque )
+                       if( trace->opaque && !(trace->compileFlags & C_SKY) )
                        {
                                VectorSubtract( trace->hit, trace->origin, displacement );
                                gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
@@ -1562,8 +1567,8 @@ void DirtyRawLightmap( int rawLightmapNum )
        trace.recvShadows = lm->recvShadows;
        trace.numSurfaces = lm->numLightSurfaces;
        trace.surfaces = &lightSurfaces[ lm->firstLightSurface ];
-       trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
-       trace.testAll = qtrue;
+       trace.inhibitRadius = 0.0f;
+       trace.testAll = qfalse;
        
        /* twosided lighting (may or may not be a good idea for lightmapped stuff) */
        trace.twoSided = qfalse;
@@ -1714,7 +1719,9 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
                //%     normal2 = SUPER_NORMAL( x, y );
        }
        else
-               Sys_Printf( "WARNING: Spurious lightmap S vector\n" );
+       {
+               Error( "Spurious lightmap S vector\n" );
+       }
        
        VectorSubtract( origin2, origin, originVecs[ 0 ] );
        //%     VectorSubtract( normal2, normal, normalVecs[ 0 ] );
@@ -1781,7 +1788,7 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl
        vec3_t          deluxel[ 3 ];
        vec3_t          origin[ 4 ], normal[ 4 ];
        float           biasDirs[ 4 ][ 2 ] = { { -1.0f, -1.0f }, { 1.0f, -1.0f }, { -1.0f, 1.0f }, { 1.0f, 1.0f } };
-       vec3_t          color, direction, total;
+       vec3_t          color, direction = { 0, 0, 0 }, total;
        
        
        /* limit check */
@@ -1854,7 +1861,10 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl
        //%     VectorClear( color );
        //%     samples = 0;
        VectorCopy( lightLuxel, color );
-       VectorCopy( lightDeluxel, direction );
+       if(lightDeluxel)
+       {
+               VectorCopy( lightDeluxel, direction );
+       }
        samples = 1;
        for( b = 0; b < 4; b++ )
        {
@@ -1919,10 +1929,6 @@ static void RandomSubsampleRawLuxel( rawLightmap_t *lm, trace_t *trace, vec3_t s
                /* set origin */
                VectorCopy( sampleOrigin, origin );
                GaussLikeRandom(bias, &dx, &dy);
-               if(dx > 1) dx = 1;
-               if(dy > 1) dy = 1;
-               if(dx < -1) dx = -1;
-               if(dy < -1) dy = -1;
 
                /* calculate position */
                if( !SubmapRawLuxel( lm, x, y, dx, dy, &cluster, origin, normal ) )
@@ -1974,8 +1980,9 @@ illuminates the luxels
 
 void IlluminateRawLightmap( int rawLightmapNum )
 {
-       int                                     i, t, x, y, sx, sy, size, llSize, ldSize, luxelFilterRadius, lightmapNum;
+       int                                     i, t, x, y, sx, sy, size, luxelFilterRadius, lightmapNum;
        int                                     *cluster, *cluster2, mapped, lighted, totalLighted;
+       size_t                                  llSize, ldSize;
        rawLightmap_t           *lm;
        surfaceInfo_t           *info;
        qboolean                        filterColor, filterDir;
@@ -2339,7 +2346,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                                                
                                                                /* subsample it */
                                                                if(lightRandomSamples)
-                                                                       RandomSubsampleRawLuxel( lm, &trace, origin, sx, sy, 0.5f, lightLuxel, deluxemap ? lightDeluxel : NULL );
+                                                                       RandomSubsampleRawLuxel( lm, &trace, origin, sx, sy, 0.5f * lightSamplesSearchBoxSize, lightLuxel, deluxemap ? lightDeluxel : NULL );
                                                                else
                                                                        SubsampleRawLuxel_r( lm, &trace, origin, sx, sy, 0.25f * lightSamplesSearchBoxSize, lightLuxel, deluxemap ? lightDeluxel : NULL );
 
@@ -2870,16 +2877,16 @@ void IlluminateVertexes( int num )
                                        radVertLuxel[ 2 ] <= ambientColor[ 2 ] )
                                {
                                        /* nudge the sample point around a bit */
-                                       for( x = 0; x < 4; x++ )
+                                       for( x = 0; x < 5; x++ )
                                        {
                                                /* two's complement 0, 1, -1, 2, -2, etc */
                                                x1 = ((x >> 1) ^ (x & 1 ? -1 : 0)) + (x & 1);
                                                
-                                               for( y = 0; y < 4; y++ )
+                                               for( y = 0; y < 5; y++ )
                                                {
                                                        y1 = ((y >> 1) ^ (y & 1 ? -1 : 0)) + (y & 1);
                                                        
-                                                       for( z = 0; z < 4; z++ )
+                                                       for( z = 0; z < 5; z++ )
                                                        {
                                                                z1 = ((z >> 1) ^ (z & 1 ? -1 : 0)) + (z & 1);
                                                                
@@ -2892,6 +2899,21 @@ void IlluminateVertexes( int num )
                                                                trace.cluster = ClusterForPointExtFilter( origin, VERTEX_EPSILON, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ] );
                                                                if( trace.cluster < 0 )
                                                                        continue;
+
+                                                               /* r7 dirt */
+                                                               if( dirty && !bouncing )
+                                                                       dirt = DirtForSample( &trace );
+                                                               else
+                                                                       dirt = 1.0f;
+
+                                                               /* jal: floodlight */
+                                                               floodLightAmount = 0.0f;
+                                                               VectorClear( floodColor );
+                                                               if( floodlighty && !bouncing )
+                                                               {
+                                                                       floodLightAmount = floodlightIntensity * FloodLightForSample( &trace, floodlightDistance, floodlight_lowquality );
+                                                                       VectorScale( floodlightRGB, floodLightAmount, floodColor );
+                                                               }
                                                                                                                        
                                                                /* trace */
                                                                LightingAtSample( &trace, ds->vertexStyles, colors );
@@ -3182,7 +3204,7 @@ determines if two clusters are visible to each other using the PVS
 
 qboolean ClusterVisible( int a, int b )
 {
-       int                     portalClusters, leafBytes;
+       int                     leafBytes;
        byte            *pvs;
        
        
@@ -3199,7 +3221,7 @@ qboolean ClusterVisible( int a, int b )
                return qtrue;
        
        /* get pvs data */
-       portalClusters = ((int *) bspVisBytes)[ 0 ];
+       /* portalClusters = ((int *) bspVisBytes)[ 0 ]; */
        leafBytes = ((int*) bspVisBytes)[ 1 ];
        pvs = bspVisBytes + VIS_HEADER_SIZE + (a * leafBytes);
        
@@ -3503,7 +3525,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag )
        int                     i, x, y, z, x1, y1, z1;
        light_t         *light, *light2, **owner;
        bspLeaf_t       *leaf;
-       vec3_t          origin, dir, mins, maxs, nullVector = { 0, 0, 0 };
+       vec3_t          origin, dir, mins, maxs;
        float           radius, intensity;
        light_t         *buckets[ 256 ];
        
@@ -3616,6 +3638,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag )
                                        /* check for fast mode */
                                        if( !(light->flags & LIGHT_FAST) && !(light->flags & LIGHT_FAST_TEMP) )
                                                light->envelope = MAX_WORLD_COORD * 8.0f;
+                                       intensity = light->photons; /* hopefully not used */
                                }
                                else
                                {
@@ -3993,7 +4016,7 @@ void SetupFloodLight( void )
        int             i, j;
        float   angle, elevation, angleStep, elevationStep;
        const char      *value;
-       double v1,v2,v3,v4,v5;
+       double v1,v2,v3,v4,v5,v6;
 
        /* note it */
        Sys_FPrintf( SYS_VRB, "--- SetupFloodLight ---\n" );
@@ -4027,8 +4050,9 @@ void SetupFloodLight( void )
                v1=v2=v3=0;
                v4=floodlightDistance;
                v5=floodlightIntensity;
+               v6=floodlightDirectionScale;
 
-               sscanf( value, "%lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5);
+               sscanf( value, "%lf %lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5, &v6);
 
                floodlightRGB[0]=v1;
                floodlightRGB[1]=v2;
@@ -4041,9 +4065,11 @@ void SetupFloodLight( void )
 
                if (v4<1) v4=1024;
                if (v5<1) v5=128;
+               if (v6<0) v6=1;
 
                floodlightDistance=v4;
                floodlightIntensity=v5;
+               floodlightDirectionScale=v6;
 
                floodlighty = qtrue;
                Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
@@ -4138,7 +4164,7 @@ float FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean f
                        TraceLine( trace );
                        contribution=1;
 
-                       if (trace->compileFlags & C_SKY )
+                       if ( trace->compileFlags & C_SKY || trace->compileFlags & C_TRANSLUCENT )
                        {
                                contribution=1.0f;
                        }
@@ -4322,7 +4348,7 @@ void FloodLightRawLightmap( int rawLightmapNum )
 
        /* global pass */
        if (floodlighty && floodlightIntensity)
-               FloodLightRawLightmapPass(lm, floodlightRGB, floodlightIntensity, floodlightDistance, floodlight_lowquality, 1.0f);
+               FloodLightRawLightmapPass(lm, floodlightRGB, floodlightIntensity, floodlightDistance, floodlight_lowquality, floodlightDirectionScale);
 
        /* custom pass */
        if (lm->floodlightIntensity)