Renderers: make sure that R_ColorShiftLightingBytes() is not picking more data that we actually need/have
Fixed some compiler warnings
This commit is contained in:
parent
5a67e8538f
commit
2e411ecfb1
|
@ -96,7 +96,7 @@ static void HSVtoRGB( float h, float s, float v, float rgb[3] )
|
|||
R_ColorShiftLightingBytes
|
||||
===============
|
||||
*/
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4] ) {
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4], qboolean hasAlpha ) {
|
||||
int shift, r, g, b;
|
||||
|
||||
// shift the color data based on overbright range
|
||||
|
@ -137,7 +137,9 @@ void R_ColorShiftLightingBytes( const byte in[4], byte out[4] ) {
|
|||
out[1] = g;
|
||||
out[2] = b;
|
||||
}
|
||||
out[3] = in[3];
|
||||
if ( hasAlpha ) {
|
||||
out[3] = in[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,7 +257,9 @@ static float R_ProcessLightmap( byte *image, const byte *buf_p, float maxIntensi
|
|||
if ( r_mergeLightmaps->integer ) {
|
||||
for ( y = 0 ; y < LIGHTMAP_SIZE; y++ ) {
|
||||
for ( x = 0 ; x < LIGHTMAP_SIZE; x++ ) {
|
||||
R_ColorShiftLightingBytes( buf_p, &image[ ((y + LIGHTMAP_BORDER) * LIGHTMAP_LEN + x + LIGHTMAP_BORDER) * 4 ] );
|
||||
byte *dst = &image[((y + LIGHTMAP_BORDER) * LIGHTMAP_LEN + x + LIGHTMAP_BORDER) * 4];
|
||||
R_ColorShiftLightingBytes( buf_p, dst, qfalse );
|
||||
dst[3] = 255;
|
||||
buf_p += 3;
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +268,9 @@ static float R_ProcessLightmap( byte *image, const byte *buf_p, float maxIntensi
|
|||
// legacy path
|
||||
for ( y = 0 ; y < LIGHTMAP_SIZE; y++ ) {
|
||||
for ( x = 0 ; x < LIGHTMAP_SIZE; x++ ) {
|
||||
R_ColorShiftLightingBytes( buf_p, &image[ (y * LIGHTMAP_SIZE + x) * 4 ] );
|
||||
byte *dst = &image[(y * LIGHTMAP_SIZE + x) * 4];
|
||||
R_ColorShiftLightingBytes( buf_p, dst, qfalse );
|
||||
dst[3] = 255;
|
||||
buf_p += 3;
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +630,7 @@ static void ParseFace( const dsurface_t *ds, const drawVert_t *verts, msurface_t
|
|||
cv->points[i][3+j] = LittleFloat( verts[i].st[j] );
|
||||
cv->points[i][5+j] = LittleFloat( verts[i].lightmap[j] );
|
||||
}
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, (byte *)&cv->points[i][7] );
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, (byte *)&cv->points[i][7], qtrue );
|
||||
if ( lightmapNum >= 0 && r_mergeLightmaps->integer ) {
|
||||
// adjust lightmap coords
|
||||
cv->points[i][5] = cv->points[i][5] * tr.lightmapScale[0] + lightmapX;
|
||||
|
@ -723,7 +729,7 @@ static void ParseMesh( const dsurface_t *ds, const drawVert_t *verts, msurface_t
|
|||
points[i].st[j] = LittleFloat( verts[i].st[j] );
|
||||
points[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );
|
||||
}
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, points[i].color.rgba );
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, points[i].color.rgba, qtrue );
|
||||
if ( lightmapNum >= 0 && r_mergeLightmaps->integer ) {
|
||||
// adjust lightmap coords
|
||||
points[i].lightmap[0] = points[i].lightmap[0] * tr.lightmapScale[0] + lightmapX;
|
||||
|
@ -807,7 +813,7 @@ static void ParseTriSurf( const dsurface_t *ds, const drawVert_t *verts, msurfac
|
|||
tri->verts[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );
|
||||
}
|
||||
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, tri->verts[i].color.rgba );
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, tri->verts[i].color.rgba, qtrue );
|
||||
if ( lightmapNum >= 0 && r_mergeLightmaps->integer ) {
|
||||
// adjust lightmap coords
|
||||
tri->verts[i].lightmap[0] = tri->verts[i].lightmap[0] * tr.lightmapScale[0] + lightmapX;
|
||||
|
@ -2060,8 +2066,8 @@ static void R_LoadLightGrid( const lump_t *l ) {
|
|||
|
||||
// deal with overbright bits
|
||||
for ( i = 0 ; i < numGridPoints ; i++ ) {
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] );
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] );
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8], qfalse );
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3], qfalse );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -643,7 +643,7 @@ static void Upload32( byte *data, int x, int y, int width, int height, image_t *
|
|||
byte *p = data;
|
||||
int i, n = width * height;
|
||||
for ( i = 0; i < n; i++, p+=4 ) {
|
||||
R_ColorShiftLightingBytes( p, p );
|
||||
R_ColorShiftLightingBytes( p, p, qfalse );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1661,7 +1661,7 @@ static void R_Register( void )
|
|||
" 4 - linear filtering, preserve aspect ratio (black bars on sides)\n" );
|
||||
}
|
||||
|
||||
#define EPSILON 1e-6
|
||||
#define EPSILON 1e-6f
|
||||
|
||||
/*
|
||||
===============
|
||||
|
|
|
@ -1408,7 +1408,7 @@ void R_Init( void );
|
|||
|
||||
void R_SetColorMappings( void );
|
||||
void R_GammaCorrect( byte *buffer, int bufSize );
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4] );
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4], qboolean hasAlpha );
|
||||
|
||||
void R_ImageList_f( void );
|
||||
void R_SkinList_f( void );
|
||||
|
|
|
@ -2829,11 +2829,11 @@ static shader_t *FinishShader( void ) {
|
|||
for ( n = 0; n < 2; n++ ) {
|
||||
for ( m = 0; m < stages[i].bundle[n].numTexMods; m++ ) {
|
||||
if ( stages[i].bundle[n].texMods[m].type == TMOD_STRETCH ) {
|
||||
if ( fabsf( stages[i].bundle[n].texMods[m].wave.amplitude ) < 1e-6 ) {
|
||||
if ( fabsf( stages[i].bundle[n].texMods[m].wave.amplitude ) < 1e-6f ) {
|
||||
if ( stages[i].bundle[n].texMods[m].wave.amplitude >= 0.0f ) {
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = 1e-6;
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = 1e-6f;
|
||||
} else {
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = -1e-6;
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = -1e-6f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ static void HSVtoRGB( float h, float s, float v, float rgb[3] )
|
|||
R_ColorShiftLightingBytes
|
||||
===============
|
||||
*/
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4] ) {
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4], qboolean hasAlpha ) {
|
||||
int shift, r, g, b;
|
||||
|
||||
// shift the color data based on overbright range
|
||||
|
@ -140,7 +140,10 @@ void R_ColorShiftLightingBytes( const byte in[4], byte out[4] ) {
|
|||
out[1] = g;
|
||||
out[2] = b;
|
||||
}
|
||||
out[3] = in[3];
|
||||
|
||||
if ( hasAlpha ) {
|
||||
out[3] = in[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -258,7 +261,9 @@ static float R_ProcessLightmap( byte *image, const byte *buf_p, float maxIntensi
|
|||
if ( r_mergeLightmaps->integer ) {
|
||||
for ( y = 0 ; y < LIGHTMAP_SIZE; y++ ) {
|
||||
for ( x = 0 ; x < LIGHTMAP_SIZE; x++ ) {
|
||||
R_ColorShiftLightingBytes( buf_p, &image[ ((y + LIGHTMAP_BORDER) * LIGHTMAP_LEN + x + LIGHTMAP_BORDER) * 4 ] );
|
||||
byte *dst = &image[((y + LIGHTMAP_BORDER) * LIGHTMAP_LEN + x + LIGHTMAP_BORDER) * 4];
|
||||
R_ColorShiftLightingBytes( buf_p, dst, qfalse );
|
||||
dst[3] = 255;
|
||||
buf_p += 3;
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +272,9 @@ static float R_ProcessLightmap( byte *image, const byte *buf_p, float maxIntensi
|
|||
// legacy path
|
||||
for ( y = 0 ; y < LIGHTMAP_SIZE; y++ ) {
|
||||
for ( x = 0 ; x < LIGHTMAP_SIZE; x++ ) {
|
||||
R_ColorShiftLightingBytes( buf_p, &image[ (y * LIGHTMAP_SIZE + x) * 4 ] );
|
||||
byte *dst = &image[(y * LIGHTMAP_SIZE + x) * 4];
|
||||
R_ColorShiftLightingBytes( buf_p, dst, qfalse );
|
||||
dst[3] = 255;
|
||||
buf_p += 3;
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +670,7 @@ static void ParseFace( const dsurface_t *ds, const drawVert_t *verts, msurface_t
|
|||
cv->points[i][3+j] = LittleFloat( verts[i].st[j] );
|
||||
cv->points[i][5+j] = LittleFloat( verts[i].lightmap[j] );
|
||||
}
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, (byte *)&cv->points[i][7] );
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, (byte *)&cv->points[i][7], qtrue );
|
||||
if ( lightmapNum >= 0 && r_mergeLightmaps->integer ) {
|
||||
// adjust lightmap coords
|
||||
cv->points[i][5] = cv->points[i][5] * tr.lightmapScale[0] + lightmapX;
|
||||
|
@ -774,7 +781,7 @@ static void ParseMesh( const dsurface_t *ds, const drawVert_t *verts, msurface_t
|
|||
points[i].st[j] = LittleFloat( verts[i].st[j] );
|
||||
points[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );
|
||||
}
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, points[i].color.rgba );
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, points[i].color.rgba, qtrue );
|
||||
if ( lightmapNum >= 0 && r_mergeLightmaps->integer ) {
|
||||
// adjust lightmap coords
|
||||
points[i].lightmap[0] = points[i].lightmap[0] * tr.lightmapScale[0] + lightmapX;
|
||||
|
@ -858,7 +865,7 @@ static void ParseTriSurf( const dsurface_t *ds, const drawVert_t *verts, msurfac
|
|||
tri->verts[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );
|
||||
}
|
||||
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, tri->verts[i].color.rgba );
|
||||
R_ColorShiftLightingBytes( verts[i].color.rgba, tri->verts[i].color.rgba, qtrue );
|
||||
if ( lightmapNum >= 0 && r_mergeLightmaps->integer ) {
|
||||
// adjust lightmap coords
|
||||
tri->verts[i].lightmap[0] = tri->verts[i].lightmap[0] * tr.lightmapScale[0] + lightmapX;
|
||||
|
@ -2111,8 +2118,8 @@ static void R_LoadLightGrid( const lump_t *l ) {
|
|||
|
||||
// deal with overbright bits
|
||||
for ( i = 0 ; i < numGridPoints ; i++ ) {
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] );
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] );
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8], qfalse );
|
||||
R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3], qfalse );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -643,7 +643,7 @@ static void generate_image_upload_data( image_t *image, byte *data, Image_Upload
|
|||
byte *p = data;
|
||||
int i, n = width * height;
|
||||
for ( i = 0; i < n; i++, p+=4 ) {
|
||||
R_ColorShiftLightingBytes( p, p );
|
||||
R_ColorShiftLightingBytes( p, p, qfalse );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1708,7 +1708,7 @@ static void R_Register( void )
|
|||
#endif // USE_VULKAN
|
||||
}
|
||||
|
||||
#define EPSILON 1e-6
|
||||
#define EPSILON 1e-6f
|
||||
|
||||
/*
|
||||
===============
|
||||
|
|
|
@ -1497,7 +1497,7 @@ void R_Init( void );
|
|||
|
||||
void R_SetColorMappings( void );
|
||||
void R_GammaCorrect( byte *buffer, int bufSize );
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4] );
|
||||
void R_ColorShiftLightingBytes( const byte in[4], byte out[4], qboolean hasAlpha );
|
||||
|
||||
void R_ImageList_f( void );
|
||||
void R_SkinList_f( void );
|
||||
|
|
|
@ -3273,11 +3273,11 @@ static shader_t *FinishShader( void ) {
|
|||
for ( n = 0; n < stages[i].numTexBundles; n++ ) {
|
||||
for ( m = 0; m < stages[i].bundle[n].numTexMods; m++ ) {
|
||||
if ( stages[i].bundle[n].texMods[m].type == TMOD_STRETCH ) {
|
||||
if ( fabsf( stages[i].bundle[n].texMods[m].wave.amplitude ) < 1e-6 ) {
|
||||
if ( fabsf( stages[i].bundle[n].texMods[m].wave.amplitude ) < 1e-6f ) {
|
||||
if ( stages[i].bundle[n].texMods[m].wave.amplitude >= 0.0f ) {
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = 1e-6;
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = 1e-6f;
|
||||
} else {
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = -1e-6;
|
||||
stages[i].bundle[n].texMods[m].wave.amplitude = -1e-6f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue