remove Q_EXTERN int numLights

remove /* potential pre-setup  */ :
1. it seems to never actually be the case
2. it is called from threaded functions, while SetupEnvelopes() itself is not thread safe
This commit is contained in:
Garux 2021-08-03 18:26:47 +03:00
parent f49639c697
commit 357f67f237
4 changed files with 5 additions and 27 deletions

View File

@ -1854,13 +1854,14 @@ void LightWorld( bool fastAllocate ){
ambientColor.set( 0 );
floodlighty = false;
/* delete any existing lights, freeing up memory for the next bounce */
lights.clear();
/* generate diffuse lights */
RadFreeLights();
RadCreateDiffuseLights();
/* setup light envelopes */
SetupEnvelopes( false, fastbounce );
if ( numLights == 0 ) {
if ( lights.empty() ) {
Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
break;
}

View File

@ -32,20 +32,8 @@
#include "q3map2.h"
/* functions */
/*
RadFreeLights()
deletes any existing lights, freeing up memory for the next bounce
*/
void RadFreeLights( void ){
lights.clear();
numLights = 0;
}
/*
RadClipWindingEpsilon()

View File

@ -3339,7 +3339,6 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
Sys_FPrintf( SYS_VRB, "--- SetupEnvelopes%s ---\n", fastFlag ? " (fast)" : "" );
/* count lights */
numLights = 0;
numCulledLights = 0;
for( decltype( lights )::iterator light = lights.begin(); light != lights.end(); )
{
@ -3574,9 +3573,6 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
/* square envelope */
light->envelope2 = ( light->envelope * light->envelope );
/* increment light count */
numLights++;
/* set next light */
++light;
}
@ -3589,7 +3585,7 @@ void SetupEnvelopes( bool forGrid, bool fastFlag ){
}
/* emit some statistics */
Sys_Printf( "%9d total lights\n", numLights );
Sys_Printf( "%9zu total lights\n", lights.size() );
Sys_Printf( "%9d culled lights\n", numCulledLights );
}
@ -3605,16 +3601,11 @@ void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *normal, in
float length;
/* potential pre-setup */
if ( numLights == 0 ) {
SetupEnvelopes( false, fast );
}
/* debug code */
//% Sys_Printf( "CTWLFB: (%4.1f %4.1f %4.1f) (%4.1f %4.1f %4.1f)\n", minmax.mins[ 0 ], minmax.mins[ 1 ], minmax.mins[ 2 ], minmax.maxs[ 0 ], minmax.maxs[ 1 ], minmax.maxs[ 2 ] );
/* allocate the light list */
trace->lights = safe_malloc( sizeof( light_t* ) * ( numLights + 1 ) );
trace->lights = safe_malloc( sizeof( light_t* ) * ( lights.size() + 1 ) );
trace->numLights = 0;
/* calculate spherical bounds */

View File

@ -1795,7 +1795,6 @@ bool RadSampleImage( byte * pixels, int width, int height
void RadLightForTriangles( int num, int lightmapNum, rawLightmap_t *lm, shaderInfo_t *si, float scale, float subdivide, clipWork_t *cw );
void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, shaderInfo_t *si, float scale, float subdivide, clipWork_t *cw );
void RadCreateDiffuseLights( void );
void RadFreeLights();
/* light_ydnar.c */
@ -2355,7 +2354,6 @@ Q_EXTERN float subdivideThreshold Q_ASSIGN( DEFAULT_SUBDIVIDE_THRESHOLD );
Q_EXTERN int numOpaqueBrushes, maxOpaqueBrush;
Q_EXTERN byte *opaqueBrushes;
Q_EXTERN int numLights;
Q_EXTERN int numCulledLights;
Q_EXTERN int gridBoundsCulled;