From 9f63742fdafc74315b3a7710a6bb6ee900a2bf7c Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 24 Sep 2021 17:35:58 +0300 Subject: [PATCH] std::vector opaqueBrushes --- tools/quake3/q3map2/light_ydnar.cpp | 15 +++++---------- tools/quake3/q3map2/minimap.cpp | 2 +- tools/quake3/q3map2/q3map2.h | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tools/quake3/q3map2/light_ydnar.cpp b/tools/quake3/q3map2/light_ydnar.cpp index b51f6df1..b179f45f 100644 --- a/tools/quake3/q3map2/light_ydnar.cpp +++ b/tools/quake3/q3map2/light_ydnar.cpp @@ -2944,14 +2944,9 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ) /* note it */ Sys_FPrintf( SYS_VRB, "--- SetupBrushes ---\n" ); - /* allocate */ - if ( opaqueBrushes == NULL ) { - opaqueBrushes = safe_malloc( bspBrushes.size() / 8 + 1 ); - } - /* clear */ - memset( opaqueBrushes, 0, bspBrushes.size() / 8 + 1 ); - numOpaqueBrushes = 0; + opaqueBrushes = decltype( opaqueBrushes )( bspBrushes.size(), false ); + int numOpaqueBrushes = 0; /* walk the list of worldspawn brushes */ 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 */ if ( ( compileFlags & mask_any ) == test_any && ( allCompileFlags & mask_all ) == test_all ) { - opaqueBrushes[ b >> 3 ] |= ( 1 << ( b & 7 ) ); + opaqueBrushes[ b ] = true; numOpaqueBrushes++; maxOpaqueBrush = i; } @@ -3152,11 +3147,11 @@ int ClusterForPointExt( const Vector3& point, float epsilon ){ if ( b > maxOpaqueBrush ) { continue; } - const bspBrush_t& brush = bspBrushes[ b ]; - if ( !( opaqueBrushes[ b >> 3 ] & ( 1 << ( b & 7 ) ) ) ) { + if ( !opaqueBrushes[ b ] ) { continue; } + const bspBrush_t& brush = bspBrushes[ b ]; /* check point against all planes */ bool inside = true; for ( int j = 0; j < brush.numSides && inside; j++ ) diff --git a/tools/quake3/q3map2/minimap.cpp b/tools/quake3/q3map2/minimap.cpp index ff9f6a1f..c86affb1 100644 --- a/tools/quake3/q3map2/minimap.cpp +++ b/tools/quake3/q3map2/minimap.cpp @@ -107,7 +107,7 @@ static float MiniMapSample( float x, float y ){ for ( int i = 0; i < minimap.model->numBSPBrushes; ++i ) { const int bi = minimap.model->firstBSPBrush + i; - if ( opaqueBrushes[bi >> 3] & ( 1 << ( bi & 7 ) ) ) { + if ( opaqueBrushes[bi] ) { const bspBrush_t& b = bspBrushes[bi]; // sort out mins/maxs of the brush diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index ee876423..8f09db5f 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -2244,8 +2244,8 @@ Q_EXTERN float maxLight Q_ASSIGN( 255.f ); /* ydnar: light optimization */ Q_EXTERN float subdivideThreshold Q_ASSIGN( DEFAULT_SUBDIVIDE_THRESHOLD ); -Q_EXTERN int numOpaqueBrushes, maxOpaqueBrush; -Q_EXTERN byte *opaqueBrushes; +Q_EXTERN int maxOpaqueBrush; +Q_EXTERN std::vector opaqueBrushes; Q_EXTERN int numCulledLights;