@@ -77,11 +77,10 @@ vec_t g_lightprobeepsilon = DEFAULT_LIGHTPROBE_EPSILON;
7777int g_lightprobesamples = 256 ;
7878bool g_vertexblur = false ;
7979uint g_numstudiobounce = DEFAULT_STUDIO_BOUNCE;
80- int g_studiogipasscounter = 0 ;
81- vec3_t *g_studioskynormals;
82- int g_numstudioskynormals;
80+ int g_studiogipasscounter = 0 ;
8381bool g_noemissive = false ;
84- int g_skystyle = -1 ;
82+ int g_skystyle = -1 ;
83+ bool g_usingpatches = true ;
8584
8685
8786bool g_drawsample = false ;
@@ -1918,8 +1917,7 @@ static void SortPatches( void )
19181917 }
19191918 }
19201919
1921- // if we haven't patches we don't need bounces
1922- if ( g_num_patches <= 0 ) g_numbounce = 0 ;
1920+ if ( g_num_patches <= 0 ) g_usingpatches = false ;
19231921}
19241922
19251923/*
@@ -2516,8 +2514,6 @@ void RadWorld( void )
25162514 RunThreadsOnIndividual ( g_numfaces, true , FindFacePositions );
25172515 CalcPositionsSize ();
25182516
2519- if ( g_fastsky )
2520- MakeTransfers ();
25212517 if ( g_envsky )
25222518 LoadEnvSkyTextures ();
25232519
@@ -2529,7 +2525,7 @@ void RadWorld( void )
25292525#ifdef HLRAD_VERTEXLIGHTING
25302526 BuildVertexLights (); // BuildFaceLights will get single gi bounce from studiomodels
25312527
2532- if ( g_numstudiobounce > 0 || g_indirect_sun > 0 . 0f )
2528+ if ( g_numstudiobounce > 0 )
25332529 {
25342530 g_studiogipasscounter = 1 ;
25352531 VertexPatchLights ();
@@ -2546,11 +2542,10 @@ void RadWorld( void )
25462542
25472543 CalcLuxelsCount ();
25482544
2549- if ( g_numbounce > 0 )
2545+ if ( g_numbounce > 0 && g_usingpatches )
25502546 {
25512547 // build transfer lists
2552- if (!g_fastsky)
2553- MakeTransfers ();
2548+ MakeTransfers ();
25542549
25552550 emitlight = (vec3_t (*)[MAXLIGHTMAPS])Mem_Alloc (( g_num_patches + 1 ) * sizeof ( vec3_t [MAXLIGHTMAPS] ));
25562551 addlight = (vec3_t (*)[MAXLIGHTMAPS])Mem_Alloc (( g_num_patches + 1 ) * sizeof ( vec3_t [MAXLIGHTMAPS] ));
@@ -2574,10 +2569,9 @@ void RadWorld( void )
25742569 emitlight_dir = NULL ;
25752570 addlight_dir = NULL ;
25762571#endif
2577- }
2578-
2579- if ( g_fastsky ||( g_numbounce > 0 ))
2572+ // transfers don't need anymore
25802573 FreeTransfers ();
2574+ }
25812575
25822576 // remove direct light from patches
25832577 for ( int i = 0 ; i < g_num_patches; i++ )
@@ -2597,13 +2591,13 @@ void RadWorld( void )
25972591 ScaleDirectLights ();
25982592
25992593 // because fastmode uses patches instead of samples
2600- if ( g_numbounce > 0 || g_fastmode || g_indirect_sun > 0 . 0f )
2594+ if ( g_usingpatches )
26012595 RunThreadsOnIndividual ( g_numfaces, false , CreateTriangulations );
26022596
26032597 // blend bounced light into direct light and save
26042598 PrecompLightmapOffsets ();
26052599
2606- if ( g_numbounce > 0 || g_fastmode || g_indirect_sun > 0 . 0f )
2600+ if ( g_usingpatches )
26072601 {
26082602 CreateFacelightDependencyList ();
26092603
@@ -2612,7 +2606,7 @@ void RadWorld( void )
26122606 FreeFacelightDependencyList ();
26132607 }
26142608
2615- if ( g_numbounce > 0 || g_fastmode || g_indirect_sun > 0 . 0f )
2609+ if ( g_usingpatches )
26162610 FreeTriangulations ();
26172611
26182612 if ( g_lightbalance )
@@ -2626,7 +2620,7 @@ void RadWorld( void )
26262620
26272621#ifdef HLRAD_VERTEXLIGHTING
26282622 g_studiogipasscounter = 0 ;
2629- for ( int i = 0 ; i < g_numstudiobounce; i++ )
2623+ for ( int i = 0 ; i < Q_max ( 1 , g_numstudiobounce ) ; i++ )
26302624 {
26312625 g_studiogipasscounter++;
26322626 VertexPatchLights ();
@@ -3085,6 +3079,7 @@ int main( int argc, char **argv )
30853079
30863080 if ( g_skystyle < 0 )
30873081 g_skystyle = IntForKey ( &g_entities[0 ], " zhlt_skystyle" );
3082+ g_usingpatches = g_numbounce > 0 || g_fastmode || g_indirect_sun > 0 .0f ;
30883083
30893084 // keep it in acceptable range
30903085 g_blur = bound ( 1.0 , g_blur, 8.0 );
0 commit comments