std::vector<std::uint8_t> opaqueBrushes

This commit is contained in:
Garux 2021-09-24 17:35:58 +03:00
parent 260dc59d4a
commit 9f63742fda
3 changed files with 8 additions and 13 deletions

View File

@ -2944,14 +2944,9 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all )
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "--- SetupBrushes ---\n" ); Sys_FPrintf( SYS_VRB, "--- SetupBrushes ---\n" );
/* allocate */
if ( opaqueBrushes == NULL ) {
opaqueBrushes = safe_malloc( bspBrushes.size() / 8 + 1 );
}
/* clear */ /* clear */
memset( opaqueBrushes, 0, bspBrushes.size() / 8 + 1 ); opaqueBrushes = decltype( opaqueBrushes )( bspBrushes.size(), false );
numOpaqueBrushes = 0; int numOpaqueBrushes = 0;
/* walk the list of worldspawn brushes */ /* walk the list of worldspawn brushes */
for ( int i = 0; i < bspModels[ 0 ].numBSPBrushes; i++ ) for ( int i = 0; i < bspModels[ 0 ].numBSPBrushes; i++ )
@ -2981,7 +2976,7 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all )
/* determine if this brush is opaque to light */ /* determine if this brush is opaque to light */
if ( ( compileFlags & mask_any ) == test_any && ( allCompileFlags & mask_all ) == test_all ) { if ( ( compileFlags & mask_any ) == test_any && ( allCompileFlags & mask_all ) == test_all ) {
opaqueBrushes[ b >> 3 ] |= ( 1 << ( b & 7 ) ); opaqueBrushes[ b ] = true;
numOpaqueBrushes++; numOpaqueBrushes++;
maxOpaqueBrush = i; maxOpaqueBrush = i;
} }
@ -3152,11 +3147,11 @@ int ClusterForPointExt( const Vector3& point, float epsilon ){
if ( b > maxOpaqueBrush ) { if ( b > maxOpaqueBrush ) {
continue; continue;
} }
const bspBrush_t& brush = bspBrushes[ b ]; if ( !opaqueBrushes[ b ] ) {
if ( !( opaqueBrushes[ b >> 3 ] & ( 1 << ( b & 7 ) ) ) ) {
continue; continue;
} }
const bspBrush_t& brush = bspBrushes[ b ];
/* check point against all planes */ /* check point against all planes */
bool inside = true; bool inside = true;
for ( int j = 0; j < brush.numSides && inside; j++ ) for ( int j = 0; j < brush.numSides && inside; j++ )

View File

@ -107,7 +107,7 @@ static float MiniMapSample( float x, float y ){
for ( int i = 0; i < minimap.model->numBSPBrushes; ++i ) for ( int i = 0; i < minimap.model->numBSPBrushes; ++i )
{ {
const int bi = minimap.model->firstBSPBrush + i; const int bi = minimap.model->firstBSPBrush + i;
if ( opaqueBrushes[bi >> 3] & ( 1 << ( bi & 7 ) ) ) { if ( opaqueBrushes[bi] ) {
const bspBrush_t& b = bspBrushes[bi]; const bspBrush_t& b = bspBrushes[bi];
// sort out mins/maxs of the brush // sort out mins/maxs of the brush

View File

@ -2244,8 +2244,8 @@ Q_EXTERN float maxLight Q_ASSIGN( 255.f );
/* ydnar: light optimization */ /* ydnar: light optimization */
Q_EXTERN float subdivideThreshold Q_ASSIGN( DEFAULT_SUBDIVIDE_THRESHOLD ); Q_EXTERN float subdivideThreshold Q_ASSIGN( DEFAULT_SUBDIVIDE_THRESHOLD );
Q_EXTERN int numOpaqueBrushes, maxOpaqueBrush; Q_EXTERN int maxOpaqueBrush;
Q_EXTERN byte *opaqueBrushes; Q_EXTERN std::vector<std::uint8_t> opaqueBrushes;
Q_EXTERN int numCulledLights; Q_EXTERN int numCulledLights;