diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 4bfbd1da..d2d0f9da 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -2774,9 +2774,10 @@ void IlluminateVertexes( int num ){ determines opaque brushes in the world and find sky shaders for sunlight calculations */ -void SetupBrushesFlags( int mask, int test ) +void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all ) { - int i, j, b, compileFlags; + int i, j, b; + unsigned int compileFlags, allCompileFlags; qboolean inside; bspBrush_t *brush; bspBrushSide_t *side; @@ -2806,6 +2807,7 @@ void SetupBrushesFlags( int mask, int test ) /* check all sides */ inside = qtrue; compileFlags = 0; + allCompileFlags = ~(0u); for ( j = 0; j < brush->numSides && inside; j++ ) { /* do bsp shader calculations */ @@ -2813,7 +2815,7 @@ void SetupBrushesFlags( int mask, int test ) shader = &bspShaders[ side->shaderNum ]; /* get shader info */ - si = ShaderInfoForShader( shader->shader ); + si = ShaderInfoForShaderNull( shader->shader ); if ( si == NULL ) { continue; } @@ -2823,7 +2825,7 @@ void SetupBrushesFlags( int mask, int test ) } /* determine if this brush is opaque to light */ - if( (compileFlags & mask) == test ) + if( (compileFlags & mask_any) == test_any && (allCompileFlags & mask_all) == test_all ) { opaqueBrushes[ b >> 3 ] |= (1 << (b & 7)); numOpaqueBrushes++; @@ -2836,7 +2838,7 @@ void SetupBrushesFlags( int mask, int test ) } void SetupBrushes( void ) { - SetupBrushesFlags(C_TRANSLUCENT, 0); + SetupBrushesFlags(C_TRANSLUCENT, 0, 0, 0); } diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index b1d5a547..6b85c3d2 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -389,7 +389,10 @@ determines solid non-sky brushes in the world void MiniMapSetupBrushes( void ) { - SetupBrushesFlags(C_SOLID | C_SKY, C_SOLID); + SetupBrushesFlags(C_SOLID | C_SKY, C_SOLID, C_NODRAW, 0); + // at least one must be solid + // none may be sky + // not all may be nodraw } qboolean MiniMapEvaluateSampleOffsets(int *bestj, int *bestk, float *bestval) @@ -744,20 +747,25 @@ int MiniMapBSPMain( int argc, char **argv ) if(v > ma) ma = v; } - s = 1 / (ma - mi); - o = mi / (ma - mi); + if(ma > mi) + { + s = 1 / (ma - mi); + o = mi / (ma - mi); - // equations: - // brightness + contrast * v - // after autolevel: - // brightness + contrast * (v * s - o) - // = - // (brightness - contrast * o) + (contrast * s) * v - minimap.brightness = minimap.brightness - minimap.contrast * o; - minimap.contrast *= s; + // equations: + // brightness + contrast * v + // after autolevel: + // brightness + contrast * (v * s - o) + // = + // (brightness - contrast * o) + (contrast * s) * v + minimap.brightness = minimap.brightness - minimap.contrast * o; + minimap.contrast *= s; - Sys_Printf( "Auto level: Brightness changed to %f\n", minimap.brightness ); - Sys_Printf( "Auto level: Contrast changed to %f\n", minimap.contrast ); + Sys_Printf( "Auto level: Brightness changed to %f\n", minimap.brightness ); + Sys_Printf( "Auto level: Contrast changed to %f\n", minimap.contrast ); + } + else + Sys_Printf( "Auto level: failed because all pixels are the same value\n" ); } if(minimap.brightness != 0 || minimap.contrast != 1) diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 08e9b1c8..ffb056ab 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1764,7 +1764,7 @@ void DirtyRawLightmap( int num ); void IlluminateRawLightmap( int num ); void IlluminateVertexes( int num ); -void SetupBrushesFlags( int mask, int test ); +void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ); void SetupBrushes( void ); void SetupClusters( void ); qboolean ClusterVisible( int a, int b ); @@ -1820,6 +1820,7 @@ void EmitVertexRemapShader( char *from, char *to ); void LoadShaderInfo( void ); shaderInfo_t *ShaderInfoForShader( const char *shader ); +shaderInfo_t *ShaderInfoForShaderNull( const char *shader ); /* bspfile_abstract.c */ diff --git a/tools/quake3/q3map2/shaders.c b/tools/quake3/q3map2/shaders.c index 153f3daa..dfbc7f19 100644 --- a/tools/quake3/q3map2/shaders.c +++ b/tools/quake3/q3map2/shaders.c @@ -801,6 +801,12 @@ static void LoadShaderImages( shaderInfo_t *si ){ finds a shaderinfo for a named shader */ +shaderInfo_t *ShaderInfoForShaderNull( const char *shaderName ){ + if(!strcmp(shaderName, "noshader")) + return NULL; + return ShaderInfoForShader(shaderName); +} + shaderInfo_t *ShaderInfoForShader( const char *shaderName ){ int i; shaderInfo_t *si;