shorten code
This commit is contained in:
parent
635c732e72
commit
070161fd13
|
|
@ -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 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 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 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_SNAP( f,snap ) ( (float)( floor( ( f ) / ( snap ) + 0.5 ) * ( snap ) ) )
|
||||||
#define FLOAT_TO_INTEGER( f ) ( (float)( floor( ( f ) + 0.5 ) ) )
|
#define FLOAT_TO_INTEGER( f ) ( (float)( floor( ( f ) + 0.5 ) ) )
|
||||||
|
|
|
||||||
|
|
@ -2426,13 +2426,7 @@ int LightMain( int argc, char **argv ){
|
||||||
/* Lighting contrast */
|
/* Lighting contrast */
|
||||||
else if( !strcmp( argv[ i ], "-contrast" ) ){
|
else if( !strcmp( argv[ i ], "-contrast" ) ){
|
||||||
f = atof( argv[ i + 1 ] );
|
f = atof( argv[ i + 1 ] );
|
||||||
lightmapContrast = f;
|
lightmapContrast = f > 255? 255 : f < -255? -255 : f;
|
||||||
if( lightmapContrast > 255 ){
|
|
||||||
lightmapContrast = 255;
|
|
||||||
}
|
|
||||||
else if( lightmapContrast < -255 ){
|
|
||||||
lightmapContrast = -255;
|
|
||||||
}
|
|
||||||
Sys_Printf( "Lighting contrast set to %f\n", lightmapContrast );
|
Sys_Printf( "Lighting contrast set to %f\n", lightmapContrast );
|
||||||
i++;
|
i++;
|
||||||
/* change to factor in range of 0 to 129.5 */
|
/* change to factor in range of 0 to 129.5 */
|
||||||
|
|
|
||||||
|
|
@ -77,13 +77,7 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
|
||||||
|
|
||||||
if ( lightmapExposure == 0 ) {
|
if ( lightmapExposure == 0 ) {
|
||||||
/* clamp with color normalization */
|
/* clamp with color normalization */
|
||||||
max = sample[ 0 ];
|
max = VectorMax( sample );
|
||||||
if ( sample[ 1 ] > max ) {
|
|
||||||
max = sample[ 1 ];
|
|
||||||
}
|
|
||||||
if ( sample[ 2 ] > max ) {
|
|
||||||
max = sample[ 2 ];
|
|
||||||
}
|
|
||||||
if ( max > 255.0f ) {
|
if ( max > 255.0f ) {
|
||||||
VectorScale( sample, ( 255.0f / max ), sample );
|
VectorScale( sample, ( 255.0f / max ), sample );
|
||||||
}
|
}
|
||||||
|
|
@ -93,13 +87,7 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
|
||||||
inv = 1.f / lightmapExposure;
|
inv = 1.f / lightmapExposure;
|
||||||
//Exposure
|
//Exposure
|
||||||
|
|
||||||
max = sample[ 0 ];
|
max = VectorMax( sample );
|
||||||
if ( sample[ 1 ] > max ) {
|
|
||||||
max = sample[ 1 ];
|
|
||||||
}
|
|
||||||
if ( sample[ 2 ] > max ) {
|
|
||||||
max = sample[ 2 ];
|
|
||||||
}
|
|
||||||
|
|
||||||
dif = ( 1 - exp( -max * inv ) ) * 255;
|
dif = ( 1 - exp( -max * inv ) ) * 255;
|
||||||
|
|
||||||
|
|
@ -129,12 +117,10 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
|
||||||
sample[i] = 0;
|
sample[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ( sample[0] > 255 ) || ( sample[1] > 255 ) || ( sample[2] > 255 ) ) {
|
/* clamp with color normalization */
|
||||||
max = sample[0] > sample[1] ? sample[0] : sample[1];
|
max = VectorMax( sample );
|
||||||
max = max > sample[2] ? max : sample[2];
|
if ( max > 255.0f ) {
|
||||||
sample[0] = sample[0] * 255 / max;
|
VectorScale( sample, ( 255.0f / max ), sample );
|
||||||
sample[1] = sample[1] * 255 / max;
|
|
||||||
sample[2] = sample[2] * 255 / max;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user