shorten code

This commit is contained in:
Garux 2019-07-25 19:23:13 +03:00
parent 635c732e72
commit 070161fd13
3 changed files with 8 additions and 27 deletions

View File

@ -80,6 +80,7 @@ extern const vec3_t g_vec3_axis_z;
#define VectorNegate( a,b ) ( ( b )[0] = -( a )[0],( b )[1] = -( a )[1],( b )[2] = -( a )[2] )
#define CrossProduct( a,b,c ) ( ( c )[0] = ( a )[1] * ( b )[2] - ( a )[2] * ( b )[1],( c )[1] = ( a )[2] * ( b )[0] - ( a )[0] * ( b )[2],( c )[2] = ( a )[0] * ( b )[1] - ( a )[1] * ( b )[0] )
#define VectorClear( x ) ( ( x )[0] = ( x )[1] = ( x )[2] = 0 )
#define VectorMax( x ) ( ( ( x )[0] > ( x )[1] ) ? ( ( ( x )[0] > ( x )[2] ) ? ( x )[0] : ( x )[2] ) : ( ( ( x )[1] > ( x )[2] ) ? ( x )[1] : ( x )[2] ) )
#define FLOAT_SNAP( f,snap ) ( (float)( floor( ( f ) / ( snap ) + 0.5 ) * ( snap ) ) )
#define FLOAT_TO_INTEGER( f ) ( (float)( floor( ( f ) + 0.5 ) ) )

View File

@ -2426,13 +2426,7 @@ int LightMain( int argc, char **argv ){
/* Lighting contrast */
else if( !strcmp( argv[ i ], "-contrast" ) ){
f = atof( argv[ i + 1 ] );
lightmapContrast = f;
if( lightmapContrast > 255 ){
lightmapContrast = 255;
}
else if( lightmapContrast < -255 ){
lightmapContrast = -255;
}
lightmapContrast = f > 255? 255 : f < -255? -255 : f;
Sys_Printf( "Lighting contrast set to %f\n", lightmapContrast );
i++;
/* change to factor in range of 0 to 129.5 */

View File

@ -77,13 +77,7 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
if ( lightmapExposure == 0 ) {
/* clamp with color normalization */
max = sample[ 0 ];
if ( sample[ 1 ] > max ) {
max = sample[ 1 ];
}
if ( sample[ 2 ] > max ) {
max = sample[ 2 ];
}
max = VectorMax( sample );
if ( max > 255.0f ) {
VectorScale( sample, ( 255.0f / max ), sample );
}
@ -93,13 +87,7 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
inv = 1.f / lightmapExposure;
//Exposure
max = sample[ 0 ];
if ( sample[ 1 ] > max ) {
max = sample[ 1 ];
}
if ( sample[ 2 ] > max ) {
max = sample[ 2 ];
}
max = VectorMax( sample );
dif = ( 1 - exp( -max * inv ) ) * 255;
@ -129,12 +117,10 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
sample[i] = 0;
}
}
if ( ( sample[0] > 255 ) || ( sample[1] > 255 ) || ( sample[2] > 255 ) ) {
max = sample[0] > sample[1] ? sample[0] : sample[1];
max = max > sample[2] ? max : sample[2];
sample[0] = sample[0] * 255 / max;
sample[1] = sample[1] * 255 / max;
sample[2] = sample[2] * 255 / max;
/* clamp with color normalization */
max = VectorMax( sample );
if ( max > 255.0f ) {
VectorScale( sample, ( 255.0f / max ), sample );
}
}