Merge branch 'fix-fast' into 'master'
authorMario <zacjardine@y7mail.com>
Sun, 29 Apr 2018 13:46:46 +0000 (13:46 +0000)
committerMario <zacjardine@y7mail.com>
Sun, 29 Apr 2018 13:46:46 +0000 (13:46 +0000)
Fix a bug that prevent -fast to behave correctly

See merge request xonotic/netradiant!64

1  2 
tools/quake3/q3map2/light_ydnar.c

index a6def14219b139e5263b7f93768bc1b7abc736e0,3587797a991d04a3e111863c92c4c383988a576b..c75dac2e55f5705029df32059d2eec071a09031d
@@@ -1740,7 -1740,7 +1740,7 @@@ static qboolean SubmapRawLuxel( rawLigh
                origin2 = SUPER_ORIGIN( x, y );
                //%     normal2 = SUPER_NORMAL( x, y );
        }
 -      else{
 +      else {
                Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap S vector\n" );
        }
  
                origin2 = SUPER_ORIGIN( x, y );
                //%     normal2 = SUPER_NORMAL( x, y );
        }
 -      else{
 +      else {
                Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" );
        }
  
        VectorSubtract( origin2, origin, originVecs[ 1 ] );
 -      //%     VectorSubtract( normal2, normal, normalVecs[ 1 ] );
  
        /* calculate new origin */
 -      //%     VectorMA( origin, bx, originVecs[ 0 ], sampleOrigin );
 -      //%     VectorMA( sampleOrigin, by, originVecs[ 1 ], sampleOrigin );
        for ( i = 0; i < 3; i++ )
                sampleOrigin[ i ] = sampleOrigin[ i ] + ( bx * originVecs[ 0 ][ i ] ) + ( by * originVecs[ 1 ][ i ] );
  
        }
  
        /* calculate new normal */
 -      //%     VectorMA( normal, bx, normalVecs[ 0 ], sampleNormal );
 -      //%     VectorMA( sampleNormal, by, normalVecs[ 1 ], sampleNormal );
 -      //%     if( VectorNormalize( sampleNormal, sampleNormal ) <= 0.0f )
 -      //%             return qfalse;
        normal = SUPER_NORMAL( x, y );
        VectorCopy( normal, sampleNormal );
  
@@@ -2240,31 -2247,42 +2240,31 @@@ void IlluminateRawLightmap( int rawLigh
                                        normal = SUPER_NORMAL( x, y );
                                        flag = SUPER_FLAG( x, y );
  
 -#if 0
 -                                      ////////// 27's temp hack for testing edge clipping ////
 -                                      if ( origin[0] == 0 && origin[1] == 0 && origin[2] == 0 ) {
 -                                              lightLuxel[ 1 ] = 255;
 -                                              lightLuxel[ 3 ] = 1.0f;
 -                                              totalLighted++;
 -                                      }
 -                                      else
 -#endif
 -                                      {
 -                                              /* set contribution count */
 -                                              lightLuxel[ 3 ] = 1.0f;
 +                                      /* set contribution count */
 +                                      lightLuxel[ 3 ] = 1.0f;
  
 -                                              /* setup trace */
 -                                              trace.cluster = *cluster;
 -                                              VectorCopy( origin, trace.origin );
 -                                              VectorCopy( normal, trace.normal );
 +                                      /* setup trace */
 +                                      trace.cluster = *cluster;
 +                                      VectorCopy( origin, trace.origin );
 +                                      VectorCopy( normal, trace.normal );
  
 -                                              /* get light for this sample */
 -                                              LightContributionToSample( &trace );
 -                                              VectorCopy( trace.color, lightLuxel );
 +                                      /* get light for this sample */
 +                                      LightContributionToSample( &trace );
 +                                      VectorCopy( trace.color, lightLuxel );
  
 -                                              /* add the contribution to the deluxemap */
 -                                              if ( deluxemap ) {
 -                                                      VectorCopy( trace.directionContribution, lightDeluxel );
 -                                              }
 +                                      /* add the contribution to the deluxemap */
 +                                      if ( deluxemap ) {
 +                                              VectorCopy( trace.directionContribution, lightDeluxel );
 +                                      }
  
 -                                              /* check for evilness */
 -                                              if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) && luxelFilterRadius == 0 ) {
 -                                                      totalLighted++;
 -                                                      *flag |= FLAG_FORCE_SUBSAMPLING; /* force */
 -                                              }
 -                                              /* add to count */
 -                                              else if ( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] ) {
 +                                      /* check for evilness */
 +                                      if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) && luxelFilterRadius == 0 ) {
                                                        totalLighted++;
 -                                              }
 +                                              *flag |= FLAG_FORCE_SUBSAMPLING; /* force */
 +                                      }
 +                                      /* add to count */
 +                                      else if ( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] ) {
 +                                              totalLighted++;
                                        }
                                }
                        }
                                {
                                        /* get cluster */
                                        cluster = SUPER_CLUSTER( x, y );
 -                                      //%     if( *cluster < 0 ) // TODO why not do this check? These pixels should be zero anyway
 -                                      //%             continue;
  
                                        /* get particulars */
                                        luxel = SUPER_LUXEL( lightmapNum, x, y );
                        }
                }
        }
 -
 -
 -#if 0
 -      // audit pass
 -      for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
 -      {
 -              /* early out */
 -              if ( lm->superLuxels[ lightmapNum ] == NULL ) {
 -                      continue;
 -              }
 -              for ( y = 0; y < lm->sh; y++ )
 -                      for ( x = 0; x < lm->sw; x++ )
 -                      {
 -                              /* get cluster */
 -                              cluster = SUPER_CLUSTER( x, y );
 -                              luxel = SUPER_LUXEL( lightmapNum, x, y );
 -                              deluxel = SUPER_DELUXEL( x, y );
 -                              if ( !luxel || !deluxel || !cluster ) {
 -                                      Sys_FPrintf( SYS_VRB, "WARNING: I got NULL'd.\n" );
 -                                      continue;
 -                              }
 -                              else if ( *cluster < 0 ) {
 -                                      // unmapped pixel
 -                                      // should have neither deluxemap nor lightmap
 -                                      if ( deluxel[3] ) {
 -                                              Sys_FPrintf( SYS_VRB, "WARNING: I have written deluxe to an unmapped luxel. Sorry.\n" );
 -                                      }
 -                              }
 -                              else
 -                              {
 -                                      // mapped pixel
 -                                      // should have both deluxemap and lightmap
 -                                      if ( deluxel[3] ) {
 -                                              Sys_FPrintf( SYS_VRB, "WARNING: I forgot to write deluxe to a mapped luxel. Sorry.\n" );
 -                                      }
 -                              }
 -                      }
 -      }
 -#endif
  }
  
  
@@@ -3124,7 -3183,7 +3124,7 @@@ void IlluminateVertexes( int num )
     determines opaque brushes in the world and find sky shaders for sunlight calculations
   */
  
 -void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ){
 +void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all ){
        int i, j, b;
        unsigned int compileFlags, allCompileFlags;
        qboolean inside;
@@@ -3616,7 -3675,7 +3616,7 @@@ void SetupEnvelopes( qboolean forGrid, 
                                else{
                                        light->flags &= ~LIGHT_FAST_TEMP;
                                }
-                               if ( fastpoint && ( light->flags != EMIT_AREA ) ) {
+                               if ( fastpoint && ( light->type != EMIT_AREA ) ) {
                                        light->flags |= LIGHT_FAST_TEMP;
                                }
                                if ( light->si && light->si->noFast ) {