diff --git a/Makefile.OpenArena b/Makefile.OpenArena index 5ad6b15f..bbc72a6c 100644 --- a/Makefile.OpenArena +++ b/Makefile.OpenArena @@ -49,6 +49,8 @@ GLSL_TEXTURES =1 # for shaders on models, leifxdither, etc GLSL_BACKEND =1 # for the entire backend. +#Possible values "gnu90", "gnu99" and "gnu11". Note that the engine uses gnu-extensions. gnu90 is broken in the commit where this message is added. Travis does not support gnu11 at the moment. +CFLAGS+="-std=gnu99" # You can change these although you probably don't need to diff --git a/code/client/snd_codec_xmp.c b/code/client/snd_codec_xmp.c index e88b66bd..89db2292 100644 --- a/code/client/snd_codec_xmp.c +++ b/code/client/snd_codec_xmp.c @@ -35,7 +35,7 @@ int xmpspeed = 22050; // assume 22050hz unless........ -// leilei - XMP +// leilei - XMP xmp_context xmpsong; //int sound_init(int, int); void sound_play(void *, int); @@ -46,13 +46,15 @@ void sound_deinit(void); extern int samplingrate; // from snd_dma -void S_XMP_StartSong ( void ){ - +void S_XMP_StartSong ( void ) +{ + } -void S_XMP_EndSong ( void ){ +void S_XMP_EndSong ( void ) +{ @@ -80,68 +82,61 @@ S_XMP_CodecOpenStream // FIXME: there's a memory leak here if you start the same song many many many many times. snd_stream_t *S_XMP_CodecOpenStream(const char *filename) { - snd_stream_t *rv; - // First let's close whatever song we had.... // Open - rv = S_CodecUtilOpen(filename, &xmp_codec); - if(!rv) + snd_stream_t *rv = S_CodecUtilOpen(filename, &xmp_codec); + if(!rv) { return NULL; + } // Com_Printf("OPENSTREAM %s\n", filename); - + { - fileHandle_t file; - void *buffer; + fileHandle_t file; - // Try to open the file - FS_FOpenFileRead(filename, &file, qtrue); - if(!file) - { - Com_Printf( S_COLOR_RED "ERROR: No.\"%s\"\n",filename); - return NULL; - } + // Try to open the file + FS_FOpenFileRead(filename, &file, qtrue); + if(!file) { + Com_Printf( S_COLOR_RED "ERROR: No.\"%s\"\n",filename); + return NULL; + } - // Allocate some memory - long thelength = FS_ReadFile(filename, buffer); + // Allocate some memory + long thelength = FS_ReadFile(filename, NULL); - buffer = Hunk_AllocateTempMemory(thelength); - if(!buffer) - { - FS_FCloseFile(file); - Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n", - filename); - return NULL; - } + void *buffer = Hunk_AllocateTempMemory(thelength); + if(!buffer) { + FS_FCloseFile(file); + Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n", filename); + return NULL; + } - FS_Read(buffer, thelength, file); + FS_Read(buffer, thelength, file); - // OK! - struct xmp_module_info mi; + // OK! + struct xmp_module_info mi; - xmpsong = xmp_create_context(); - int itsloaded = 0; + xmpsong = xmp_create_context(); + int itsloaded = 0; - itsloaded = xmp_load_module_from_memory(xmpsong, buffer, 0); + itsloaded = xmp_load_module_from_memory(xmpsong, buffer, 0); - // Free our memory and close the file. - Hunk_FreeTempMemory(buffer); - FS_FCloseFile(file); // unfortunately these do not help with the leak + // Free our memory and close the file. + Hunk_FreeTempMemory(buffer); + FS_FCloseFile(file); // unfortunately these do not help with the leak - if (itsloaded == 0) - itsloaded = xmp_start_player(xmpsong, xmpspeed, 0); // TODO: do sample rate of the mixer. - - if (itsloaded == 0){ - - // Com_Printf("XMP loaded our buffer of the file %s which is %i long \n", filename, thelength); - xmp_get_module_info(xmpsong, &mi); - // Com_Printf("Song Name: %s\n", mi.mod->name); - // Com_Printf("CODECLOAD %s\n", filename); - + if (itsloaded == 0) + itsloaded = xmp_start_player(xmpsong, xmpspeed, 0); // TODO: do sample rate of the mixer. + + if (itsloaded == 0) { + // Com_Printf("XMP loaded our buffer of the file %s which is %i long \n", filename, thelength); + xmp_get_module_info(xmpsong, &mi); + // Com_Printf("Song Name: %s\n", mi.mod->name); + // Com_Printf("CODECLOAD %s\n", filename); } } @@ -183,64 +178,30 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer) struct xmp_module_info mi; struct xmp_frame_info fi; - int bytesRead, bytesLeft, c; - char *bufPtr; - // check if input is valid - if(!(stream && buffer)) - { + if(!(stream && buffer)) { return 0; } - if(bytes <= 0) - { + if(bytes <= 0) { return 0; } - bytesRead = 0; - bytesLeft = bytes; - bufPtr = buffer; + int yeah=xmp_play_buffer(xmpsong, buffer, bytes, 0); - // cycle until we have the requested or all available bytes read - while(-1) - { - int yeah=xmp_play_buffer(xmpsong, buffer, bytesLeft, 0); - - if (yeah == 0){ // if we can play it... + if (yeah == 0) { // if we can play it... xmp_get_frame_info(xmpsong, &fi); - - c = fi.buffer; - - // no more bytes are left - if(c <= 0) - { - break; - } - - bytesRead += c; - bytesLeft -= c; - bufPtr += c; - xmp_get_module_info(xmpsong, &mi); - - // we have enough bytes - if(bytesLeft <= 0) - { - break; - } - } - else // if we can't play it JUST STOP OK - { - break; - - } + xmp_get_module_info(xmpsong, &mi); + } + else { + return 0; } return bytes; } -snd_codec_t xmp_codec = -{ +snd_codec_t xmp_codec = { "umx", S_XMP_CodecLoad, S_XMP_CodecOpenStream, @@ -249,8 +210,7 @@ snd_codec_t xmp_codec = NULL }; -snd_codec_t xmp_mod_codec = -{ +snd_codec_t xmp_mod_codec = { "mod", S_XMP_CodecLoad, S_XMP_CodecOpenStream, @@ -259,8 +219,7 @@ snd_codec_t xmp_mod_codec = NULL }; -snd_codec_t xmp_it_codec = -{ +snd_codec_t xmp_it_codec = { "it", S_XMP_CodecLoad, S_XMP_CodecOpenStream, @@ -269,8 +228,7 @@ snd_codec_t xmp_it_codec = NULL }; -snd_codec_t xmp_s3m_codec = -{ +snd_codec_t xmp_s3m_codec = { "s3m", S_XMP_CodecLoad, S_XMP_CodecOpenStream, @@ -279,8 +237,7 @@ snd_codec_t xmp_s3m_codec = NULL }; -snd_codec_t xmp_xm_codec = -{ +snd_codec_t xmp_xm_codec = { "xm", S_XMP_CodecLoad, S_XMP_CodecOpenStream, diff --git a/code/renderer_oa/tr_bloom.c b/code/renderer_oa/tr_bloom.c index 06d818e7..3e00af48 100644 --- a/code/renderer_oa/tr_bloom.c +++ b/code/renderer_oa/tr_bloom.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // tr_bloom.c: General post-processing shader stuff including bloom, leifx, and everything else -// that's postprocessed. Maintained by leilei and Hitchiker +// that's postprocessed. Maintained by leilei and Hitchiker #include "tr_local.h" @@ -68,7 +68,7 @@ static struct { int width, height; } work; - // leilei - motion blur + // leilei - motion blur struct { image_t *texture; int width, height; @@ -136,7 +136,7 @@ static struct { cvar_t *r_film; -extern int force32upload; +extern int force32upload; int leifxmode; int leifxpass; int fakeit = 0; @@ -148,16 +148,15 @@ extern int tvHeight; extern float tvAspectW; // aspect correction extern int vresWidth; extern int vresHeight; -/* -============================================================================== - - LIGHT BLOOMS - -============================================================================== -*/ +/* +============================================================================== -static float Diamond8x[8][8] = -{ + LIGHT BLOOMS + +============================================================================== +*/ + +static float Diamond8x[8][8] = { { 0.0f, 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f, }, { 0.0f, 0.0f, 0.2f, 0.3f, 0.3f, 0.2f, 0.0f, 0.0f, }, { 0.0f, 0.2f, 0.4f, 0.6f, 0.6f, 0.4f, 0.2f, 0.0f, }, @@ -169,8 +168,7 @@ static float Diamond8x[8][8] = }; -static float Star8x[8][8] = -{ +static float Star8x[8][8] = { { 0.4f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.4f, }, { 0.1f, 0.6f, 0.2f, 0.0f, 0.0f, 0.2f, 0.6f, 0.1f, }, { 0.0f, 0.2f, 0.7f, 0.6f, 0.6f, 0.7f, 0.2f, 0.0f, }, @@ -182,18 +180,16 @@ static float Star8x[8][8] = }; -static float Diamond6x[6][6] = -{ +static float Diamond6x[6][6] = { { 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, }, - { 0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f, }, + { 0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f, }, { 0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f, }, { 0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f, }, { 0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f, }, { 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f } }; -static float Diamond4x[4][4] = -{ +static float Diamond4x[4][4] = { { 0.3f, 0.4f, 0.4f, 0.3f, }, { 0.4f, 0.9f, 0.9f, 0.4f, }, { 0.4f, 0.9f, 0.9f, 0.4f, }, @@ -224,29 +220,30 @@ static struct { -static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) { +static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) +{ int x = 0; int y = 0; x = 0; y += glConfig.vidHeight - height; width += x; height += y; - + texWidth += texX; texHeight += texY; - qglBegin( GL_QUADS ); - qglTexCoord2f( texX, texHeight ); + qglBegin( GL_QUADS ); + qglTexCoord2f( texX, texHeight ); qglVertex2f( x, y ); - qglTexCoord2f( texX, texY ); - qglVertex2f( x, height ); + qglTexCoord2f( texX, texY ); + qglVertex2f( x, height ); - qglTexCoord2f( texWidth, texY ); - qglVertex2f( width, height ); + qglTexCoord2f( texWidth, texY ); + qglVertex2f( width, height ); - qglTexCoord2f( texWidth, texHeight ); - qglVertex2f( width, y ); + qglTexCoord2f( texWidth, texHeight ); + qglVertex2f( width, y ); qglEnd (); } @@ -254,7 +251,8 @@ static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float tex // LEILEI - Bloom Reflection -static void ID_INLINE R_Bloom_Quad_Lens(float offsert, int width, int height, float texX, float texY, float texWidth, float texHeight) { +static void ID_INLINE R_Bloom_Quad_Lens(float offsert, int width, int height, float texX, float texY, float texWidth, float texHeight) +{ int x = 0; int y = 0; x = 0; @@ -265,18 +263,18 @@ static void ID_INLINE R_Bloom_Quad_Lens(float offsert, int width, int height, fl texWidth -= texX; texHeight -= texY; - qglBegin( GL_QUADS ); - qglTexCoord2f( texX, texHeight ); + qglBegin( GL_QUADS ); + qglTexCoord2f( texX, texHeight ); qglVertex2f( width + offsert, height + offsert ); - qglTexCoord2f( texX, texY ); - qglVertex2f( width + offsert, y - offsert); + qglTexCoord2f( texX, texY ); + qglVertex2f( width + offsert, y - offsert); - qglTexCoord2f( texWidth, texY ); - qglVertex2f( x - offsert, y - offsert); + qglTexCoord2f( texWidth, texY ); + qglVertex2f( x - offsert, y - offsert); - qglTexCoord2f( texWidth, texHeight ); - qglVertex2f( x - offsert, height + offsert); + qglTexCoord2f( texWidth, texHeight ); + qglVertex2f( x - offsert, height + offsert); qglEnd (); } @@ -292,37 +290,37 @@ static void R_Bloom_InitTextures( void ) { byte *data; - // find closer power of 2 to screen size - for (bloom.screen.width = 1;bloom.screen.width< glConfig.vidWidth;bloom.screen.width *= 2); - for (bloom.screen.height = 1;bloom.screen.height < glConfig.vidHeight;bloom.screen.height *= 2); + // find closer power of 2 to screen size + for (bloom.screen.width = 1; bloom.screen.width< glConfig.vidWidth; bloom.screen.width *= 2); + for (bloom.screen.height = 1; bloom.screen.height < glConfig.vidHeight; bloom.screen.height *= 2); bloom.screen.readW = glConfig.vidWidth / (float)bloom.screen.width; bloom.screen.readH = glConfig.vidHeight / (float)bloom.screen.height; - // find closer power of 2 to effect size + // find closer power of 2 to effect size bloom.work.width = r_bloom_sample_size->integer; bloom.work.height = bloom.work.width * ( glConfig.vidWidth / glConfig.vidHeight ); - for (bloom.effect.width = 1;bloom.effect.width < bloom.work.width;bloom.effect.width *= 2); - for (bloom.effect.height = 1;bloom.effect.height < bloom.work.height;bloom.effect.height *= 2); + for (bloom.effect.width = 1; bloom.effect.width < bloom.work.width; bloom.effect.width *= 2); + for (bloom.effect.height = 1; bloom.effect.height < bloom.work.height; bloom.effect.height *= 2); bloom.effect.readW = bloom.work.width / (float)bloom.effect.width; bloom.effect.readH = bloom.work.height / (float)bloom.effect.height; - + bloom.effect2.readW=bloom.effect.readW; bloom.effect2.readH=bloom.effect.readH; bloom.effect2.width=bloom.effect.width; bloom.effect2.height=bloom.effect.height; - + // disable blooms if we can't handle a texture of that size if( bloom.screen.width > glConfig.maxTextureSize || - bloom.screen.height > glConfig.maxTextureSize || - bloom.effect.width > glConfig.maxTextureSize || - bloom.effect.height > glConfig.maxTextureSize || - bloom.work.width > glConfig.vidWidth || - bloom.work.height > glConfig.vidHeight - ) { + bloom.screen.height > glConfig.maxTextureSize || + bloom.effect.width > glConfig.maxTextureSize || + bloom.effect.height > glConfig.maxTextureSize || + bloom.work.width > glConfig.vidWidth || + bloom.work.height > glConfig.vidHeight + ) { ri.Cvar_Set( "r_bloom", "0" ); Com_Printf( S_COLOR_YELLOW"WARNING: 'R_InitBloomTextures' too high resolution for light bloom, effect disabled\n" ); return; @@ -369,7 +367,7 @@ static void R_Bloom_DrawEffect( void ) float alpha=r_bloom_alpha->value; GL_Bind( bloom.effect.texture ); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - if(r_bloom_cascade->integer){ + if(r_bloom_cascade->integer) { alpha=r_bloom_cascade_alpha->value; } qglColor4f( alpha,alpha,alpha, 1.0f ); @@ -433,7 +431,8 @@ static void R_Bloom_LensEffect( void ) ================= Tcpp: sorry for my poor English skill. */ -static void R_Bloom_Cascaded( void ){ +static void R_Bloom_Cascaded( void ) +{ int scale; int oldWorkW, oldWorkH; int newWorkW, newWorkH; @@ -441,7 +440,7 @@ static void R_Bloom_Cascaded( void ){ float bloomShiftY=r_bloom_cascade_blur->value/(float)bloom.effect.height; float intensity=r_bloom_cascade_intensity->value; float intensity2; - + qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); //Take the backup texture and downscale it GL_Bind( bloom.screen.texture ); @@ -450,88 +449,89 @@ static void R_Bloom_Cascaded( void ){ //Copy downscaled framebuffer into a texture GL_Bind( bloom.effect.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, bloom.work.width, bloom.work.height ); - + /* Copy the result to the effect texture */ GL_Bind( bloom.effect2.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, bloom.work.width, bloom.work.height ); - + // do blurs.. scale=32; while(bloom.work.width>=1; while(bloom.work.height>=1; - + // prepare the first level. newWorkW=bloom.work.width/scale; newWorkH=bloom.work.height/scale; - + GL_Bind( bloom.effect2.texture ); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); intensity2=intensity/(float)scale; qglColor4f( intensity2, intensity2, intensity2, 1.0 ); - R_Bloom_Quad( newWorkW, newWorkH, - 0, 0, - bloom.effect2.readW, bloom.effect2.readH ); - + R_Bloom_Quad( newWorkW, newWorkH, + 0, 0, + bloom.effect2.readW, bloom.effect2.readH ); + // go through levels. - while(scale>1){ + while(scale>1) { float oldScaleInv=1.f/(float)scale; scale>>=1; oldWorkH=newWorkH; oldWorkW=newWorkW; newWorkW=bloom.work.width/scale; newWorkH=bloom.work.height/scale; - + // get effect texture. GL_Bind( bloom.effect.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWorkW, oldWorkH); - + // maginfy the previous level. - if(r_bloom_cascade_blur->value<.01f){ + if(r_bloom_cascade_blur->value<.01f) { // don't blur. qglColor4f( 1.f, 1.f, 1.f, 1.0 ); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - R_Bloom_Quad( newWorkW, newWorkH, - 0, 0, - bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); - }else{ + R_Bloom_Quad( newWorkW, newWorkH, + 0, 0, + bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); + } + else { // blur. qglColor4f( .25f, .25f, .25f, 1.0 ); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - R_Bloom_Quad( newWorkW, newWorkH, - -bloomShiftX, -bloomShiftY, - bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); - + R_Bloom_Quad( newWorkW, newWorkH, + -bloomShiftX, -bloomShiftY, + bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - R_Bloom_Quad( newWorkW, newWorkH, - bloomShiftX, -bloomShiftY, - bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); - R_Bloom_Quad( newWorkW, newWorkH, - -bloomShiftX, bloomShiftY, - bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); - R_Bloom_Quad( newWorkW, newWorkH, - bloomShiftX, bloomShiftY, - bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); + R_Bloom_Quad( newWorkW, newWorkH, + bloomShiftX, -bloomShiftY, + bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); + R_Bloom_Quad( newWorkW, newWorkH, + -bloomShiftX, bloomShiftY, + bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); + R_Bloom_Quad( newWorkW, newWorkH, + bloomShiftX, bloomShiftY, + bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv ); } - + // add the input. intensity2=intensity/(float)scale; qglColor4f( intensity2, intensity2, intensity2, 1.0 ); - + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); GL_Bind( bloom.effect2.texture ); - - R_Bloom_Quad( newWorkW, newWorkH, - 0, 0, - bloom.effect2.readW, bloom.effect2.readH ); - - + + R_Bloom_Quad( newWorkW, newWorkH, + 0, 0, + bloom.effect2.readW, bloom.effect2.readH ); + + } - + GL_Bind( bloom.effect.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, bloom.work.width, bloom.work.height ); - + } /* @@ -559,9 +559,9 @@ static void R_Bloom_WarsowEffect( void ) GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO ); for( i = 0; i < r_bloom_darken->integer; i++ ) { - R_Bloom_Quad( bloom.work.width, bloom.work.height, - 0, 0, - bloom.effect.readW, bloom.effect.readH ); + R_Bloom_Quad( bloom.work.width, bloom.work.height, + 0, 0, + bloom.effect.readW, bloom.effect.readH ); } qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, bloom.work.width, bloom.work.height ); } @@ -575,37 +575,39 @@ static void R_Bloom_WarsowEffect( void ) if( r_bloom_diamond_size->integer > 7 || r_bloom_diamond_size->integer <= 3 ) { if( r_bloom_diamond_size->integer != 8 ) ri.Cvar_Set( "r_bloom_diamond_size", "8" ); - } else if( r_bloom_diamond_size->integer > 5 ) { + } + else if( r_bloom_diamond_size->integer > 5 ) { if( r_bloom_diamond_size->integer != 6 ) ri.Cvar_Set( "r_bloom_diamond_size", "6" ); - } else if( r_bloom_diamond_size->integer > 3 ) { + } + else if( r_bloom_diamond_size->integer > 3 ) { if( r_bloom_diamond_size->integer != 4 ) ri.Cvar_Set( "r_bloom_diamond_size", "4" ); } switch( r_bloom_diamond_size->integer ) { - case 4: - k = 2; - diamond = &Diamond4x[0][0]; - scale = r_bloom_intensity->value * 0.8f; - break; - case 6: - k = 3; - diamond = &Diamond6x[0][0]; - scale = r_bloom_intensity->value * 0.5f; - break; - case 9: - k = 4; - diamond = &Star8x[0][0]; - scale = r_bloom_intensity->value * 0.3f; - break; + case 4: + k = 2; + diamond = &Diamond4x[0][0]; + scale = r_bloom_intensity->value * 0.8f; + break; + case 6: + k = 3; + diamond = &Diamond6x[0][0]; + scale = r_bloom_intensity->value * 0.5f; + break; + case 9: + k = 4; + diamond = &Star8x[0][0]; + scale = r_bloom_intensity->value * 0.3f; + break; - default: - case 8: - k = 4; - diamond = &Diamond8x[0][0]; - scale = r_bloom_intensity->value * 0.3f; - break; + default: + case 8: + k = 4; + diamond = &Diamond8x[0][0]; + scale = r_bloom_intensity->value * 0.3f; + break; } for( i = 0; i < r_bloom_diamond_size->integer; i++ ) { @@ -622,7 +624,7 @@ static void R_Bloom_WarsowEffect( void ) } } qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, bloom.work.width, bloom.work.height ); -} +} /* ================= @@ -630,7 +632,8 @@ R_Bloom_BackupScreen Backup the full original screen to a texture for downscaling and later restoration ================= */ -static void R_Bloom_BackupScreen( void ) { +static void R_Bloom_BackupScreen( void ) +{ GL_Bind( bloom.screen.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } @@ -641,21 +644,23 @@ R_Bloom_RestoreScreen Restore the temporary framebuffer section we used with the backup texture ================= */ -static void R_Bloom_RestoreScreen( void ) { +static void R_Bloom_RestoreScreen( void ) +{ float dry=r_bloom_dry->value; if(r_bloom_cascade->integer) dry=r_bloom_cascade_dry->value; GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); GL_Bind( bloom.screen.texture ); qglColor4f( dry,dry,dry, 1 ); - if(dry<.99f){ + if(dry<.99f) { R_Bloom_Quad( bloom.screen.width, bloom.screen.height, 0, 0, - 1.f, - 1.f ); - }else{ + 1.f, + 1.f ); + } + else { R_Bloom_Quad( bloom.work.width, bloom.work.height, 0, 0, - bloom.work.width / (float)bloom.screen.width, - bloom.work.height / (float)bloom.screen.height ); + bloom.work.width / (float)bloom.screen.width, + bloom.work.height / (float)bloom.screen.height ); } } /* @@ -666,11 +671,9 @@ Restore the temporary framebuffer section we used with the backup texture */ extern int mpasses; -static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float texY, float texWidth, float texHeight, int aa ) { - int x = 0; - int y = 0; +static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float texY, float texWidth, float texHeight, int aa ) +{ float aspcenter = 0; - int aspoff = 0; float raa = r_retroAA->value; if (raa < 1) raa = 1; @@ -678,103 +681,158 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t float ypix = 1.0f / height / (4 / raa); float xaa; float yaa; - x = 0; - y = 0; - - + int x = 0; + int y = 0; - if (aa == 0){ xaa = 0; yaa = 0; } - if (aa == 1){ xaa = -xpix; yaa = ypix; } - if (aa == 2){ xaa = -xpix; yaa = -ypix; } - if (aa == 3){ xaa = xpix; yaa = -ypix; } - if (aa == 4){ xaa = xpix; yaa = ypix; } + + + if (aa == 0) { + xaa = 0; + yaa = 0; + } + if (aa == 1) { + xaa = -xpix; + yaa = ypix; + } + if (aa == 2) { + xaa = -xpix; + yaa = -ypix; + } + if (aa == 3) { + xaa = xpix; + yaa = -ypix; + } + if (aa == 4) { + xaa = xpix; + yaa = ypix; + } //y += tvHeight - height; width += x; height += y; - + texWidth += texX; texHeight += texY; - if (tvAspectW != 1.0){ + if (tvAspectW != 1.0) { aspcenter = tvWidth * ((1.0f - tvAspectW) / 2); // leilei - also do a quad that is 100% black, hiding our actual rendered viewport - // qglViewport (0, 0, tvWidth, tvHeight ); - // qglScissor (0, 0, tvWidth, tvHeight ); - qglBegin( GL_QUADS ); - if (r_tvFilter->integer) // bilinear filter - { - qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - } - else - { - qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - } - qglColor4f( 0.0, 0.0, 0.0, 1 ); + // qglViewport (0, 0, tvWidth, tvHeight ); + // qglScissor (0, 0, tvWidth, tvHeight ); + qglBegin( GL_QUADS ); + if (r_tvFilter->integer) { // bilinear filter + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + } + else { + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + } + qglColor4f( 0.0, 0.0, 0.0, 1 ); qglVertex2f(0,0 ); - qglVertex2f(0,height); - qglVertex2f(width,height); - qglVertex2f(width,0); + qglVertex2f(0,height); + qglVertex2f(width,height); + qglVertex2f(width,0); qglEnd (); - qglColor4f( 1.0, 1.0, 1.0, 1 ); + qglColor4f( 1.0, 1.0, 1.0, 1 ); } - - //aspcenter = 0; - aspoff = tvWidth * tvAspectW; - - if (!aa){ - qglViewport(aspcenter, 0, (tvWidth * tvAspectW), tvHeight ); - qglScissor(aspcenter, 0, (tvWidth * tvAspectW), tvHeight ); + if (!aa) { + qglViewport(aspcenter, 0, (tvWidth * tvAspectW), tvHeight ); + qglScissor(aspcenter, 0, (tvWidth * tvAspectW), tvHeight ); } - qglBegin( GL_QUADS ); + qglBegin( GL_QUADS ); //GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); if (aa) - qglColor4f( 0.25, 0.25, 0.25, 1 ); - qglTexCoord2f( texX + xaa, texHeight + yaa); + qglColor4f( 0.25, 0.25, 0.25, 1 ); + qglTexCoord2f( texX + xaa, texHeight + yaa); qglVertex2f( x, y ); - qglTexCoord2f( texX + xaa, texY + yaa ); - qglVertex2f( x, height ); - qglTexCoord2f( texWidth + xaa, texY + yaa ); - qglVertex2f( width, height ); - qglTexCoord2f( texWidth + xaa, texHeight + yaa ); - qglVertex2f( width, y ); + qglTexCoord2f( texX + xaa, texY + yaa ); + qglVertex2f( x, height ); + qglTexCoord2f( texWidth + xaa, texY + yaa ); + qglVertex2f( width, height ); + qglTexCoord2f( texWidth + xaa, texHeight + yaa ); + qglVertex2f( width, y ); qglEnd (); } -static void R_Bloom_RestoreScreen_Postprocessed( void ) { +static void R_Bloom_RestoreScreen_Postprocessed( void ) +{ #ifdef GLSL_POSTPROCESSING - glslProgram_t *program; - if (leifxmode) - { - if (leifxmode == 1){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXDitherProgram); program=tr.programs[tr.leiFXDitherProgram];} - if (leifxmode == 2){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXGammaProgram); program=tr.programs[tr.leiFXGammaProgram];} - if (leifxmode == 3){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXFilterProgram); program=tr.programs[tr.leiFXFilterProgram];} - if (leifxmode == 888){ if (vertexShaders) R_GLSL_UseProgram(tr.animeProgram); program=tr.programs[tr.animeProgram];} - if (leifxmode == 999){ if (vertexShaders) R_GLSL_UseProgram(tr.animeFilmProgram); program=tr.programs[tr.animeFilmProgram];} - if (leifxmode == 777){ if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram); program=tr.programs[tr.motionBlurProgram];} - if (leifxmode == 778){ if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram); program=tr.programs[tr.motionBlurProgram];} - if (leifxmode == 779){ if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurPostProgram); program=tr.programs[tr.motionBlurPostProgram];} - if (leifxmode == 632){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCEncodeProgram); program=tr.programs[tr.NTSCEncodeProgram];} - if (leifxmode == 633){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCDecodeProgram); program=tr.programs[tr.NTSCDecodeProgram];} - if (leifxmode == 634){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCBleedProgram); program=tr.programs[tr.NTSCBleedProgram];} - if (leifxmode == 666){ if (vertexShaders) R_GLSL_UseProgram(tr.BrightnessProgram); program=tr.programs[tr.BrightnessProgram];} - if (leifxmode == 1236){ if (vertexShaders) R_GLSL_UseProgram(tr.CRTProgram); program=tr.programs[tr.CRTProgram];} - if (leifxmode == 1997){ if (vertexShaders) R_GLSL_UseProgram(tr.paletteProgram); program=tr.programs[tr.paletteProgram];} - + glslProgram_t *program = NULL; + if (leifxmode) { + if (leifxmode == 1) { + if (vertexShaders) R_GLSL_UseProgram(tr.leiFXDitherProgram); + program=tr.programs[tr.leiFXDitherProgram]; + } + if (leifxmode == 2) { + if (vertexShaders) R_GLSL_UseProgram(tr.leiFXGammaProgram); + program=tr.programs[tr.leiFXGammaProgram]; + } + if (leifxmode == 3) { + if (vertexShaders) R_GLSL_UseProgram(tr.leiFXFilterProgram); + program=tr.programs[tr.leiFXFilterProgram]; + } + if (leifxmode == 888) { + if (vertexShaders) R_GLSL_UseProgram(tr.animeProgram); + program=tr.programs[tr.animeProgram]; + } + if (leifxmode == 999) { + if (vertexShaders) R_GLSL_UseProgram(tr.animeFilmProgram); + program=tr.programs[tr.animeFilmProgram]; + } + if (leifxmode == 777) { + if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram); + program=tr.programs[tr.motionBlurProgram]; + } + if (leifxmode == 778) { + if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram); + program=tr.programs[tr.motionBlurProgram]; + } + if (leifxmode == 779) { + if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurPostProgram); + program=tr.programs[tr.motionBlurPostProgram]; + } + if (leifxmode == 632) { + if (vertexShaders) R_GLSL_UseProgram(tr.NTSCEncodeProgram); + program=tr.programs[tr.NTSCEncodeProgram]; + } + if (leifxmode == 633) { + if (vertexShaders) R_GLSL_UseProgram(tr.NTSCDecodeProgram); + program=tr.programs[tr.NTSCDecodeProgram]; + } + if (leifxmode == 634) { + if (vertexShaders) R_GLSL_UseProgram(tr.NTSCBleedProgram); + program=tr.programs[tr.NTSCBleedProgram]; + } + if (leifxmode == 666) { + if (vertexShaders) R_GLSL_UseProgram(tr.BrightnessProgram); + program=tr.programs[tr.BrightnessProgram]; + } + if (leifxmode == 1236) { + if (vertexShaders) R_GLSL_UseProgram(tr.CRTProgram); + program=tr.programs[tr.CRTProgram]; + } + if (leifxmode == 1997) { + if (vertexShaders) R_GLSL_UseProgram(tr.paletteProgram); + program=tr.programs[tr.paletteProgram]; + } + } - else - { - if (vertexShaders) R_GLSL_UseProgram(tr.postprocessingProgram); - // Feed GLSL postprocess program - program=tr.programs[tr.postprocessingProgram]; + else { + if (vertexShaders) R_GLSL_UseProgram(tr.postprocessingProgram); + // Feed GLSL postprocess program + program=tr.programs[tr.postprocessingProgram]; + } + if (!program) { + //If leifsmode has been set to something invalid we have to bail out or we will dereference a null pointer + Com_Printf( S_COLOR_YELLOW"WARNING: 'leifxmode' has an invalid value\n" ); + return; } if (program->u_ScreenSizeX > -1) R_GLSL_SetUniform_u_ScreenSizeX(program, glConfig.vidWidth); @@ -799,79 +857,80 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) { if (program->u_CC_Saturation > -1) R_GLSL_SetUniform_u_CC_Saturation(program, 1.0); if (program->u_CC_Contrast > -1) R_GLSL_SetUniform_u_CC_Contrast(program, 1.0); - // - if (leifxmode == 3){ R_GLSL_SetUniform_u_CC_Brightness(program, leifxpass); } + // + if (leifxmode == 3) { + R_GLSL_SetUniform_u_CC_Brightness(program, leifxpass); + } - if (program->u_zFar > -1) R_GLSL_SetUniform_u_zFar(program, tr.viewParms.zFar); + if (program->u_zFar > -1) R_GLSL_SetUniform_u_zFar(program, tr.viewParms.zFar); GL_SelectTexture(0); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); GL_Bind( postproc.screen.texture ); GL_SelectTexture(7); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.depth.texture ); + GL_Bind( postproc.depth.texture ); // motion blur crap - if( r_motionblur->integer > 2){ - if (program->u_mpasses > -1) R_GLSL_SetUniform_u_mpasses(program, mpasses); - GL_SelectTexture(2); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.motion1.texture ); - GL_SelectTexture(3); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.motion2.texture ); - GL_SelectTexture(4); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.motion3.texture ); - GL_SelectTexture(5); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.motion4.texture ); - GL_SelectTexture(6); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.motion5.texture ); - GL_SelectTexture(11); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.mpass1.texture ); - GL_SelectTexture(12); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.mpass1.texture ); - GL_SelectTexture(13); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.mpass1.texture ); - GL_SelectTexture(14); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - GL_Bind( postproc.mpass1.texture ); + if( r_motionblur->integer > 2) { + if (program->u_mpasses > -1) R_GLSL_SetUniform_u_mpasses(program, mpasses); + GL_SelectTexture(2); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.motion1.texture ); + GL_SelectTexture(3); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.motion2.texture ); + GL_SelectTexture(4); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.motion3.texture ); + GL_SelectTexture(5); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.motion4.texture ); + GL_SelectTexture(6); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.motion5.texture ); + GL_SelectTexture(11); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.mpass1.texture ); + GL_SelectTexture(12); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.mpass1.texture ); + GL_SelectTexture(13); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.mpass1.texture ); + GL_SelectTexture(14); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + GL_Bind( postproc.mpass1.texture ); } qglColor4f( 1, 1, 1, 1 ); // if (leifxmode == 778) // return; - if (leifxmode == 1234){ - { - R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 0 ); - } - } - else if (leifxmode == 1236){ - { - R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 0 ); - } - } - else if (leifxmode == 1233){ - - - R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 1 ); - GL_SelectTexture(0); - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - GL_Bind( postproc.screen.texture ); - R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 2 ); - R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 3 ); - R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 4 ); - - } - else + if (leifxmode == 1234) { { - R_Bloom_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, - postproc.screen.readW,postproc.screen.readH ); + R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 0 ); } + } + else if (leifxmode == 1236) { + { + R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 0 ); + } + } + else if (leifxmode == 1233) { + + + R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 1 ); + GL_SelectTexture(0); + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + GL_Bind( postproc.screen.texture ); + R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 2 ); + R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 3 ); + R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 4 ); + + } + else { + R_Bloom_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, + postproc.screen.readW,postproc.screen.readH ); + } if (vertexShaders) R_GLSL_UseProgram(0); GL_SelectTexture(0); #endif @@ -901,8 +960,8 @@ Scale the copied screen back to the sample size used for subsequent passes GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO ); for( i = 0; i < r_bloom_darken->integer; i++ ) { - R_Bloom_Quad( bloom.work.width, bloom.work.height, - 0, 0, + R_Bloom_Quad( bloom.work.width, bloom.work.height, + 0, 0, bloom.effect.readW, bloom.effect.readH ); } qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, bloom.work.width, bloom.work.height ); @@ -946,8 +1005,8 @@ static void R_Bloom_CreateEffect( void ) { r = 2.0f /(range*2+1)*(1 - x*x/(float)(range*range)); // r *= r_bloom_darken->value; qglColor4f(r, r, r, 1); - R_Bloom_Quad( bloom.work.width, bloom.work.height, - xoffset, yoffset, + R_Bloom_Quad( bloom.work.width, bloom.work.height, + xoffset, yoffset, bloom.effect.readW, bloom.effect.readH ); // bloom.screen.readW, bloom.screen.readH ); GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); @@ -987,10 +1046,10 @@ void R_BloomScreen( void ) qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglMatrixMode( GL_PROJECTION ); - qglLoadIdentity (); + qglLoadIdentity (); qglOrtho( 0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1 ); qglMatrixMode( GL_MODELVIEW ); - qglLoadIdentity (); + qglLoadIdentity (); GL_Cull( CT_TWO_SIDED ); #endif @@ -1016,12 +1075,13 @@ void R_BloomScreen( void ) // applied to give a rainbow streak effect. Most effective with high bloom darkness // values. if(r_bloom_reflection->integer) - R_Bloom_LensEffect (); + R_Bloom_LensEffect (); } -void R_BloomInit( void ) { +void R_BloomInit( void ) +{ memset( &bloom, 0, sizeof( bloom )); r_bloom = ri.Cvar_Get( "r_bloom", "0", CVAR_ARCHIVE ); @@ -1062,20 +1122,19 @@ static void R_Postprocess_InitTextures( void ) { #ifdef GLSL_POSTPROCESSING byte *data; - int vidinted = glConfig.vidHeight * 0.55f; int intdiv = 1; force32upload = 1; - // find closer power of 2 to screen size - for (postproc.screen.width = 1;postproc.screen.width< glConfig.vidWidth;postproc.screen.width *= 2); + // find closer power of 2 to screen size + for (postproc.screen.width = 1; postproc.screen.width< glConfig.vidWidth; postproc.screen.width *= 2) {} // if (r_tvMode->integer > 1) // interlaced // for (postproc.screen.height = 1;postproc.screen.height < vidinted;postproc.screen.height *= 2); //else - for (postproc.screen.height = 1;postproc.screen.height < glConfig.vidHeight;postproc.screen.height *= 2); + for (postproc.screen.height = 1; postproc.screen.height < glConfig.vidHeight; postproc.screen.height *= 2) {} -// if (r_tvMode->integer > 1) +// if (r_tvMode->integer > 1) // intdiv = 2; postproc.screen.readW = glConfig.vidWidth / (float)postproc.screen.width; @@ -1084,12 +1143,12 @@ static void R_Postprocess_InitTextures( void ) - // find closer power of 2 to effect size + // find closer power of 2 to effect size postproc.work.width = r_bloom_sample_size->integer; postproc.work.height = postproc.work.width * ( glConfig.vidWidth / glConfig.vidHeight ); - for (postproc.effect.width = 1;postproc.effect.width < postproc.work.width;postproc.effect.width *= 2); - for (postproc.effect.height = 1;postproc.effect.height < postproc.work.height;postproc.effect.height *= 2); + for (postproc.effect.width = 1; postproc.effect.width < postproc.work.width; postproc.effect.width *= 2) {} + for (postproc.effect.height = 1; postproc.effect.height < postproc.work.height; postproc.effect.height *= 2) {} postproc.effect.readW = postproc.work.width / (float)postproc.effect.width; postproc.effect.readH = postproc.work.height / (float)postproc.effect.height; @@ -1099,8 +1158,8 @@ static void R_Postprocess_InitTextures( void ) // disable blooms if we can't handle a texture of that size if( postproc.screen.width > glConfig.maxTextureSize || - postproc.screen.height > glConfig.maxTextureSize - ) { + postproc.screen.height > glConfig.maxTextureSize + ) { ri.Cvar_Set( "r_postprocess", "none" ); Com_Printf( S_COLOR_YELLOW"WARNING: 'R_InitPostprocessTextures' too high resolution for postprocessing, effect disabled\n" ); postprocess=0; @@ -1113,37 +1172,39 @@ static void R_Postprocess_InitTextures( void ) Com_Memset( data, 0, postproc.screen.width * postproc.screen.height * 4 ); postproc.screen.texture = R_CreateImage( "***postproc screen texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); ri.Hunk_FreeTempMemory( data ); - + // leilei - tv output texture - if (r_tvMode->integer > -1){ - // find closer power of 2 to screen size - for (postproc.tv.width = 1;postproc.tv.width< tvWidth;postproc.tv.width *= 2); - for (postproc.tv.height = 1;postproc.tv.height < tvHeight;postproc.tv.height *= 2); - + if (r_tvMode->integer > -1) { + // find closer power of 2 to screen size + for (postproc.tv.width = 1; postproc.tv.width< tvWidth; postproc.tv.width *= 2); + for (postproc.tv.height = 1; postproc.tv.height < tvHeight; postproc.tv.height *= 2); + //postproc.tv.height /= intdiv; // interlacey - + postproc.tv.readW = tvWidth / (float)postproc.tv.width; postproc.tv.readH = tvHeight / (float)postproc.tv.height; - - // find closer power of 2 to effect size + + // find closer power of 2 to effect size postproc.tvwork.width = r_bloom_sample_size->integer; postproc.tvwork.height = postproc.tvwork.width * ( tvWidth / tvHeight ); - // postproc.tvwork.height /= intdiv; // interlacey - - for (postproc.tveffect.width = 1;postproc.tveffect.width < postproc.tvwork.width;postproc.tveffect.width *= 2); -if (intdiv > 1) - for (postproc.tveffect.height = 1;(postproc.tveffect.height/2) < postproc.tvwork.height;postproc.tveffect.height *= 2); - else - for (postproc.tveffect.height = 1;postproc.tveffect.height < postproc.tvwork.height;postproc.tveffect.height *= 2); + // postproc.tvwork.height /= intdiv; // interlacey + + for (postproc.tveffect.width = 1; postproc.tveffect.width < postproc.tvwork.width; postproc.tveffect.width *= 2) {} + if (intdiv > 1) { + for (postproc.tveffect.height = 1; (postproc.tveffect.height/2) < postproc.tvwork.height; postproc.tveffect.height *= 2) {} + } + else { + for (postproc.tveffect.height = 1; postproc.tveffect.height < postproc.tvwork.height; postproc.tveffect.height *= 2) {} + } postproc.tveffect.readW = postproc.tvwork.width / (float)postproc.tveffect.width; postproc.tveffect.readH = postproc.tvwork.height / (float)postproc.tveffect.height; - - + + data = ri.Hunk_AllocateTempMemory( tvWidth * tvHeight * 4 ); Com_Memset( data, 0, tvWidth * tvHeight * 4 ); postproc.tv.texture = R_CreateImage( "***tv output screen texture***", data, tvWidth, tvHeight, qfalse, qfalse, GL_CLAMP_TO_EDGE ); @@ -1152,19 +1213,19 @@ if (intdiv > 1) // leilei - motion blur textures! - if (r_motionblur->integer > 2){ - data = ri.Hunk_AllocateTempMemory( postproc.screen.width * postproc.screen.height * 4 ); - Com_Memset( data, 0, postproc.screen.width * postproc.screen.height * 4 ); - postproc.motion1.texture = R_CreateImage( "***motionblur1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.motion2.texture = R_CreateImage( "***motionblur2 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.motion3.texture = R_CreateImage( "***motionblur3 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.motion4.texture = R_CreateImage( "***motionblur4 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.motion5.texture = R_CreateImage( "***motionblur5 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.mpass1.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.mpass2.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.mpass3.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - postproc.mpass4.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); - ri.Hunk_FreeTempMemory( data ); + if (r_motionblur->integer > 2) { + data = ri.Hunk_AllocateTempMemory( postproc.screen.width * postproc.screen.height * 4 ); + Com_Memset( data, 0, postproc.screen.width * postproc.screen.height * 4 ); + postproc.motion1.texture = R_CreateImage( "***motionblur1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.motion2.texture = R_CreateImage( "***motionblur2 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.motion3.texture = R_CreateImage( "***motionblur3 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.motion4.texture = R_CreateImage( "***motionblur4 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.motion5.texture = R_CreateImage( "***motionblur5 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.mpass1.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.mpass2.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.mpass3.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + postproc.mpass4.texture = R_CreateImage( "***motionaccum1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE ); + ri.Hunk_FreeTempMemory( data ); } // GLSL Depth Buffer @@ -1178,7 +1239,7 @@ if (intdiv > 1) postproc.started = qtrue; force32upload = 0; -#endif +#endif } /* @@ -1203,7 +1264,8 @@ R_Postprocess_BackupScreen Backup the full original screen to a texture for downscaling and later restoration ================= */ -static void R_Postprocess_BackupScreen( void ) { +static void R_Postprocess_BackupScreen( void ) +{ #ifdef GLSL_POSTPROCESSING GL_Bind( postproc.screen.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); @@ -1211,7 +1273,7 @@ static void R_Postprocess_BackupScreen( void ) { GL_Bind( postproc.depth.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); -#endif +#endif } @@ -1252,7 +1314,8 @@ void R_PostprocessScreen( void ) -void R_PostprocessingInit(void) { +void R_PostprocessingInit(void) +{ #ifdef GLSL_POSTPROCESSING memset( &postproc, 0, sizeof( postproc )); #endif @@ -1269,30 +1332,31 @@ void R_PostprocessingInit(void) { -static void ID_INLINE R_LeiFX_Pointless_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) { +static void ID_INLINE R_LeiFX_Pointless_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) +{ int x = 0; int y = 0; x = 0; y += glConfig.vidHeight - height; width += x; height += y; - + texWidth += texX; texHeight += texY; - qglBegin( GL_QUADS ); + qglBegin( GL_QUADS ); - qglTexCoord2f( texX, texHeight ); + qglTexCoord2f( texX, texHeight ); qglVertex2f( x, y ); - qglTexCoord2f( texX, texY ); - qglVertex2f( x, height ); + qglTexCoord2f( texX, texY ); + qglVertex2f( x, height ); - qglTexCoord2f( texWidth, texY ); - qglVertex2f( width, height ); + qglTexCoord2f( texWidth, texY ); + qglVertex2f( width, height ); - qglTexCoord2f( texWidth, texHeight ); - qglVertex2f( width, y ); + qglTexCoord2f( texWidth, texHeight ); + qglVertex2f( width, y ); qglEnd (); } @@ -1331,19 +1395,19 @@ void R_LeiFXPostprocessDitherScreen( void ) // postprocess = 1; leifxmode = 1; - + // The stupidest hack in america R_LeiFX_Stupid_Hack(); - if (r_leifx->integer > 1){ + if (r_leifx->integer > 1) { leifxmode = 1; // reduct and dither - 1 pass R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); - } + } - force32upload = 0; -#endif + force32upload = 0; +#endif } @@ -1365,24 +1429,25 @@ void R_LeiFXPostprocessFilterScreen( void ) return; } - if ( !backEnd.projection2D ) + if ( !backEnd.projection2D ) { RB_SetGL2D(); - force32upload = 1; + } + force32upload = 1; // postprocess = 1; -/* if (r_leifx->integer == 3){ - leifxmode = 2; // gamma - 1 pass - // The stupidest hack in america - R_LeiFX_Stupid_Hack(); - R_Postprocess_BackupScreen(); - R_Bloom_RestoreScreen_Postprocessed(); - } -*/ // Gamma disabled because r_alternateBrightness 2 makes it redundant now. - if (r_leifx->integer > 3){ + /* if (r_leifx->integer == 3){ + leifxmode = 2; // gamma - 1 pass + // The stupidest hack in america + R_LeiFX_Stupid_Hack(); + R_Postprocess_BackupScreen(); + R_Bloom_RestoreScreen_Postprocessed(); + } + */ // Gamma disabled because r_alternateBrightness 2 makes it redundant now. + if (r_leifx->integer > 3) { leifxmode = 3; // filter - 4 pass - // The stupidest hack in america - R_LeiFX_Stupid_Hack(); + // The stupidest hack in america + R_LeiFX_Stupid_Hack(); leifxpass = 0; R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); @@ -1395,11 +1460,11 @@ void R_LeiFXPostprocessFilterScreen( void ) leifxpass = 3; R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); - } + } backEnd.doneleifx = qtrue; - force32upload = 0; - + force32upload = 0; + #endif } @@ -1432,66 +1497,88 @@ void R_NTSCScreen( void ) return; } - if ( !backEnd.projection2D ) + if ( !backEnd.projection2D ) { RB_SetGL2D(); - force32upload = 1; + } + force32upload = 1; int ntsc_bleed = 0; int ntsc_encode = 0; int ntsc_decode = 0; // TODO: Switch it up - if (r_ntsc->integer == 1) ntsc_bleed = 1; - else if (r_ntsc->integer == 2){ ntsc_bleed = 1; ntsc_encode = 1; ntsc_decode = 1; } - else if (r_ntsc->integer == 3){ ntsc_bleed = 0; ntsc_encode = 1; ntsc_decode = 1; } - else if (r_ntsc->integer == 4){ ntsc_bleed = 1; ntsc_encode = 1; ntsc_decode = 1; } - else if (r_ntsc->integer > 6){ ntsc_bleed = 666; ntsc_encode = 0; ntsc_decode = 0; } - else { ntsc_bleed = 0; ntsc_encode = 1; ntsc_decode = 0; } - + if (r_ntsc->integer == 1) { + ntsc_bleed = 1; + } + else if (r_ntsc->integer == 2) { + ntsc_bleed = 1; + ntsc_encode = 1; + ntsc_decode = 1; + } + else if (r_ntsc->integer == 3) { + ntsc_bleed = 0; + ntsc_encode = 1; + ntsc_decode = 1; + } + else if (r_ntsc->integer == 4) { + ntsc_bleed = 1; + ntsc_encode = 1; + ntsc_decode = 1; + } + else if (r_ntsc->integer > 6) { + ntsc_bleed = 666; + ntsc_encode = 0; + ntsc_decode = 0; + } + else { + ntsc_bleed = 0; + ntsc_encode = 1; + ntsc_decode = 0; + } + // qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); // qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); R_LeiFX_Stupid_Hack(); - if (ntsc_encode){ + if (ntsc_encode) { leifxmode = 632; // Encode to composite R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); - } + } - if (ntsc_decode){ + if (ntsc_decode) { leifxmode = 633; // Decode to RGB R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); - } + } - if (ntsc_bleed){ + if (ntsc_bleed) { leifxmode = 634; // Encode to YUV and decode to RGB R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); - } + } - if (ntsc_bleed == 666){ + if (ntsc_bleed == 666) { leifxmode = 634; // Encode to YUV and decode to RGB EXCESSIVELY int passasses = r_ntsc->integer; int j; - for (j=0;jinteger) return; if ( backEnd.doneAltBrightness) @@ -1554,18 +1642,18 @@ void R_BrightScreen( void ) if (r_alternateBrightness->integer == 1) mode = 1; // force use blend #ifdef GLSL_POSTPROCESSING - if (r_alternateBrightness->integer == 2) - { + if (r_alternateBrightness->integer == 2) { // Automatically determine from capabilities - if ( vertexShaders ) - mode = 2; - else - mode = 1; + if ( vertexShaders ) { + mode = 2; + } + else { + mode = 1; + } } // the modern pixel shader way - if (mode == 2) - { + if (mode == 2) { if ( !vertexShaders ) return; // leilei - cards without support for this should not ever activate this @@ -1575,50 +1663,52 @@ void R_BrightScreen( void ) if( !postproc.started ) return; } - + if ( !backEnd.projection2D ) - RB_SetGL2D(); - + RB_SetGL2D(); + force32upload = 1; - + leifxmode = 666; // anime effect - outlines, desat, bloom and other crap to go with it R_LeiFX_Stupid_Hack(); R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); backEnd.doneAltBrightness = qtrue; - + force32upload = 0; - } + } // the fixed function quad blending way else if (mode == 1) #endif { - int eh, ah; - if ((r_overBrightBits->integer)) - { - - ah = r_overBrightBits->integer; - if (ah < 1) ah = 1; if (ah > 2) ah = 2; // clamp so it never looks stupid + if ((r_overBrightBits->integer)) { + ah = r_overBrightBits->integer; + if (ah < 1) { + ah = 1; + } + if (ah > 2) { + ah = 2; // clamp so it never looks stupid + } // Blend method // do a loop for every overbright bit enabled for (eh=0; ehinteger ) return; @@ -1648,83 +1737,90 @@ void R_FilmScreen( void ) RB_SetGL2D(); backEnd.doneFilm = qtrue; - // set up our colors, this is our default - tone[0] = 0.8f; - tone[1] = 0.9f; - tone[2] = 1.0f; + // set up our colors, this is our default + tone[0] = 0.8f; + tone[1] = 0.9f; + tone[2] = 1.0f; //VectorCopy( backEnd.currentEntity->ambientLight, tone ); - if (backEnd.currentEntity){ - if (backEnd.currentEntity->ambientLight[0] > 0.001f && backEnd.currentEntity->ambientLight[1] > 0.001f && backEnd.currentEntity->ambientLight[2] > 0.001f){ - tone[0] = backEnd.currentEntity->ambientLight[0]; - tone[1] = backEnd.currentEntity->ambientLight[1]; - tone[2] = backEnd.currentEntity->ambientLight[2]; - } + if (backEnd.currentEntity) { + if (backEnd.currentEntity->ambientLight[0] > 0.001f && backEnd.currentEntity->ambientLight[1] > 0.001f && backEnd.currentEntity->ambientLight[2] > 0.001f) { + tone[0] = backEnd.currentEntity->ambientLight[0]; + tone[1] = backEnd.currentEntity->ambientLight[1]; + tone[2] = backEnd.currentEntity->ambientLight[2]; } + } // VectorNormalize(tone); - tone[0] *= 0.3 + 0.7; - tone[1] *= 0.3 + 0.7; - tone[2] *= 0.3 + 0.7; + tone[0] *= 0.3 + 0.7; + tone[1] *= 0.3 + 0.7; + tone[2] *= 0.3 + 0.7; // tone[0] = 1.6f; // tone[1] = 1.2f; // tone[2] = 0.7f; - // TODO: Get overexposure to flares raising this faking "HDR" - tonecont[0] = 0.0f; - tonecont[1] = 0.0f; - tonecont[2] = 0.0f; - + // TODO: Get overexposure to flares raising this faking "HDR" + tonecont[0] = 0.0f; + tonecont[1] = 0.0f; + tonecont[2] = 0.0f; - // inverted - toneinv[0] = tone[0] * -1 + 1 + tonecont[0]; - toneinv[1] = tone[1] * -1 + 1 + tonecont[1]; - toneinv[2] = tone[2] * -1 + 1 + tonecont[2]; + // inverted - // darken vignette. - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);GL_Bind( tr.dlightImage ); GL_Cull( CT_TWO_SIDED ); - qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f ); - R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.35f, 0.35f, 0.2f, 0.2f ); + toneinv[0] = tone[0] * -1 + 1 + tonecont[0]; + toneinv[1] = tone[1] * -1 + 1 + tonecont[1]; + toneinv[2] = tone[2] * -1 + 1 + tonecont[2]; + + // darken vignette. + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + GL_Bind( tr.dlightImage ); + GL_Cull( CT_TWO_SIDED ); + qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f ); + R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.35f, 0.35f, 0.2f, 0.2f ); - // brighten. - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE);GL_Bind( tr.dlightImage ); GL_Cull( CT_TWO_SIDED ); - //qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f ); - qglColor4f( (0.9f + (tone[0] * 0.5)), (0.9f + (tone[1] * 0.5)), (0.9f + (tone[2] * 0.5)), 1.0f ); + // brighten. + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE); + GL_Bind( tr.dlightImage ); + GL_Cull( CT_TWO_SIDED ); + //qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f ); + qglColor4f( (0.9f + (tone[0] * 0.5)), (0.9f + (tone[1] * 0.5)), (0.9f + (tone[2] * 0.5)), 1.0f ); - R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.25f, 0.25f, 0.48f, 0.48f ); + R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.25f, 0.25f, 0.48f, 0.48f ); - // invert. - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED ); + // invert. + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR); + GL_Bind( tr.whiteImage ); + GL_Cull( CT_TWO_SIDED ); // qglColor4f(0.85098, 0.85098, 0.815686, 1.0f ); - qglColor4f( (0.8f + (toneinv[0] * 0.5)), (0.8f + (toneinv[1] * 0.5)), (0.8f + (toneinv[2] * 0.5)), 1.0f ); - R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); + qglColor4f( (0.8f + (toneinv[0] * 0.5)), (0.8f + (toneinv[1] * 0.5)), (0.8f + (toneinv[2] * 0.5)), 1.0f ); + R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); - // brighten. - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED ); - qglColor4f( 0.615686, 0.615686, 0.615686, 1.0f ); - R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); + // brighten. + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR); + GL_Bind( tr.whiteImage ); + GL_Cull( CT_TWO_SIDED ); + qglColor4f( 0.615686, 0.615686, 0.615686, 1.0f ); + R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); - // invoort. - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED ); - qglColor4f(1.0f, 1.0f, 1.0f , 1.0f ); - R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); + // invoort. + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR); + GL_Bind( tr.whiteImage ); + GL_Cull( CT_TWO_SIDED ); + qglColor4f(1.0f, 1.0f, 1.0f , 1.0f ); + R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); - // brighten. - GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED ); + // brighten. + GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR); + GL_Bind( tr.whiteImage ); + GL_Cull( CT_TWO_SIDED ); // qglColor4f( 0.866667, 0.847059, 0.776471, 1.0f ); - qglColor4f( (0.73f + (toneinv[0] * 0.4)), (0.73f + (toneinv[1] * 0.4)), (0.73f + (toneinv[2] * 0.4)), 1.0f ); - R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); - - - - - + qglColor4f( (0.73f + (toneinv[0] * 0.4)), (0.73f + (toneinv[1] * 0.4)), (0.73f + (toneinv[2] * 0.4)), 1.0f ); + R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 ); } @@ -1763,11 +1859,11 @@ void R_RetroAAScreen( void ) //R_Postprocess_BackupScreen(); R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); - + backEnd.doneraa = qtrue; force32upload = 0; - + #endif } @@ -1805,7 +1901,7 @@ void R_AnimeScreen( void ) } if ( !backEnd.projection2D ) - RB_SetGL2D(); + RB_SetGL2D(); force32upload = 1; @@ -1814,13 +1910,13 @@ void R_AnimeScreen( void ) R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); leifxmode = 999; // film effect - to blur things slightly, and add some grain and chroma stuff - R_LeiFX_Stupid_Hack(); + R_LeiFX_Stupid_Hack(); R_Postprocess_BackupScreen(); R_Bloom_RestoreScreen_Postprocessed(); backEnd.doneanime = qtrue; - force32upload = 0; -#endif + force32upload = 0; +#endif } @@ -1838,22 +1934,53 @@ void R_AnimeScreen( void ) // leilei - motion blur hack -void R_MotionBlur_BackupScreen(int which) { +void R_MotionBlur_BackupScreen(int which) +{ #ifdef GLSL_POSTPROCESSING if( r_motionblur->integer < 3) return; - if (which == 1){ GL_Bind( postproc.motion1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // gather thee samples - if (which == 2){ GL_Bind( postproc.motion2.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } - if (which == 3){ GL_Bind( postproc.motion3.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } - if (which == 4){ GL_Bind( postproc.motion4.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } - if (which == 5){ GL_Bind( postproc.motion5.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } - if (which == 11){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum - if (which == 12){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum - if (which == 13){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum - if (which == 14){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum - if (which == 18){ GL_Bind( postproc.screen.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum -#endif - + if (which == 1) { + GL_Bind( postproc.motion1.texture ); // gather thee samples + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 2) { + GL_Bind( postproc.motion2.texture ); + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 3) { + GL_Bind( postproc.motion3.texture ); + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 4) { + GL_Bind( postproc.motion4.texture ); + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 5) { + GL_Bind( postproc.motion5.texture ); + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 11) { + GL_Bind( postproc.mpass1.texture ); // to accum + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 12) { + GL_Bind( postproc.mpass1.texture ); // to accum + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 13) { + GL_Bind( postproc.mpass1.texture ); // to accum + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 14) { + GL_Bind( postproc.mpass1.texture ); // to accum + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } + if (which == 18) { + GL_Bind( postproc.screen.texture ); // to accum + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + } +#endif + } @@ -1876,10 +2003,10 @@ void R_MblurScreen( void ) } if ( !backEnd.projection2D ) - RB_SetGL2D(); + RB_SetGL2D(); + - force32upload = 1; @@ -1912,7 +2039,7 @@ void R_MblurScreenPost( void ) backEnd.donemblur = qtrue; if ( !backEnd.projection2D ) - RB_SetGL2D(); + RB_SetGL2D(); force32upload = 1; @@ -1932,20 +2059,17 @@ void R_MblurScreenPost( void ) // TV MODE // ================================================================= -static void R_Postprocess_BackupScreenTV( void ) { +static void R_Postprocess_BackupScreenTV( void ) +{ #ifdef GLSL_POSTPROCESSING - int intdiv; - intdiv = 1; - - GL_TexEnv( GL_MODULATE ); qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglMatrixMode( GL_PROJECTION ); - qglLoadIdentity (); + qglLoadIdentity (); qglOrtho( 0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1 ); qglMatrixMode( GL_MODELVIEW ); - qglLoadIdentity (); + qglLoadIdentity (); GL_Bind( postproc.screen.texture ); @@ -1953,14 +2077,15 @@ static void R_Postprocess_BackupScreenTV( void ) { #endif } -static void R_Postprocess_ScaleTV( void ) { +static void R_Postprocess_ScaleTV( void ) +{ #ifdef GLSL_POSTPROCESSING GL_TexEnv( GL_MODULATE ); qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglMatrixMode( GL_PROJECTION ); - qglLoadIdentity (); + qglLoadIdentity (); #endif } @@ -1992,15 +2117,15 @@ void R_TVScreen( void ) - force32upload = 1; + force32upload = 1; // postprocess = 1; - if (backEnd.refdef.time > tvtime){ + if (backEnd.refdef.time > tvtime) { tvinterlace *= -1; - tvtime = backEnd.refdef.time + (1000.0f / 60); // 60hz + tvtime = backEnd.refdef.time + (1000.0f / 60); // 60hz } - + tvinter = tvinterlace; if (tvinter < 0) tvinter = 0; if (r_tvMode->integer < 100) tvinter = 0; @@ -2012,23 +2137,21 @@ void R_TVScreen( void ) // leifxmode = 1236; // run it through a shader //R_Postprocess_BackupScreen(); - if (r_tvMode->integer > 100) - { - R_Postprocess_ScaleTV(); + if (r_tvMode->integer > 100) { + R_Postprocess_ScaleTV(); } - else - { - R_Postprocess_BackupScreenTV(); + else { + R_Postprocess_BackupScreenTV(); - R_Bloom_RestoreScreen_Postprocessed(); + R_Bloom_RestoreScreen_Postprocessed(); } - + backEnd.donetv = qtrue; force32upload = 0; #else // NO! -#endif +#endif } @@ -2040,7 +2163,7 @@ void R_TVScreen( void ) // ================================================================= // PALLETIZING // -// Processes the screen into having a 8-bit indexed color +// Processes the screen into having a 8-bit indexed color // palette to suit a throwback mode better // // ================================================================= @@ -2067,7 +2190,7 @@ void R_PaletteScreen( void ) } if ( !backEnd.projection2D ) - RB_SetGL2D(); + RB_SetGL2D(); force32upload = 1; @@ -2078,7 +2201,7 @@ void R_PaletteScreen( void ) backEnd.donepalette = qtrue; force32upload = 0; - + #else // NO! #endif @@ -2112,7 +2235,7 @@ void R_InitWaterTextures( void ) -static void R_Water_BackupScreen( void ) +static void R_Water_BackupScreen( void ) { // NO! } @@ -2120,15 +2243,17 @@ static void R_Water_BackupScreen( void ) static void R_WaterWorks( void ) { // NO! -} - - -static void R_Water_RestoreScreen( void ) { - // NO! } - -void R_WaterInit( void ) { + +static void R_Water_RestoreScreen( void ) +{ + // NO! +} + + +void R_WaterInit( void ) +{ // NO! } diff --git a/code/renderer_oa/tr_flares.c b/code/renderer_oa/tr_flares.c index 40326b07..b8a6b065 100644 --- a/code/renderer_oa/tr_flares.c +++ b/code/renderer_oa/tr_flares.c @@ -79,17 +79,17 @@ typedef struct flare_s { vec3_t origin; vec3_t color; int radius; // leilei - for dynamic light flares - qboolean peek; + qboolean peek; int ftype; // leilei - flare types - // 0 - off - // 1 - nromal flare - // 2 - hexagonal polygons (tcpp) - // 3 - glow polygons (tcpp) - // 4 - hex and glow polygons (tcpp) - // 5 - lens reflections like it's 1997 - // 6 - fully modulated lens reflections - // 7 - unmodulated lens reflections - // 8 - anamorphic like it's 2009 + // 0 - off + // 1 - nromal flare + // 2 - hexagonal polygons (tcpp) + // 3 - glow polygons (tcpp) + // 4 - hex and glow polygons (tcpp) + // 5 - lens reflections like it's 1997 + // 6 - fully modulated lens reflections + // 7 - unmodulated lens reflections + // 8 - anamorphic like it's 2009 struct shader_s *theshader; // leilei - custom flare shaders int type; // 0 - map, 1 - dlight, 2 - sun float delay; // update delay time @@ -110,7 +110,8 @@ int flareCoeff; R_SetFlareCoeff ================== */ -static void R_SetFlareCoeff( void ) { +static void R_SetFlareCoeff( void ) +{ if(r_flareCoeff->value == 0.0f) flareCoeff = atof(FLARE_STDCOEFF); @@ -123,12 +124,13 @@ qboolean forceit; // for low quality flare testing static int pvrhack = 0; // leilei = powervr workarounds -/* +/* ================== R_ClearFlares ================== */ -void R_ClearFlares( void ) { +void R_ClearFlares( void ) +{ int i; Com_Memset( r_flareStructs, 0, sizeof( r_flareStructs ) ); @@ -155,9 +157,10 @@ float flaredsize; // leilei - dirty flare fix for widescreens -void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal, int radii, int efftype, float scaled, int type) { +void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal, int radii, int efftype, float scaled, int type) +{ int i; - flare_t *f, *oldest; + flare_t *f; vec3_t local; float d = 1; vec4_t eye, clip, normalized, window; @@ -166,8 +169,7 @@ void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, ve // fade the intensity of the flare down as the // light surface turns away from the viewer - if(normal && (normal[0] || normal[1] || normal[2]) ) - { + if(normal && (normal[0] || normal[1] || normal[2]) ) { VectorSubtract( backEnd.viewParms.or.origin, point, local ); VectorNormalizeFast(local); d = DotProduct(local, normal); @@ -179,10 +181,10 @@ void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, ve flaredsize = backEnd.viewParms.viewportHeight; - R_TransformModelToClip( point, backEnd.or.modelMatrix, - backEnd.viewParms.projectionMatrix, eye, clip ); + R_TransformModelToClip( point, backEnd.or.modelMatrix, + backEnd.viewParms.projectionMatrix, eye, clip ); + - // check to see if the point is completely off screen @@ -196,15 +198,14 @@ void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, ve R_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window ); if ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth - || window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) { + || window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) { return; // shouldn't happen, since we check the clip[] above, except for FP rounding } // see if a flare with a matching surface, scene, and view exists - oldest = r_flareStructs; for ( f = r_activeFlares ; f ; f = f->next ) { if ( f->surface == surface && f->frameSceneNum == backEnd.viewParms.frameSceneNum - && f->inPortal == backEnd.viewParms.isPortal ) { + && f->inPortal == backEnd.viewParms.isPortal ) { break; } } @@ -247,37 +248,37 @@ void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, ve if (!pvrhack) // leilei - don't do this on powervr - VectorScale( f->color, d, f->color ); + VectorScale( f->color, d, f->color ); // save info needed to test f->windowX = backEnd.viewParms.viewportX + window[0]; f->windowY = backEnd.viewParms.viewportY + window[1]; - f->radius = radii * scaled * 0.17; + f->radius = radii * scaled * 0.17; f->eyeZ = eye[2]; f->theshader = tr.flareShader; f->type = type; if (f->type == 0) - f->theshader = surface->shadder; + f->theshader = surface->shadder; else - f->theshader = tr.flareShader; + f->theshader = tr.flareShader; if ( (type == 1) && (r_flaresDlightScale->value) ) { // leilei - dynamic light flare scale float ef = r_flaresDlightScale->value; - if (ef > 1.0f) ef = 1.0f; - if (ef < 0.01f) ef = 0.01f; - + if (ef > 1.0f) ef = 1.0f; + if (ef < 0.01f) ef = 0.01f; + f->radius *= ef; } if ( (type == 1) && (r_flaresDlightOpacity->value) ) { // leilei - dynamic light flare scale float ef = r_flaresDlightOpacity->value; - if (ef > 1.0f) ef = 1.0f; - if (ef < 0.1f) ef = 0.1f; - + if (ef > 1.0f) ef = 1.0f; + if (ef < 0.1f) ef = 0.1f; + f->color[0] *= ef; f->color[1] *= ef; f->color[2] *= ef; @@ -288,7 +289,7 @@ void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, ve // { -// } +// } } @@ -298,7 +299,8 @@ void RB_AddFlare(srfFlare_t *surface, int fogNum, vec3_t point, vec3_t color, ve RB_AddDlightFlares ================== */ -void RB_AddDlightFlares( void ) { +void RB_AddDlightFlares( void ) +{ dlight_t *l; int i, j, k; fog_t *fog = NULL; @@ -315,9 +317,8 @@ void RB_AddDlightFlares( void ) { for (i=0 ; inumfogs ; j++ ) { fog = &tr.world->fogs[j]; for ( k = 0 ; k < 3 ; k++ ) { @@ -350,7 +351,7 @@ FLARE BACK END void CM_Trace( trace_t *results, const vec3_t start, const vec3_t end, vec3_t mins, vec3_t maxs, - clipHandle_t model, const vec3_t origin, int brushmask, int capsule, sphere_t *sphere ); + clipHandle_t model, const vec3_t origin, int brushmask, int capsule, sphere_t *sphere ); /* @@ -360,89 +361,89 @@ RB_TestFlareFast faster simple one. ================== */ -static void RB_TestFlareFast( flare_t *f, int dotrace ) { +static void RB_TestFlareFast( flare_t *f, int dotrace ) +{ float depth; qboolean visible; float fade; float screenZ; - backEnd.pc.c_flareTests++; - - - // doing a readpixels is as good as doing a glFinish(), so - // don't bother with another sync - glState.finishCalled = qfalse; - if (f->type == 2) dotrace = 0; // sun cant trace - // leilei - do trace, then complain - if (dotrace){ - trace_t yeah; - CM_Trace( &yeah, f->origin, backEnd.or.viewOrigin, NULL, NULL, NULL, f->origin, 1, NULL, NULL ); - if (yeah.fraction < 1){ - visible = 0; + backEnd.pc.c_flareTests++; + + + // doing a readpixels is as good as doing a glFinish(), so + // don't bother with another sync + glState.finishCalled = qfalse; + if (f->type == 2) dotrace = 0; // sun cant trace + // leilei - do trace, then complain + if (dotrace) { + trace_t yeah; + CM_Trace( &yeah, f->origin, backEnd.or.viewOrigin, NULL, NULL, 0, f->origin, 1, 0, NULL ); + if (yeah.fraction < 1) { + visible = 0; return; - } - else - { - visible = 1; - } } + else { + visible = 1; + } + } // leilei - delay hack, to speed up the renderer - if (backEnd.refdef.time > f->delay){ - + if (backEnd.refdef.time > f->delay) { + // read back the z buffer contents qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); f->delay = backEnd.refdef.time + r_flareDelay->value; - - - screenZ = backEnd.viewParms.projectionMatrix[14] / - ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); - - visible = ( -f->eyeZ - -screenZ ) < 24; - - + + screenZ = backEnd.viewParms.projectionMatrix[14] / + ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); + + visible = ( -f->eyeZ - -screenZ ) < 24; + + + if ( visible ) { if ( !f->visible ) { f->visible = qtrue; f->fadeTime = backEnd.refdef.time - 1; - + } { fade = ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; } - } else { + } + else { if ( f->visible ) { f->visible = qfalse; f->fadeTime = backEnd.refdef.time - 1; } fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; } - + if ( fade < 0 ) { fade = 0; } if ( fade > 1 ) { fade = 1; } - + f->drawIntensity = fade; - + } else - // leilei - continue drawing the flare from where we last checked + // leilei - continue drawing the flare from where we last checked { if (f->visible) { f->drawIntensity = 1; } - else - { + else { f->drawIntensity = 0; } } - + } /* @@ -450,126 +451,126 @@ static void RB_TestFlareFast( flare_t *f, int dotrace ) { RB_TestFlare ================== */ -static void RB_TestFlare( flare_t *f, int dotrace ) { +static void RB_TestFlare( flare_t *f, int dotrace ) +{ float depth; qboolean visible; float fade; float screenZ; - backEnd.pc.c_flareTests++; - - - // doing a readpixels is as good as doing a glFinish(), so - // don't bother with another sync - glState.finishCalled = qfalse; - + backEnd.pc.c_flareTests++; - if (f->type == 2) dotrace = 0; // sun cant trace - // leilei - do trace, then complain - if (dotrace){ - trace_t yeah; - CM_Trace( &yeah, f->origin, backEnd.or.viewOrigin, NULL, NULL, NULL, f->origin, 1, NULL, NULL ); - if (yeah.fraction < 1){ - visible = 0; + + // doing a readpixels is as good as doing a glFinish(), so + // don't bother with another sync + glState.finishCalled = qfalse; + + + if (f->type == 2) dotrace = 0; // sun cant trace + // leilei - do trace, then complain + if (dotrace) { + trace_t yeah; + CM_Trace( &yeah, f->origin, backEnd.or.viewOrigin, NULL, NULL, 0, f->origin, 1, 0, NULL ); + if (yeah.fraction < 1) { + visible = 0; return; - } - else - { + } + else { visible = 1; - } } + } - // read back the z buffer contents + // read back the z buffer contents - qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); - - - screenZ = backEnd.viewParms.projectionMatrix[14] / - ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); - - visible = ( -f->eyeZ - -screenZ ) < 24; - + qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); + + + screenZ = backEnd.viewParms.projectionMatrix[14] / + ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); + + visible = ( -f->eyeZ - -screenZ ) < 24; + + + + if ( visible ) { + if ( !f->visible ) { + f->visible = qtrue; + f->fadeTime = backEnd.refdef.time - 1; - - if ( visible ) { - if ( !f->visible ) { - f->visible = qtrue; - f->fadeTime = backEnd.refdef.time - 1; - - } - { - fade = ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; - } - } else { - if ( f->visible ) { - f->visible = qfalse; - f->fadeTime = backEnd.refdef.time - 1; - } - fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; } - - if ( fade < 0 ) { - fade = 0; + { + fade = ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; } - if ( fade > 1 ) { - fade = 1; + } + else { + if ( f->visible ) { + f->visible = qfalse; + f->fadeTime = backEnd.refdef.time - 1; } - - f->drawIntensity = fade; - + fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; + } + + if ( fade < 0 ) { + fade = 0; + } + if ( fade > 1 ) { + fade = 1; + } + + f->drawIntensity = fade; + } -static void RB_TestFlareTraceOnly( flare_t *f ) { - float depth; +static void RB_TestFlareTraceOnly( flare_t *f ) +{ qboolean visible; float fade; - float screenZ; - backEnd.pc.c_flareTests++; - - - // doing a readpixels is as good as doing a glFinish(), so - // don't bother with another sync - glState.finishCalled = qfalse; + backEnd.pc.c_flareTests++; - // read from a traceline - trace_t yeah; - CM_Trace( &yeah, f->origin, backEnd.or.viewOrigin, NULL, NULL, NULL, f->origin, 1, NULL, NULL ); - if (yeah.fraction < 1){ - visible = 0; + + // doing a readpixels is as good as doing a glFinish(), so + // don't bother with another sync + glState.finishCalled = qfalse; + + // read from a traceline + trace_t yeah; + CM_Trace( &yeah, f->origin, backEnd.or.viewOrigin, NULL, NULL, 0, f->origin, 1, 0, NULL ); + if (yeah.fraction < 1) { + visible = 0; return; - } - else - { + } + else { visible = 1; + } + + if ( visible ) { + if ( !f->visible ) { + f->visible = qtrue; + f->fadeTime = backEnd.refdef.time - 1; + } - - if ( visible ) { - if ( !f->visible ) { - f->visible = qtrue; - f->fadeTime = backEnd.refdef.time - 1; - - } - { - fade = ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; - } - } else { - if ( f->visible ) { - f->visible = qfalse; - f->fadeTime = backEnd.refdef.time - 1; - } - fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; + { + fade = ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; } - - if ( fade < 0 ) { - fade = 0; + } + else { + if ( f->visible ) { + f->visible = qfalse; + f->fadeTime = backEnd.refdef.time - 1; } - if ( fade > 1 ) { - fade = 1; - } - - f->drawIntensity = fade; - + fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; + } + + if ( fade < 0 ) { + fade = 0; + } + if ( fade > 1 ) { + fade = 1; + } + + f->drawIntensity = fade; + } @@ -580,7 +581,8 @@ RB_RenderFlare ================== */ -void RB_RenderFlare( flare_t *f ) { +void RB_RenderFlare( flare_t *f ) +{ float size; vec3_t color; int iColor[3]; @@ -599,14 +601,13 @@ void RB_RenderFlare( flare_t *f ) { else distance = -f->eyeZ; - if ( (r_flaresDlightShrink->integer) && (f->type == 1) ) // leilei - dynamic light flares shrinking when close - { + if ( (r_flaresDlightShrink->integer) && (f->type == 1) ) { // leilei - dynamic light flares shrinking when close float newd = distance / (48.0f); if (newd > 1) newd = 1.0f; flaredsize *= newd; - } + } if(!f->radius) @@ -614,21 +615,21 @@ void RB_RenderFlare( flare_t *f ) { // calculate the flare size.. -/* - * This is an alternative to intensity scaling. It changes the size of the flare on screen instead - * with growing distance. See in the description at the top why this is not the way to go. -*/ + /* + * This is an alternative to intensity scaling. It changes the size of the flare on screen instead + * with growing distance. See in the description at the top why this is not the way to go. + */ // size will change ~ 1/r. - if (r_flareMethod->integer == 1 || r_flareMethod->integer == 4 ){ // The "not the way to go" method. - // seen in EF + if (r_flareMethod->integer == 1 || r_flareMethod->integer == 4 ) { // The "not the way to go" method. + // seen in EF size = flaredsize * (r_flareSize->value / (distance * -2.0f)); } - else if (r_flareMethod->integer == 2){ // Raven method - size = flaredsize * ( r_flareSize->value/640.0f + 8 / -f->eyeZ ); } - else - { + else if (r_flareMethod->integer == 2) { // Raven method + size = flaredsize * ( r_flareSize->value/640.0f + 8 / -f->eyeZ ); + } + else { - size = flaredsize * ( (r_flareSize->value) /640.0f + 8 / distance ); + size = flaredsize * ( (r_flareSize->value) /640.0f + 8 / distance ); @@ -638,54 +639,52 @@ void RB_RenderFlare( flare_t *f ) { -/* - * As flare sizes stay nearly constant with increasing distance we must decrease the intensity - * to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be - * got by considering the ratio of - * (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare) - * An important requirement is: - * intensity <= 1 for all distances. - * - * The formula used here to compute the intensity is as follows: - * intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2 - * As you can see, the intensity will have a max. of 1 when the distance is 0. - * The coefficient flareCoeff will determine the falloff speed with increasing distance. - */ + /* + * As flare sizes stay nearly constant with increasing distance we must decrease the intensity + * to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be + * got by considering the ratio of + * (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare) + * An important requirement is: + * intensity <= 1 for all distances. + * + * The formula used here to compute the intensity is as follows: + * intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2 + * As you can see, the intensity will have a max. of 1 when the distance is 0. + * The coefficient flareCoeff will determine the falloff speed with increasing distance. + */ factor = distance + size * sqrt(flareCoeff); - + if (r_flareMethod->integer == 4) // leilei - EF didn't scale intensity on distance. Speed I guess - intensity = 1; + intensity = 1; else - intensity = flareCoeff * size * size / (factor * factor); + intensity = flareCoeff * size * size / (factor * factor); - if (r_flareMethod->integer == 1) // leilei - stupid hack to fix the not the way method - { + if (r_flareMethod->integer == 1) { // leilei - stupid hack to fix the not the way method if (intensity > 1) intensity = 1; - } + } - if (pvrhack) - VectorScale(f->color, 1, color ); + if (pvrhack) + VectorScale(f->color, 1, color ); else - VectorScale(f->color, f->drawIntensity * intensity, color); + VectorScale(f->color, f->drawIntensity * intensity, color); + - // Calculations for fogging - if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs) - { + if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs) { tess.numVertexes = 1; VectorCopy(f->origin, tess.xyz[0]); tess.fogNum = f->fogNum; - + RB_CalcModulateColorsByFog(fogFactors); - + // We don't need to render the flare if colors are 0 anyways. if(!(fogFactors[0] || fogFactors[1] || fogFactors[2])) return; @@ -697,37 +696,34 @@ void RB_RenderFlare( flare_t *f ) { iColor[1] = color[1] * fogFactors[1]; iColor[2] = color[2] * fogFactors[2]; if (pvrhack) - alphcal = f->drawIntensity * tr.identityLight * 255; // Calculate alphas from intensity instead + alphcal = f->drawIntensity * tr.identityLight * 255; // Calculate alphas from intensity instead else - alphcal = 255; // Don't mess with alpha. + alphcal = 255; // Don't mess with alpha. + - float halfer = 1; - if (f->ftype == 5 || f->ftype == 6 || f->ftype == 7 || f->ftype == 166){ - RB_BeginSurface( tr.flareShaderAtlas, f->fogNum ); + if (f->ftype == 5 || f->ftype == 6 || f->ftype == 7 || f->ftype == 166) { + RB_BeginSurface( tr.flareShaderAtlas, f->fogNum ); halfer = 0.5f; - } - else - { + } + else { - if (r_flareQuality->integer) // leilei - high quality flares get no depth testing - { + if (r_flareQuality->integer) { // leilei - high quality flares get no depth testing int index; - - for(index = 0; index theshader->numUnfoggedPasses; index++) - { + + for(index = 0; index theshader->numUnfoggedPasses; index++) { f->theshader->stages[index]->adjustColorsForFog = ACFF_NONE; f->theshader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; } } - RB_BeginSurface( f->theshader, f->fogNum ); + RB_BeginSurface( f->theshader, f->fogNum ); + - halfer = 1; } @@ -771,22 +767,22 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = iColor[2]; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.indexes[tess.numIndexes++] = 0; tess.indexes[tess.numIndexes++] = 1; tess.indexes[tess.numIndexes++] = 2; tess.indexes[tess.numIndexes++] = 0; tess.indexes[tess.numIndexes++] = 2; tess.indexes[tess.numIndexes++] = 3; - + ind+=4; - + // reflections -- tcpparena - - if(f->ftype == 2 || f->ftype == 4){ - + + if(f->ftype == 2 || f->ftype == 4) { + // renders sharp lens flare. - + float cx, cy; float dx, dy; float size2; @@ -799,15 +795,15 @@ void RB_RenderFlare( flare_t *f ) { int n; cx=backEnd.viewParms.viewportX+(backEnd.viewParms.viewportWidth>>1); cy=backEnd.viewParms.viewportY+(backEnd.viewParms.viewportHeight>>1); - for(n=0;n<5;n++){ + for(n=0; n<5; n++) { dx=(f->windowX-cx)*poses[n]+cx; dy=(f->windowY-cy)*poses[n]+cy; size2=sizes[n]*backEnd.viewParms.viewportWidth*.25f; - + brightness1[n]=(int)(brightness1[n]*r_lensReflectionBrightness->value); brightness2[n]=(int)(brightness2[n]*r_lensReflectionBrightness->value); brightness3[n]=(int)(brightness3[n]*r_lensReflectionBrightness->value); - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy; tess.texCoords[tess.numVertexes][0][0] = .5f; @@ -817,7 +813,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = 255; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx-size2*.5f; tess.xyz[tess.numVertexes][1] = dy-size2*r3_2; tess.texCoords[tess.numVertexes][0][0] = .5f; @@ -827,7 +823,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = 255; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2*.5f; tess.xyz[tess.numVertexes][1] = dy-size2*r3_2; tess.texCoords[tess.numVertexes][0][0] = .5f; @@ -837,7 +833,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = 255; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy; tess.texCoords[tess.numVertexes][0][0] = .5f; @@ -847,7 +843,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = 255; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2*.5f; tess.xyz[tess.numVertexes][1] = dy+size2*r3_2; tess.texCoords[tess.numVertexes][0][0] = .5f; @@ -857,7 +853,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = 255; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx-size2*.5f; tess.xyz[tess.numVertexes][1] = dy+size2*r3_2; tess.texCoords[tess.numVertexes][0][0] = .5f; @@ -867,7 +863,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = 255; tess.numVertexes++; - + tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 1+ind; tess.indexes[tess.numIndexes++] = 0+ind; @@ -880,18 +876,18 @@ void RB_RenderFlare( flare_t *f ) { tess.indexes[tess.numIndexes++] = 5+ind; tess.indexes[tess.numIndexes++] = 4+ind; tess.indexes[tess.numIndexes++] = 0+ind; - + ind+=6; - + } } - if(f->ftype == 3 || f->ftype == 4){ - + if(f->ftype == 3 || f->ftype == 4) { + // renders fuzzy lens flare. - + float cx, cy; float dx, dy; float size2; @@ -903,17 +899,17 @@ void RB_RenderFlare( flare_t *f ) { int n; cx=backEnd.viewParms.viewportX+(backEnd.viewParms.viewportWidth>>1); cy=backEnd.viewParms.viewportY+(backEnd.viewParms.viewportHeight>>1); - - - for(n=0;n<2;n++){ + + + for(n=0; n<2; n++) { dx=(f->windowX-cx)*poses[n]+cx; dy=(f->windowY-cy)*poses[n]+cy; size2=sizes[n]*flaredsize2*.25f; - + brightness1[n]=(int)(brightness1[n]*r_lensReflectionBrightness->value); brightness2[n]=(int)(brightness2[n]*r_lensReflectionBrightness->value); brightness3[n]=(int)(brightness3[n]*r_lensReflectionBrightness->value); - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy-size2; tess.texCoords[tess.numVertexes][0][0] = 0.f; @@ -923,7 +919,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy+size2; tess.texCoords[tess.numVertexes][0][0] = 0.f; @@ -933,7 +929,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy+size2; tess.texCoords[tess.numVertexes][0][0] = 1.f; @@ -943,7 +939,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy-size2; tess.texCoords[tess.numVertexes][0][0] = 1.f; @@ -953,25 +949,25 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.indexes[tess.numIndexes++] = 0+ind; tess.indexes[tess.numIndexes++] = 1+ind; tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 0+ind; tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 3+ind; - + ind+=4; - - + + } } - float drak; + float drak; - if(f->ftype == 5 || f->ftype == 6 || f->ftype == 7 || f->ftype == 166){ - - // renders special atlas lens flare like fuzzy but not fuzzy + if(f->ftype == 5 || f->ftype == 6 || f->ftype == 7 || f->ftype == 166) { + + // renders special atlas lens flare like fuzzy but not fuzzy int modess; if (f->ftype == 6) modess = 1; // mono rings else if (f->ftype == 7 || f->ftype == 166) modess = 2; // force normal colored rings @@ -981,69 +977,83 @@ void RB_RenderFlare( flare_t *f ) { float size2; float poses[]= {-1.0f, -0.75f, -0.64f, -0.57f, -0.37f, -0.35f, -0.3f, 1.2f, -.21f, 0.15f, .38f, .56f, .52f, 0.6f, 1.2f, 1.37f}; float sizes[]= {1.15f, 0.7f, 0.2f, 0.35f, 0.24f, .86f, .357f, 2.3f, 0.15f, 0.09f, 0.21f, 0.7f, 0.37f, 0.23f, 0.3f, 1.2f}; - float atlases[]={4, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2, 7, 8, 2, 3, 2}; + float atlases[]= {4, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2, 7, 8, 2, 3, 2}; float downsize1 = 0.25f; float downsize2 = 0.25f; - int brightness1[]= {16, 5, 6, 18, 18, 38, 18, 12, 24, 24, 18, 3, 3, 0, 12, 12}; - int brightness2[]= {16, 32, 8, 17, 17, 37, 17, 11, 28, 28, 17, 3, 3, 0, 12, 10}; - int brightness3[]= {27, 3, 24, 0, 0, 17, 0, 4, 28, 28, 0, 17, 12, 12, 10, 10}; + int brightness1[]= {16, 5, 6, 18, 18, 38, 18, 12, 24, 24, 18, 3, 3, 0, 12, 12}; + int brightness2[]= {16, 32, 8, 17, 17, 37, 17, 11, 28, 28, 17, 3, 3, 0, 12, 10}; + int brightness3[]= {27, 3, 24, 0, 0, 17, 0, 4, 28, 28, 0, 17, 12, 12, 10, 10}; int n; vec3_t colarz; cx=backEnd.viewParms.viewportX+(backEnd.viewParms.viewportWidth>>1); cy=backEnd.viewParms.viewportY+(backEnd.viewParms.viewportHeight>>1); - - - for(n=0;n<16;n++){ + + + for(n=0; n<16; n++) { dx=(f->windowX-cx)*poses[n]+cx; dy=(f->windowY-cy)*poses[n]+cy; size2=sizes[n]*flaredsize2*.25f; drak = f->radius * 0.07; - if (atlases[n] == 1){ downsize1 = 1; downsize2 = 1; }; - if (atlases[n] == 3){ downsize1 = 1; downsize2 = -1; }; - if (atlases[n] == 4){ downsize1 = -1; downsize2 = -1; }; - if (atlases[n] == 2){ downsize1 = -1; downsize2 = 1; }; - + if (atlases[n] == 1) { + downsize1 = 1; + downsize2 = 1; + }; + if (atlases[n] == 3) { + downsize1 = 1; + downsize2 = -1; + }; + if (atlases[n] == 4) { + downsize1 = -1; + downsize2 = -1; + }; + if (atlases[n] == 2) { + downsize1 = -1; + downsize2 = 1; + }; - if (modess == 1){ - brightness1[n] = brightness1[n] + brightness2[n] + brightness3[n] * 0.0100; - brightness2[n] = brightness1[n]; brightness3[n] = brightness1[n]; + + if (modess == 1) { + brightness1[n] = brightness1[n] + brightness2[n] + brightness3[n] * 0.0100; + brightness2[n] = brightness1[n]; + brightness3[n] = brightness1[n]; } brightness1[n]=(int)(brightness1[n]*r_lensReflectionBrightness->value) * drak; brightness2[n]=(int)(brightness2[n]*r_lensReflectionBrightness->value) * drak; brightness3[n]=(int)(brightness3[n]*r_lensReflectionBrightness->value) * drak; - if (modess == 2){ - iColor[0] = 32.0f; iColor[1] = 32.0f; iColor[2] = 32.0f; + if (modess == 2) { + iColor[0] = 32.0f; + iColor[1] = 32.0f; + iColor[2] = 32.0f; } - if (pvrhack){ - if (modess == 2){ - colarz[0] = ceil(iColor[0]*brightness1[n]); - colarz[1] = ceil(iColor[1]*brightness2[n]); - colarz[2] = ceil(iColor[2]*brightness3[n]); - } - else - { - colarz[0] = ceil(iColor[0]); - colarz[1] = ceil(iColor[1]); - colarz[2] = ceil(iColor[2]); - } + if (pvrhack) { + if (modess == 2) { + colarz[0] = ceil(iColor[0]*brightness1[n]); + colarz[1] = ceil(iColor[1]*brightness2[n]); + colarz[2] = ceil(iColor[2]*brightness3[n]); + } + else { + colarz[0] = ceil(iColor[0]); + colarz[1] = ceil(iColor[1]); + colarz[2] = ceil(iColor[2]); + } - alphcal=r_lensReflectionBrightness->value * drak * 56; + alphcal=r_lensReflectionBrightness->value * drak * 56; } else { - colarz[0] = (iColor[0]*brightness1[n])>>8; - colarz[1] = (iColor[1]*brightness2[n])>>8; - colarz[2] = (iColor[2]*brightness3[n])>>8; + colarz[0] = (iColor[0]*brightness1[n])>>8; + colarz[1] = (iColor[1]*brightness2[n])>>8; + colarz[2] = (iColor[2]*brightness3[n])>>8; } - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy-size2; tess.texCoords[tess.numVertexes][0][0] = 0.f; @@ -1053,7 +1063,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = colarz[2]; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy+size2; tess.texCoords[tess.numVertexes][0][0] = 0.f; @@ -1063,7 +1073,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = colarz[2]; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy+size2; tess.texCoords[tess.numVertexes][0][0] = 0.5f * downsize1; @@ -1073,7 +1083,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = colarz[2]; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy-size2; tess.texCoords[tess.numVertexes][0][0] = 0.5f * downsize1; @@ -1083,25 +1093,25 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = colarz[2]; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - - + + tess.indexes[tess.numIndexes++] = 0+ind; tess.indexes[tess.numIndexes++] = 1+ind; tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 0+ind; tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 3+ind; - + ind+=4; - - + + } } - if(f->ftype == 8 ){ - + if(f->ftype == 8 ) { + // renders anamorphic flare - // JUST LIKE TEH MOVEEZ!!!!!!!!! + // JUST LIKE TEH MOVEEZ!!!!!!!!! float cx, cy; float dx, dy; float size2; @@ -1115,18 +1125,18 @@ void RB_RenderFlare( flare_t *f ) { int n; cx=backEnd.viewParms.viewportX+(backEnd.viewParms.viewportWidth>>1); cy=backEnd.viewParms.viewportY+(backEnd.viewParms.viewportHeight>>1); - - drak = f->radius * 0.02; - for(n=0;n<3;n++){ + + drak = f->radius * 0.02; + for(n=0; n<3; n++) { dx=(f->windowX-cx)*poses[n]+cx; dy=(f->windowY-cy)*poses[n]+cy; size2=sizes[n]*flaredsize2 * drak*.25f; size3=sizes2[n]*flaredsize2 * (drak) *.25f; - + brightness1[n]=(int)(brightness1[n]*6 *r_lensReflectionBrightness->value); brightness2[n]=(int)(brightness2[n]*6 *r_lensReflectionBrightness->value); brightness3[n]=(int)(brightness3[n]*6 *r_lensReflectionBrightness->value); - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy-size3; tess.texCoords[tess.numVertexes][0][0] = 0.f; @@ -1136,7 +1146,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx-size2; tess.xyz[tess.numVertexes][1] = dy+size3; tess.texCoords[tess.numVertexes][0][0] = 0.f; @@ -1146,7 +1156,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy+size3; tess.texCoords[tess.numVertexes][0][0] = 1.f; @@ -1156,7 +1166,7 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.xyz[tess.numVertexes][0] = dx+size2; tess.xyz[tess.numVertexes][1] = dy-size3; tess.texCoords[tess.numVertexes][0][0] = 1.f; @@ -1166,17 +1176,17 @@ void RB_RenderFlare( flare_t *f ) { tess.vertexColors[tess.numVertexes][2] = (iColor[2]*brightness3[n])>>8; tess.vertexColors[tess.numVertexes][3] = alphcal; tess.numVertexes++; - + tess.indexes[tess.numIndexes++] = 0+ind; tess.indexes[tess.numIndexes++] = 1+ind; tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 0+ind; tess.indexes[tess.numIndexes++] = 2+ind; tess.indexes[tess.numIndexes++] = 3+ind; - + ind+=4; - - + + } } RB_EndSurface(); @@ -1200,7 +1210,8 @@ when occluded by something in the main view, and portal flares that should extend past the portal edge will be overwritten. ================== */ -void RB_RenderFlares (void) { +void RB_RenderFlares (void) +{ flare_t *f; flare_t **prev; qboolean draw; @@ -1210,11 +1221,10 @@ void RB_RenderFlares (void) { } if ( (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) return; // leilei - don't draw flares in the UI. this prevents - // a very very very very nasty error relating to the trace checks - // leading to recursive startup in te OA3 menu + // a very very very very nasty error relating to the trace checks + // leading to recursive startup in te OA3 menu - if(r_flareCoeff->modified) - { + if(r_flareCoeff->modified) { R_SetFlareCoeff(); r_flareCoeff->modified = qfalse; } @@ -1242,23 +1252,24 @@ void RB_RenderFlares (void) { // don't draw any here that aren't from this scene / portal f->drawIntensity = 0; if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum - && f->inPortal == backEnd.viewParms.isPortal ) { - if (r_flareQuality->integer > 4) // highest flare quality - only frequent readpixels, no trace - RB_TestFlare( f, 0 ); - else if (r_flareQuality->integer == 4) // high flare quality - frequent readpixels, trace - RB_TestFlare( f, 1 ); - else if (r_flareQuality->integer == 3) // medium flare quality - delayed readpixels, no trace (faster for some cpus than 2) - RB_TestFlareFast( f, 0 ); - else if (r_flareQuality->integer == 2) // low flare quality - delayed readpixels, trace - RB_TestFlareFast( f, 1 ); - else if (r_flareQuality->integer == 1) // lower flare quality - no readpixels, trace - RB_TestFlareTraceOnly( f ); - else - RB_TestFlareFast( f, 1 ); // lowest is actually a different surface flare defined elsewhere + && f->inPortal == backEnd.viewParms.isPortal ) { + if (r_flareQuality->integer > 4) // highest flare quality - only frequent readpixels, no trace + RB_TestFlare( f, 0 ); + else if (r_flareQuality->integer == 4) // high flare quality - frequent readpixels, trace + RB_TestFlare( f, 1 ); + else if (r_flareQuality->integer == 3) // medium flare quality - delayed readpixels, no trace (faster for some cpus than 2) + RB_TestFlareFast( f, 0 ); + else if (r_flareQuality->integer == 2) // low flare quality - delayed readpixels, trace + RB_TestFlareFast( f, 1 ); + else if (r_flareQuality->integer == 1) // lower flare quality - no readpixels, trace + RB_TestFlareTraceOnly( f ); + else + RB_TestFlareFast( f, 1 ); // lowest is actually a different surface flare defined elsewhere if ( f->drawIntensity ) { draw = qtrue; - } else { + } + else { // this flare has completely faded out, so remove it from the chain *prev = f->next; f->next = r_inactiveFlares; @@ -1279,18 +1290,18 @@ void RB_RenderFlares (void) { } qglPushMatrix(); - qglLoadIdentity(); + qglLoadIdentity(); qglMatrixMode( GL_PROJECTION ); qglPushMatrix(); - qglLoadIdentity(); + qglLoadIdentity(); qglOrtho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth, - backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, - -99999, 99999 ); + backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, + -99999, 99999 ); for ( f = r_activeFlares ; f ; f = f->next ) { if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum - && f->inPortal == backEnd.viewParms.isPortal - && f->drawIntensity ) { + && f->inPortal == backEnd.viewParms.isPortal + && f->drawIntensity ) { RB_RenderFlare( f ); } } @@ -1302,7 +1313,8 @@ void RB_RenderFlares (void) { -void RB_DrawSunFlare( void ) { +void RB_DrawSunFlare( void ) +{ float size; float dist; vec3_t origin, vec1, vec2; @@ -1354,8 +1366,8 @@ void RB_DrawSunFlare( void ) { int g; - for (g=0;g<3;g++) - if (coll[g] > 1) coll[g] = 1; + for (g=0; g<3; g++) + if (coll[g] > 1) coll[g] = 1; VectorCopy( origin, temp ); VectorSubtract( temp, vec1, temp ); diff --git a/code/renderer_oa/tr_init.c b/code/renderer_oa/tr_init.c index c9f34e9b..7a436b96 100644 --- a/code/renderer_oa/tr_init.c +++ b/code/renderer_oa/tr_init.c @@ -193,10 +193,10 @@ cvar_t *r_lensReflectionBrightness; // leilei cvar_t *r_flareMethod; // method of flare intensity -cvar_t *r_flareQuality; // testing quality of the flares. +cvar_t *r_flareQuality; // testing quality of the flares. cvar_t *r_flareSun; // type of flare to use for the sun -cvar_t *r_flareDelay; // time delay for medium quality flare testing -cvar_t *r_flaresMotionBlur; // Stretch blur +cvar_t *r_flareDelay; // time delay for medium quality flare testing +cvar_t *r_flaresMotionBlur; // Stretch blur cvar_t *r_specMode; //cvar_t *r_waveMode; @@ -210,7 +210,7 @@ cvar_t *r_alternateBrightness; // leilei - linux overbright fix cvar_t *r_mockvr; // Leilei - for debugging PVR only! cvar_t *r_parseStageSimple; // Leilei - for debugging PVR only! cvar_t *r_leifx; // Leilei - leifx nostalgia filter -cvar_t *r_modelshader; // Leilei +cvar_t *r_modelshader; // Leilei cvar_t *r_particles; // Leilei - particle effects motif cvar_t *r_ntsc; // Leilei - ntsc / composite signals @@ -284,11 +284,10 @@ static void InitOpenGL( void ) // - r_ignorehwgamma // - r_gamma // - - if ( glConfig.vidWidth == 0 ) - { + + if ( glConfig.vidWidth == 0 ) { GLint temp; - + GLimp_Init(); GLimp_InitExtraExtensions(); @@ -300,8 +299,7 @@ static void InitOpenGL( void ) glConfig.maxTextureSize = temp; // stubbed or broken drivers may have reported 0... - if ( glConfig.maxTextureSize <= 0 ) - { + if ( glConfig.maxTextureSize <= 0 ) { glConfig.maxTextureSize = 0; } } @@ -315,7 +313,8 @@ static void InitOpenGL( void ) GL_CheckErrors ================== */ -void GL_CheckErrors( void ) { +void GL_CheckErrors( void ) +{ int err; char s[64]; @@ -327,27 +326,27 @@ void GL_CheckErrors( void ) { return; } switch( err ) { - case GL_INVALID_ENUM: - strcpy( s, "GL_INVALID_ENUM" ); - break; - case GL_INVALID_VALUE: - strcpy( s, "GL_INVALID_VALUE" ); - break; - case GL_INVALID_OPERATION: - strcpy( s, "GL_INVALID_OPERATION" ); - break; - case GL_STACK_OVERFLOW: - strcpy( s, "GL_STACK_OVERFLOW" ); - break; - case GL_STACK_UNDERFLOW: - strcpy( s, "GL_STACK_UNDERFLOW" ); - break; - case GL_OUT_OF_MEMORY: - strcpy( s, "GL_OUT_OF_MEMORY" ); - break; - default: - Com_sprintf( s, sizeof(s), "%i", err); - break; + case GL_INVALID_ENUM: + strcpy( s, "GL_INVALID_ENUM" ); + break; + case GL_INVALID_VALUE: + strcpy( s, "GL_INVALID_VALUE" ); + break; + case GL_INVALID_OPERATION: + strcpy( s, "GL_INVALID_OPERATION" ); + break; + case GL_STACK_OVERFLOW: + strcpy( s, "GL_STACK_OVERFLOW" ); + break; + case GL_STACK_UNDERFLOW: + strcpy( s, "GL_STACK_UNDERFLOW" ); + break; + case GL_OUT_OF_MEMORY: + strcpy( s, "GL_OUT_OF_MEMORY" ); + break; + default: + Com_sprintf( s, sizeof(s), "%i", err); + break; } ri.Error( ERR_FATAL, "GL_CheckErrors: %s", s ); @@ -357,15 +356,13 @@ void GL_CheckErrors( void ) { /* ** R_GetModeInfo */ -typedef struct vidmode_s -{ +typedef struct vidmode_s { const char *description; int width, height; float pixelAspect; // pixel width / height } vidmode_t; -vidmode_t r_vidModes[] = -{ +vidmode_t r_vidModes[] = { { "Mode 0: 320x240", 320, 240, 1 }, { "Mode 1: 400x300", 400, 300, 1 }, { "Mode 2: 512x384", 512, 384, 1 }, @@ -397,7 +394,8 @@ vidmode_t r_vidModes[] = }; static int s_numVidModes = ARRAY_LEN( r_vidModes ); -qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) { +qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) +{ vidmode_t *vm; float pixelAspect; @@ -412,7 +410,8 @@ qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) *width = r_customwidth->integer; *height = r_customheight->integer; pixelAspect = r_customPixelAspect->value; - } else { + } + else { vm = &r_vidModes[mode]; *width = vm->width; @@ -433,18 +432,17 @@ static void R_ModeList_f( void ) int i; ri.Printf( PRINT_ALL, "\n" ); - for ( i = 0; i < s_numVidModes; i++ ) - { + for ( i = 0; i < s_numVidModes; i++ ) { ri.Printf( PRINT_ALL, "%s\n", r_vidModes[i].description ); } ri.Printf( PRINT_ALL, "\n" ); } -/* -============================================================================== - - SCREEN SHOTS +/* +============================================================================== + + SCREEN SHOTS NOTE TTimo some thoughts about the screenshots system: @@ -457,11 +455,11 @@ we use statics to store a count and start writing the first screenshot/screensho (with FS_FileExists / FS_FOpenFileWrite calls) FIXME: the statics don't get a reinit between fs_game changes -============================================================================== -*/ +============================================================================== +*/ -/* -================== +/* +================== RB_ReadPixels Reads an image but takes care of alignment issues for reading RGB images. @@ -474,50 +472,50 @@ alignment of packAlign to ensure efficient copying. Stores the length of padding after a line of pixels to address padlen Return value must be freed with ri.Hunk_FreeTempMemory() -================== -*/ +================== +*/ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *padlen) { byte *buffer, *bufstart; int padwidth, linelen; GLint packAlign; - + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); - + linelen = width * 3; padwidth = PAD(linelen, packAlign); - + // Allocate a few more bytes so that we can choose an alignment we like buffer = ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); - + bufstart = PADP((intptr_t) buffer + *offset, packAlign); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); - + *offset = bufstart - buffer; *padlen = padwidth - linelen; - + return buffer; } -/* -================== +/* +================== RB_TakeScreenshot -================== -*/ +================== +*/ void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) { byte *allbuf, *buffer; byte *srcptr, *destptr; byte *endline, *endmem; byte temp; - + int linelen, padlen; size_t offset = 18, memcount; - + allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen); buffer = allbuf + offset - 18; - + Com_Memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type buffer[12] = width & 255; @@ -528,24 +526,22 @@ void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) // swap rgb to bgr and remove padding from line endings linelen = width * 3; - + srcptr = destptr = allbuf + offset; endmem = srcptr + (linelen + padlen) * height; - - while(srcptr < endmem) - { + + while(srcptr < endmem) { endline = srcptr + linelen; - while(srcptr < endline) - { + while(srcptr < endline) { temp = srcptr[0]; *destptr++ = srcptr[2]; *destptr++ = srcptr[1]; *destptr++ = temp; - + srcptr += 3; } - + // Skip the pad srcptr += padlen; } @@ -562,10 +558,10 @@ void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) ri.Hunk_FreeTempMemory(allbuf); } -/* -================== +/* +================== RB_TakeScreenshotJPEG -================== +================== */ void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) @@ -594,26 +590,27 @@ RB_TakeScreenshotCmd extern int tvWidth; extern int tvHeight; -const void *RB_TakeScreenshotCmd( const void *data ) { +const void *RB_TakeScreenshotCmd( const void *data ) +{ const screenshotCommand_t *cmd; - - cmd = (const screenshotCommand_t *)data; - - // leilei - hack for tvmode - if (r_tvMode->integer > -1){ - if (cmd->jpeg) - RB_TakeScreenshotJPEG( cmd->x, cmd->y, tvWidth, tvHeight, cmd->fileName); - else - RB_TakeScreenshot( cmd->x, cmd->y, tvWidth, tvHeight, cmd->fileName); - } + cmd = (const screenshotCommand_t *)data; + + // leilei - hack for tvmode + if (r_tvMode->integer > -1) { + + if (cmd->jpeg) + RB_TakeScreenshotJPEG( cmd->x, cmd->y, tvWidth, tvHeight, cmd->fileName); + else + RB_TakeScreenshot( cmd->x, cmd->y, tvWidth, tvHeight, cmd->fileName); + } if (cmd->jpeg) RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); else RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); - - return (const void *)(cmd + 1); + + return (const void *)(cmd + 1); } /* @@ -621,7 +618,8 @@ const void *RB_TakeScreenshotCmd( const void *data ) { R_TakeScreenshot ================== */ -void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean jpeg ) { +void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean jpeg ) +{ static char fileName[MAX_OSPATH]; // bad things if two screenshots per frame? screenshotCommand_t *cmd; @@ -640,12 +638,13 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean cmd->jpeg = jpeg; } -/* -================== +/* +================== R_ScreenshotFilename -================== -*/ -void R_ScreenshotFilename( int lastNumber, char *fileName ) { +================== +*/ +void R_ScreenshotFilename( int lastNumber, char *fileName ) +{ int a,b,c,d; if ( lastNumber < 0 || lastNumber > 9999 ) { @@ -662,15 +661,16 @@ void R_ScreenshotFilename( int lastNumber, char *fileName ) { d = lastNumber; Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.tga" - , a, b, c, d ); + , a, b, c, d ); } -/* -================== +/* +================== R_ScreenshotFilename -================== -*/ -void R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) { +================== +*/ +void R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) +{ int a,b,c,d; if ( lastNumber < 0 || lastNumber > 9999 ) { @@ -687,7 +687,7 @@ void R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) { d = lastNumber; Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.jpg" - , a, b, c, d ); + , a, b, c, d ); } /* @@ -698,7 +698,8 @@ levelshots are specialized 128*128 thumbnails for the menu system, sampled down from full screen distorted images ==================== */ -void R_LevelShot( void ) { +void R_LevelShot( void ) +{ char checkname[MAX_OSPATH]; byte *buffer; byte *source, *allsource; @@ -731,7 +732,7 @@ void R_LevelShot( void ) { for ( yy = 0 ; yy < 3 ; yy++ ) { for ( xx = 0 ; xx < 4 ; xx++ ) { src = source + (3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) + - 3 * (int) ((x*4 + xx) * xScale); + 3 * (int) ((x*4 + xx) * xScale); r += src[0]; g += src[1]; b += src[2]; @@ -757,8 +758,8 @@ void R_LevelShot( void ) { ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); } -/* -================== +/* +================== R_ScreenShot_f screenshot @@ -767,9 +768,10 @@ screenshot [levelshot] screenshot [filename] Doesn't print the pacifier message if there is a second arg -================== -*/ -void R_ScreenShot_f (void) { +================== +*/ +void R_ScreenShot_f (void) +{ char checkname[MAX_OSPATH]; static int lastNumber = -1; qboolean silent; @@ -781,14 +783,16 @@ void R_ScreenShot_f (void) { if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { silent = qtrue; - } else { + } + else { silent = qfalse; } if ( ri.Cmd_Argc() == 2 && !silent ) { // explicit filename Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri.Cmd_Argv( 1 ) ); - } else { + } + else { // scan for a free filename // if we have saved a previous screenshot, don't scan @@ -801,16 +805,15 @@ void R_ScreenShot_f (void) { for ( ; lastNumber <= 9999 ; lastNumber++ ) { R_ScreenshotFilename( lastNumber, checkname ); - if (!ri.FS_FileExists( checkname )) - { - break; // file doesn't exist - } + if (!ri.FS_FileExists( checkname )) { + break; // file doesn't exist + } } if ( lastNumber >= 9999 ) { - ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); return; - } + } lastNumber++; } @@ -820,9 +823,10 @@ void R_ScreenShot_f (void) { if ( !silent ) { ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); } -} +} -void R_ScreenShotJPEG_f (void) { +void R_ScreenShotJPEG_f (void) +{ char checkname[MAX_OSPATH]; static int lastNumber = -1; qboolean silent; @@ -834,14 +838,16 @@ void R_ScreenShotJPEG_f (void) { if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { silent = qtrue; - } else { + } + else { silent = qfalse; } if ( ri.Cmd_Argc() == 2 && !silent ) { // explicit filename Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.Cmd_Argv( 1 ) ); - } else { + } + else { // scan for a free filename // if we have saved a previous screenshot, don't scan @@ -854,16 +860,15 @@ void R_ScreenShotJPEG_f (void) { for ( ; lastNumber <= 9999 ; lastNumber++ ) { R_ScreenshotFilenameJPEG( lastNumber, checkname ); - if (!ri.FS_FileExists( checkname )) - { - break; // file doesn't exist - } + if (!ri.FS_FileExists( checkname )) { + break; // file doesn't exist + } } if ( lastNumber == 10000 ) { - ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); return; - } + } lastNumber++; } @@ -873,7 +878,7 @@ void R_ScreenShotJPEG_f (void) { if ( !silent ) { ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); } -} +} //============================================================================ @@ -889,9 +894,9 @@ const void *RB_TakeVideoFrameCmd( const void *data ) size_t memcount, linelen; int padwidth, avipadwidth, padlen, avipadlen; GLint packAlign; - + cmd = (const videoFrameCommand_t *)data; - + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); linelen = cmd->width * 3; @@ -904,9 +909,9 @@ const void *RB_TakeVideoFrameCmd( const void *data ) avipadlen = avipadwidth - linelen; cBuf = PADP(cmd->captureBuffer, packAlign); - + qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, - GL_UNSIGNED_BYTE, cBuf); + GL_UNSIGNED_BYTE, cBuf); memcount = padwidth * cmd->height; @@ -914,44 +919,40 @@ const void *RB_TakeVideoFrameCmd( const void *data ) if(glConfig.deviceSupportsGamma) R_GammaCorrect(cBuf, memcount); - if(cmd->motionJpeg) - { + if(cmd->motionJpeg) { memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, - r_aviMotionJpegQuality->integer, - cmd->width, cmd->height, cBuf, padlen); + r_aviMotionJpegQuality->integer, + cmd->width, cmd->height, cBuf, padlen); ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); } - else - { + else { byte *lineend, *memend; byte *srcptr, *destptr; - + srcptr = cBuf; destptr = cmd->encodeBuffer; memend = srcptr + memcount; - + // swap R and B and remove line paddings - while(srcptr < memend) - { + while(srcptr < memend) { lineend = srcptr + linelen; - while(srcptr < lineend) - { + while(srcptr < lineend) { *destptr++ = srcptr[2]; *destptr++ = srcptr[1]; *destptr++ = srcptr[0]; srcptr += 3; } - + Com_Memset(destptr, '\0', avipadlen); destptr += avipadlen; - + srcptr += padlen; } - + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); } - return (const void *)(cmd + 1); + return (const void *)(cmd + 1); } //============================================================================ @@ -1008,14 +1009,14 @@ R_PrintLongString Workaround for ri.Printf's 1024 characters buffer limit. ================ */ -void R_PrintLongString(const char *string) { +void R_PrintLongString(const char *string) +{ char buffer[1024]; const char *p; int size = strlen(string); p = string; - while(size > 0) - { + while(size > 0) { Q_strncpyz(buffer, p, sizeof (buffer) ); ri.Printf( PRINT_ALL, "%s", buffer ); p += 1023; @@ -1028,15 +1029,13 @@ void R_PrintLongString(const char *string) { GfxInfo_f ================ */ -void GfxInfo_f( void ) +void GfxInfo_f( void ) { - const char *enablestrings[] = - { + const char *enablestrings[] = { "disabled", "enabled" }; - const char *fsstrings[] = - { + const char *fsstrings[] = { "windowed", "fullscreen" }; @@ -1051,20 +1050,16 @@ void GfxInfo_f( void ) ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits ); ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] ); - if ( glConfig.displayFrequency ) - { + if ( glConfig.displayFrequency ) { ri.Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); } - else - { + else { ri.Printf( PRINT_ALL, "N/A\n" ); } - if ( glConfig.deviceSupportsGamma ) - { + if ( glConfig.deviceSupportsGamma ) { ri.Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); } - else - { + else { ri.Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); } @@ -1078,17 +1073,21 @@ void GfxInfo_f( void ) if ( primitives == 0 ) { if ( qglLockArraysEXT ) { primitives = 2; - } else { + } + else { primitives = 1; } } if ( primitives == -1 ) { ri.Printf( PRINT_ALL, "none\n" ); - } else if ( primitives == 2 ) { + } + else if ( primitives == 2 ) { ri.Printf( PRINT_ALL, "single glDrawElements\n" ); - } else if ( primitives == 1 ) { + } + else if ( primitives == 1 ) { ri.Printf( PRINT_ALL, "multiple glArrayElement\n" ); - } else if ( primitives == 3 ) { + } + else if ( primitives == 3 ) { ri.Printf( PRINT_ALL, "multiple glColor4ubv + glTexCoord2fv + glVertex3fv\n" ); } } @@ -1101,33 +1100,30 @@ void GfxInfo_f( void ) ri.Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); ri.Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); ri.Printf( PRINT_ALL, "glsl programs: %s\n", enablestrings[vertexShaders] ); - if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) - { + if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) { ri.Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); } - if ( glConfig.hardwareType == GLHW_RAGEPRO ) - { + if ( glConfig.hardwareType == GLHW_RAGEPRO ) { ri.Printf( PRINT_ALL, "HACK: ragePro approximations\n" ); } - if ( glConfig.hardwareType == GLHW_RIVA128 ) - { + if ( glConfig.hardwareType == GLHW_RIVA128 ) { ri.Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); } if ( r_finish->integer ) { ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); } - if (voodootype){ + if (voodootype) { - if (voodootype == 1) - ri.Printf( PRINT_ALL, "3Dfx Voodoo Graphics assumed\n" ); - else if (voodootype == 2) - ri.Printf( PRINT_ALL, "3Dfx Voodoo2 assumed\n" ); - else if (voodootype == 3) - ri.Printf( PRINT_ALL, "3dfx Voodoo3 assumed\n" ); - else if (voodootype == 4) - ri.Printf( PRINT_ALL, "3dfx Voodoo 4 or 5 assumed\n" ); - - } + if (voodootype == 1) + ri.Printf( PRINT_ALL, "3Dfx Voodoo Graphics assumed\n" ); + else if (voodootype == 2) + ri.Printf( PRINT_ALL, "3Dfx Voodoo2 assumed\n" ); + else if (voodootype == 3) + ri.Printf( PRINT_ALL, "3dfx Voodoo3 assumed\n" ); + else if (voodootype == 4) + ri.Printf( PRINT_ALL, "3dfx Voodoo 4 or 5 assumed\n" ); + + } @@ -1138,11 +1134,11 @@ void GfxInfo_f( void ) R_Register =============== */ -void R_Register( void ) +void R_Register( void ) { - #ifdef USE_RENDERER_DLOPEN +#ifdef USE_RENDERER_DLOPEN com_altivec = ri.Cvar_Get("com_altivec", "1", CVAR_ARCHIVE); - #endif +#endif #if defined( _WIN32 ) // leilei - Get some version info first, code torn from quake @@ -1162,7 +1158,7 @@ void R_Register( void ) r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic", - "0", CVAR_ARCHIVE | CVAR_LATCH ); + "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_max_anisotropy = ri.Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_paletted_texture = ri.Cvar_Get( "r_ext_paletted_texture", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - paletted texture support r_ext_gamma_control = ri.Cvar_Get( "r_ext_gamma_control", "1", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - 3dfx gamma support @@ -1186,9 +1182,9 @@ void R_Register( void ) #if defined( _WIN32 ) if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) // Win2000 and up - r_mode = ri.Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - -2 is so convenient for modern day PCs + r_mode = ri.Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - -2 is so convenient for modern day PCs else // WinNT4/WinME and below - r_mode = ri.Cvar_Get( "r_mode", "3", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - initialize 640x480 for <2000 users as there's a problem at figuring out desktop res on them + r_mode = ri.Cvar_Get( "r_mode", "3", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - initialize 640x480 for <2000 users as there's a problem at figuring out desktop res on them #else @@ -1238,7 +1234,7 @@ void R_Register( void ) r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0", - CVAR_ARCHIVE | CVAR_LATCH ); + CVAR_ARCHIVE | CVAR_LATCH ); r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); @@ -1309,16 +1305,16 @@ void R_Register( void ) - r_specMode = ri.Cvar_Get( "r_specMode", "1" , CVAR_ARCHIVE ); + r_specMode = ri.Cvar_Get( "r_specMode", "1" , CVAR_ARCHIVE ); //r_waveMode = ri.Cvar_Get( "r_waveMode", "0" , CVAR_ARCHIVE ); - + r_lensReflection1 = ri.Cvar_Get( "r_lensReflection1", "1" , CVAR_ARCHIVE); // sharp reflection r_lensReflection2 = ri.Cvar_Get( "r_lensReflection2", "0" , CVAR_ARCHIVE); // fuzzy reflection r_lensReflectionBrightness = ri.Cvar_Get( "r_lensReflectionBrightness", "0.5" , CVAR_ARCHIVE); r_flareQuality = ri.Cvar_Get( "r_flareQuality", "4" , CVAR_ARCHIVE); // use high flares for default (lower settings stutter vsync or clip too badly) - r_flareMethod = ri.Cvar_Get( "r_flareMethod", "0" , CVAR_ARCHIVE); - r_flaresDlight = ri.Cvar_Get( "r_flaresDlight", "0" , CVAR_ARCHIVE ); // dynamic light flares + r_flareMethod = ri.Cvar_Get( "r_flareMethod", "0" , CVAR_ARCHIVE); + r_flaresDlight = ri.Cvar_Get( "r_flaresDlight", "0" , CVAR_ARCHIVE ); // dynamic light flares r_flaresDlightShrink = ri.Cvar_Get( "r_flaresDlightShrink", "1" , CVAR_ARCHIVE ); // dynamic light flares shrinking when close (reducing muzzleflash blindness) r_flaresDlightFade = ri.Cvar_Get( "r_flaresDlightFade", "0" , CVAR_ARCHIVE | CVAR_CHEAT ); // dynamic light flares fading (workaround clipping bug) r_flaresDlightOpacity = ri.Cvar_Get( "r_flaresDlightOpacity", "0.5" , CVAR_ARCHIVE ); // dynamic light flares (workaround poor visibility) @@ -1330,28 +1326,28 @@ void R_Register( void ) - r_mockvr = ri.Cvar_Get( "r_mockvr", "0" , CVAR_CHEAT); - r_parseStageSimple = ri.Cvar_Get( "r_parseStageSimple", "0" , CVAR_CHEAT); - r_leifx = ri.Cvar_Get( "r_leifx", "0" , CVAR_ARCHIVE | CVAR_LATCH); + r_mockvr = ri.Cvar_Get( "r_mockvr", "0" , CVAR_CHEAT); + r_parseStageSimple = ri.Cvar_Get( "r_parseStageSimple", "0" , CVAR_CHEAT); + r_leifx = ri.Cvar_Get( "r_leifx", "0" , CVAR_ARCHIVE | CVAR_LATCH); r_modelshader = ri.Cvar_Get( "r_modelshader", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - load and use special shaders for lightDiffuse models r_detailTextureScale = ri.Cvar_Get( "r_detailtextureScale", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - adjust scale of detail textures r_detailTextureLayers = ri.Cvar_Get( "r_detailtextureLayers", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - add more detail layers r_ntsc = ri.Cvar_Get( "r_ntsc", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - ntsc filter - //r_tvMode = ri.Cvar_Get( "r_tvMode", "0" , CVAR_ARCHIVE | CVAR_LATCH); - r_retroAA = ri.Cvar_Get( "r_retroAA", "0" , CVAR_ARCHIVE | CVAR_LATCH); + //r_tvMode = ri.Cvar_Get( "r_tvMode", "0" , CVAR_ARCHIVE | CVAR_LATCH); + r_retroAA = ri.Cvar_Get( "r_retroAA", "0" , CVAR_ARCHIVE | CVAR_LATCH); - r_suggestiveThemes = ri.Cvar_Get( "r_suggestiveThemes", "1" , CVAR_ARCHIVE | CVAR_LATCH); + r_suggestiveThemes = ri.Cvar_Get( "r_suggestiveThemes", "1" , CVAR_ARCHIVE | CVAR_LATCH); -// r_motionblur = ri.Cvar_Get( "r_motionblur", "0" , CVAR_ARCHIVE | CVAR_LATCH); - r_motionblur_fps = ri.Cvar_Get( "r_motionblur_fps", "60", 0); +// r_motionblur = ri.Cvar_Get( "r_motionblur", "0" , CVAR_ARCHIVE | CVAR_LATCH); + r_motionblur_fps = ri.Cvar_Get( "r_motionblur_fps", "60", 0); - r_anime = ri.Cvar_Get( "r_anime", "0" , CVAR_ARCHIVE | CVAR_LATCH); - r_palletize = ri.Cvar_Get( "r_palletize", "0" , CVAR_ARCHIVE | CVAR_LATCH); - r_leidebug = ri.Cvar_Get( "r_leidebug", "0" , CVAR_CHEAT); - r_particles = ri.Cvar_Get( "r_particles", "0" , CVAR_ARCHIVE | CVAR_LATCH); - r_leidebugeye = ri.Cvar_Get( "r_leidebugeye", "0" , CVAR_CHEAT); + r_anime = ri.Cvar_Get( "r_anime", "0" , CVAR_ARCHIVE | CVAR_LATCH); + r_palletize = ri.Cvar_Get( "r_palletize", "0" , CVAR_ARCHIVE | CVAR_LATCH); + r_leidebug = ri.Cvar_Get( "r_leidebug", "0" , CVAR_CHEAT); + r_particles = ri.Cvar_Get( "r_particles", "0" , CVAR_ARCHIVE | CVAR_LATCH); + r_leidebugeye = ri.Cvar_Get( "r_leidebugeye", "0" , CVAR_CHEAT); r_slowness = ri.Cvar_Get( "r_slowness", "0" , CVAR_ARCHIVE); // it's 0 because you want it to be the fastest possible by default. r_slowness_cpu = ri.Cvar_Get( "r_slowness_cpu", "300" , CVAR_ARCHIVE); // it's 0 because you want it to be the fastest possible by default. r_slowness_gpu = ri.Cvar_Get( "r_slowness_gpu", "96" , CVAR_ARCHIVE); // it's 0 because you want it to be the fastest possible by default. @@ -1385,7 +1381,8 @@ void R_Register( void ) * R_GLSL_AllocProgram * Reserve memory for program */ -static glslProgram_t *R_GLSL_AllocProgram(void) { +static glslProgram_t *R_GLSL_AllocProgram(void) +{ glslProgram_t *program; if (tr.numPrograms == MAX_PROGRAMS) @@ -1425,10 +1422,10 @@ static glslProgram_t *R_GLSL_AllocProgram(void) { program->u_ViewOrigin = -1; program->u_Normal = -1; - program->u_mpass1 = -1; - program->u_mpass2 = -1; - program->u_mpass3 = -1; - program->u_mpass4 = -1; + program->u_mpass1 = -1; + program->u_mpass2 = -1; + program->u_mpass3 = -1; + program->u_mpass4 = -1; program->rubyTextureSize = -1; @@ -1446,7 +1443,8 @@ static glslProgram_t *R_GLSL_AllocProgram(void) { * Load all default GLSL programs which are not loaded via the q3 shader system */ -void R_GLSL_Init(void) { +void R_GLSL_Init(void) +{ #ifdef GLSL_BACKEND glslProgram_t *program; char programVertexObjects[MAX_PROGRAM_OBJECTS][MAX_QPATH]; @@ -1549,8 +1547,7 @@ void R_GLSL_Init(void) { Q_strncpyz(programFragmentObjects[0], "glsl/ntsc_bleed_fp.glsl", sizeof(programFragmentObjects[0])); tr.NTSCBleedProgram = RE_GLSL_RegisterProgram("ntsc_bleed", (const char *)programVertexObjects, 1, (const char *)programFragmentObjects, 1); - if (strcmp( (const char *)r_postprocess->string, "none" )) - { + if (strcmp( (const char *)r_postprocess->string, "none" )) { sprintf(p,"glsl/%s_vp.glsl",r_postprocess->string); Q_strncpyz(programVertexObjects[0], (const char *)&p, sizeof(programVertexObjects[0])); sprintf(p,"glsl/%s_fp.glsl",r_postprocess->string); @@ -1560,7 +1557,7 @@ void R_GLSL_Init(void) { else ri.Printf( PRINT_ALL, "WARNING: Cannot locate postprocessing glsl program %s\n" ,r_postprocess->string); if (tr.postprocessingProgram) postprocess=qtrue; - } + } #endif } extern qboolean initparticles; @@ -1570,7 +1567,8 @@ extern qboolean initparticles; R_Init =============== */ -void R_Init( void ) { +void R_Init( void ) +{ int err; int i; byte *ptr; @@ -1595,26 +1593,21 @@ void R_Init( void ) { // // init function tables // - for ( i = 0; i < FUNCTABLE_SIZE; i++ ) - { + for ( i = 0; i < FUNCTABLE_SIZE; i++ ) { tr.sinTable[i] = sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) ); tr.squareTable[i] = ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f; tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE; tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i]; - if ( i < FUNCTABLE_SIZE / 2 ) - { - if ( i < FUNCTABLE_SIZE / 4 ) - { + if ( i < FUNCTABLE_SIZE / 2 ) { + if ( i < FUNCTABLE_SIZE / 4 ) { tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 ); } - else - { + else { tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4]; } } - else - { + else { tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2]; } } @@ -1672,7 +1665,8 @@ void R_Init( void ) { RE_Shutdown =============== */ -void RE_Shutdown( qboolean destroyWindow ) { +void RE_Shutdown( qboolean destroyWindow ) +{ ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); @@ -1715,7 +1709,8 @@ RE_EndRegistration Touch all images to make sure they are resident ============= */ -void RE_EndRegistration( void ) { +void RE_EndRegistration( void ) +{ R_IssuePendingRenderCommands(); if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); @@ -1730,9 +1725,11 @@ GetRefAPI @@@@@@@@@@@@@@@@@@@@@ */ #ifdef USE_RENDERER_DLOPEN -Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { +Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) +{ #else -refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { +refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) +{ #endif static refexport_t re; @@ -1742,8 +1739,8 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { Com_Memset( &re, 0, sizeof( re ) ); if ( apiVersion != REF_API_VERSION ) { - ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", - REF_API_VERSION, apiVersion ); + ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", + REF_API_VERSION, apiVersion ); return NULL; } diff --git a/code/renderer_oa/tr_local.h b/code/renderer_oa/tr_local.h index dfeb0b8d..73782286 100644 --- a/code/renderer_oa/tr_local.h +++ b/code/renderer_oa/tr_local.h @@ -2373,18 +2373,18 @@ void R_MotionBlur_BackupScreen(int which); void R_AddParticles (void); void R_RenderParticles (void); void R_ClearParticles (void); -void R_LFX_Spark (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); -void R_LFX_Smoke (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); -void R_LFX_Smoke2 (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scale, float scaleup, int blendfunc); -void R_LFX_Shock (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); -void R_LFX_Burst (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); -void R_LFX_PushSmoke (vec3_t there, float force); +void R_LFX_Spark (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); +void R_LFX_Smoke (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); +void R_LFX_Smoke2 (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scale, float scaleup, int blendfunc); +void R_LFX_Shock (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); +void R_LFX_Burst (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc); +void R_LFX_PushSmoke (const vec3_t there, float force); -void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count); -void R_QarticleExplosion(vec3_t org); -void R_LFX_Blood (vec3_t org, vec3_t dir, float pressure) ; +void R_RunParticleEffect (const vec3_t org, const vec3_t dir, int color, int count); +void R_QarticleExplosion(const vec3_t org); +void R_LFX_Blood (const vec3_t org, const vec3_t dir, float pressure) ; void LFX_ShaderInit(void); -void LFX_ParticleEffect (int effect, vec3_t org, vec3_t dir); +void LFX_ParticleEffect (int effect, const vec3_t org, const vec3_t dir); #endif //TR_LOCAL_H diff --git a/code/renderer_oa/tr_model_mdo.c b/code/renderer_oa/tr_model_mdo.c index 9149868f..08d74aac 100644 --- a/code/renderer_oa/tr_model_mdo.c +++ b/code/renderer_oa/tr_model_mdo.c @@ -25,431 +25,431 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LL(x) x=LittleLong(x) -typedef struct{ - float matrix[3][4]; +typedef struct{ + float matrix[3][4]; }boneMatrix_t; -/* -================= -LOADING CODE -================= +/* +================= +LOADING CODE +================= */ -/* -================= -R_LoadMDO -================= -*/ -qboolean R_LoadMDO( model_t *mod, void *buffer, int filesize, const char *mod_name ) { - int i, j, k, lodindex; - mdoHeader_t *pinmodel, *mdo; - mdoFrame_t *frame; - mdoLOD_t *lod; - mdoSurface_t *surf; - mdoTriangle_t *tri; - mdoVertex_t *v; - mdoBoneInfo_t *bone; - int *boneRef; - int version; - int size; - shader_t *sh; - int frameSize; - - pinmodel = (mdoHeader_t *)buffer; - - if( Q_strncmp(pinmodel->ident, MDO_IDENT, sizeof(pinmodel->ident) ) ){ // failed - ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has wrong ident (%s should be %s)\n", - mod_name, pinmodel->ident, MDO_IDENT); - } - - version = LittleLong (pinmodel->version); - if (version != MDO_VERSION) { - ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has wrong version (%i should be %i)\n", - mod_name, version, MDO_VERSION); - return qfalse; - } - - mod->type = MOD_MDO; - - size = LittleLong(pinmodel->ofsEnd); - if(size > filesize) - { - ri.Printf(PRINT_WARNING, "R_LoadMDO: Header of %s is broken. Wrong filesize declared!\n", mod_name); - return qfalse; - } - - mod->dataSize += size; - mod->modelData = mdo = ri.Hunk_Alloc( size, h_low ); - - Com_Memcpy( mdo, buffer, LittleLong(pinmodel->ofsEnd) ); - - LL(mdo->version); - LL(mdo->numFrames); - LL(mdo->numBones); - LL(mdo->numLODs); - LL(mdo->ofsFrames); - LL(mdo->ofsLODs); - LL(mdo->ofsEnd); - - if ( mdo->numFrames < 1 ) { - ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has no frames\n", mod_name ); - return qfalse; - } - - if( mdo->numLODs < 1){ - ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has no LODs\n", mod_name ); - return qfalse; - } - - mod->numLods = mdo->numLODs; // ... don't forget this or LODs won't work - - // swap all the frames - frameSize = (int)( &((mdoFrame_t *)0)->bones[ mdo->numBones ] ); - for ( i = 0 ; i < mdo->numFrames ; i++, frame++) { - frame = (mdoFrame_t *) ( (byte *)mdo + mdo->ofsFrames + i * frameSize ); - frame->radius = LittleFloat( frame->radius ); - for ( j = 0 ; j < 3 ; j++ ) { - frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] ); - frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] ); - frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] ); - } - - for ( j = 0 ; j < mdo->numBones * sizeof( mdoBoneComp_t ) / sizeof( short ); j++ ) { - ( (short *)frame->bones )[j] = LittleShort( ( (short *)frame->bones )[j] ); - } - } - - // swap all the bone infos - bone = (mdoBoneInfo_t *) ( (byte *)mdo + mdo->ofsBones ); - for ( i = 0; i < mdo->numBones; i++, bone++ ){ - // lowercase the bone name so name compares are faster - Q_strlwr( bone->name ); - bone->flags = LittleLong(bone->flags); - bone->parent = LittleLong(bone->parent); - } - - // swap all the LOD's - lod = (mdoLOD_t *) ( (byte *)mdo + mdo->ofsLODs ); - for ( lodindex = 0 ; lodindex < mdo->numLODs ; lodindex++ ) { - LL(lod->numSurfaces); - LL(lod->ofsSurfaces); - LL(lod->ofsEnd); - // swap all the surfaces - surf = (mdoSurface_t *) ( (byte *)lod + lod->ofsSurfaces ); - for ( i = 0 ; i < lod->numSurfaces ; i++) { - //LL(surf->ident); - LL(surf->ofsHeader); // don't swap header offset - LL(surf->numTriangles); - LL(surf->ofsTriangles); - LL(surf->numVerts); - LL(surf->ofsVerts); - LL(surf->numBoneRefs); - LL(surf->ofsBoneRefs); - LL(surf->ofsEnd); - - - if ( surf->numVerts > SHADER_MAX_VERTEXES ) { - ri.Error (ERR_DROP, "R_LoadMDO: %s has more than %i verts on a surface (%i)", - mod_name, SHADER_MAX_VERTEXES, surf->numVerts ); - } - if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { - ri.Error (ERR_DROP, "R_LoadMDO: %s has more than %i triangles on a surface (%i)", - mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles ); - } - - // change to surface identifier - surf->ident = SF_MDO; - - // lowercase the surface name so skin compares are faster - Q_strlwr( surf->name ); - - // register the shaders - sh = R_FindShader(surf->shader, LIGHTMAP_NONE, qtrue); - if ( sh->defaultShader ) { - surf->shaderIndex = 0; - } else { - surf->shaderIndex = sh->index; - } - - // swap all the vertexes and texcoords - v = (mdoVertex_t *) ( (byte *)surf + surf->ofsVerts); - for ( j = 0 ; j < surf->numVerts ; j++ ) { - v->xyz[0] = LittleFloat( v->xyz[0] ); - v->xyz[1] = LittleFloat( v->xyz[1] ); - v->xyz[2] = LittleFloat( v->xyz[2] ); - - v->texCoords[0] = LittleFloat( v->texCoords[0] ); - v->texCoords[1] = LittleFloat( v->texCoords[1] ); - - v->normal = LittleShort( v->normal ); - // num bone weights + weights[] are bytes - v = (mdoVertex_t *)&v->weights[v->numWeights]; - } - - // swap all the triangles - tri = (mdoTriangle_t *) ( (byte *)surf + surf->ofsTriangles ); - for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) { - LL(tri->indexes[0]); - LL(tri->indexes[1]); - LL(tri->indexes[2]); - } - - // swap all the bone references - boneRef = ( int * )( ( byte *)surf + surf->ofsBoneRefs ); - for ( j = 0; j < surf->numBoneRefs; j++, boneRef++ ){ - *boneRef = LittleLong( *boneRef ); - } - - // find the next surface - surf = (mdoSurface_t *)( (byte *)surf + surf->ofsEnd ); - } - - // find the next LOD - lod = (mdoLOD_t *)( (byte *)lod + lod->ofsEnd ); - } - - return qtrue; -} - -/* -================= -DRAWING CODE -================= -*/ - -/* -============= -R_CullMDO -============= -*/ - -static int R_CullMDO( mdoHeader_t *header, trRefEntity_t *ent ) { - vec3_t bounds[2]; - mdoFrame_t *oldFrame, *newFrame; - int i, frameSize; - - frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ header->numBones ] ); - - // compute frame pointers - newFrame = ( mdoFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); - oldFrame = ( mdoFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.oldframe); - - // cull bounding sphere ONLY if this is not an upscaled entity - if ( !ent->e.nonNormalizedAxes ) - { - if ( ent->e.frame == ent->e.oldframe ) - { - switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) - { - - case CULL_OUT: - tr.pc.c_sphere_cull_md3_out++; - return CULL_OUT; - - case CULL_IN: - tr.pc.c_sphere_cull_md3_in++; - return CULL_IN; - - case CULL_CLIP: - tr.pc.c_sphere_cull_md3_clip++; - break; - } - } - else - { - int sphereCull, sphereCullB; - - sphereCull = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ); - if ( newFrame == oldFrame ) { - sphereCullB = sphereCull; - } else { - sphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius ); - } - - if ( sphereCull == sphereCullB ) - { - if ( sphereCull == CULL_OUT ) - { - tr.pc.c_sphere_cull_md3_out++; - return CULL_OUT; - } - else if ( sphereCull == CULL_IN ) - { - tr.pc.c_sphere_cull_md3_in++; - return CULL_IN; - } - else - { - tr.pc.c_sphere_cull_md3_clip++; - } - } - } - } - - // calculate a bounding box in the current coordinate system - for (i = 0 ; i < 3 ; i++) { - bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; - bounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i]; - } - - switch ( R_CullLocalBox( bounds ) ) - { - case CULL_IN: - tr.pc.c_box_cull_md3_in++; - return CULL_IN; - case CULL_CLIP: - tr.pc.c_box_cull_md3_clip++; - return CULL_CLIP; - case CULL_OUT: - default: - tr.pc.c_box_cull_md3_out++; - return CULL_OUT; - } -} - -/* -================= -R_ComputeMDOFogNum - -================= -*/ -int R_ComputeMDOFogNum( mdoHeader_t *header, trRefEntity_t *ent ) { - int i, j; - fog_t *fog; - mdoFrame_t *frame; - vec3_t localOrigin; - int frameSize; - - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - return 0; - } - - frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ header->numBones ] ); - - // FIXME: non-normalized axis issues - frame = ( mdoFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); - VectorAdd( ent->e.origin, frame->localOrigin, localOrigin ); - for ( i = 1 ; i < tr.world->numfogs ; i++ ) { - fog = &tr.world->fogs[i]; - for ( j = 0 ; j < 3 ; j++ ) { - if ( localOrigin[j] - frame->radius >= fog->bounds[1][j] ) { - break; - } - if ( localOrigin[j] + frame->radius <= fog->bounds[0][j] ) { - break; - } - } - if ( j == 3 ) { - return i; - } - } - - return 0; -} - -/* -============== -R_AddMDOSurfaces -============== -*/ -void R_AddMDOSurfaces( trRefEntity_t *ent ) { - mdoHeader_t *header; - mdoSurface_t *surface; - mdoLOD_t *lod; - shader_t *shader; - skin_t *skin; - int i, j, k; - int lodnum = 0; - int fogNum = 0; - int cull; - qboolean personalModel; - - header = (mdoHeader_t *) tr.currentModel->modelData; - - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; - - if ( ent->e.renderfx & RF_WRAP_FRAMES ) - { - ent->e.frame %= header->numFrames; - ent->e.oldframe %= header->numFrames; - } - - // - // Validate the frames so there is no chance of a crash. - // This will write directly into the entity structure, so - // when the surfaces are rendered, they don't need to be - // range checked again. - // - if ((ent->e.frame >= header->numFrames) - || (ent->e.frame < 0) - || (ent->e.oldframe >= header->numFrames) - || (ent->e.oldframe < 0) ) - { - ri.Printf( PRINT_DEVELOPER, "R_AddMDOSurfaces: no such frame %d to %d for '%s'\n", - ent->e.oldframe, ent->e.frame, tr.currentModel->name ); - ent->e.frame = 0; - ent->e.oldframe = 0; - } - - // - // cull the entire model if merged bounding box of both frames - // is outside the view frustum. - // - cull = R_CullMDO (header, ent); - if ( cull == CULL_OUT ) { - return; - } - - // figure out the current LOD of the model we're rendering, and set the lod pointer respectively. - lodnum = R_ComputeLOD(ent); - // check whether this model has as that many LODs at all. If not, try the closest thing we got. - if(header->numLODs <= 0) - return; - if(header->numLODs <= lodnum) - lodnum = header->numLODs - 1; - - lod = (mdoLOD_t *)( (byte *)header + header->ofsLODs); - for(i = 0; i < lodnum; i++) - { - lod = (mdoLOD_t *) ((byte *) lod + lod->ofsEnd); - } - - // set up lighting - if ( !personalModel || r_shadows->integer > 1 ) - { - R_SetupEntityLighting( &tr.refdef, ent ); - } - - // fogNum - fogNum = R_ComputeMDOFogNum( header, ent ); - - surface = (mdoSurface_t *)( (byte *)lod + lod->ofsSurfaces ); - - for ( i = 0 ; i < lod->numSurfaces ; i++ ) - { - - if(ent->e.customShader) - shader = R_GetShaderByHandle(ent->e.customShader); - else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) - { - skin = R_GetSkinByHandle(ent->e.customSkin); - shader = tr.defaultShader; - - for(j = 0; j < skin->numSurfaces; j++) - { - if (!strcmp(skin->surfaces[j]->name, surface->name)) - { - shader = skin->surfaces[j]->shader; - break; - } - } - } - else if(surface->shaderIndex > 0) - shader = R_GetShaderByHandle( surface->shaderIndex ); - else - shader = tr.defaultShader; - - // we will add shadows even if the main object isn't visible in the view - +/* +================= +R_LoadMDO +================= +*/ +qboolean R_LoadMDO( model_t *mod, void *buffer, int filesize, const char *mod_name ) { + int i, j, k, lodindex; + mdoHeader_t *pinmodel, *mdo; + mdoFrame_t *frame; + mdoLOD_t *lod; + mdoSurface_t *surf; + mdoTriangle_t *tri; + mdoVertex_t *v; + mdoBoneInfo_t *bone; + int *boneRef; + int version; + int size; + shader_t *sh; + int frameSize; + + pinmodel = (mdoHeader_t *)buffer; + + if( Q_strncmp(pinmodel->ident, MDO_IDENT, sizeof(pinmodel->ident) ) ){ // failed + ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has wrong ident (%s should be %s)\n", + mod_name, pinmodel->ident, MDO_IDENT); + } + + version = LittleLong (pinmodel->version); + if (version != MDO_VERSION) { + ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has wrong version (%i should be %i)\n", + mod_name, version, MDO_VERSION); + return qfalse; + } + + mod->type = MOD_MDO; + + size = LittleLong(pinmodel->ofsEnd); + if(size > filesize) + { + ri.Printf(PRINT_WARNING, "R_LoadMDO: Header of %s is broken. Wrong filesize declared!\n", mod_name); + return qfalse; + } + + mod->dataSize += size; + mod->modelData = mdo = ri.Hunk_Alloc( size, h_low ); + + Com_Memcpy( mdo, buffer, LittleLong(pinmodel->ofsEnd) ); + + LL(mdo->version); + LL(mdo->numFrames); + LL(mdo->numBones); + LL(mdo->numLODs); + LL(mdo->ofsFrames); + LL(mdo->ofsLODs); + LL(mdo->ofsEnd); + + if ( mdo->numFrames < 1 ) { + ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has no frames\n", mod_name ); + return qfalse; + } + + if( mdo->numLODs < 1){ + ri.Printf( PRINT_WARNING, "R_LoadMDO: %s has no LODs\n", mod_name ); + return qfalse; + } + + mod->numLods = mdo->numLODs; // ... don't forget this or LODs won't work + + // swap all the frames + frameSize = (int)( &((mdoFrame_t *)0)->bones[ mdo->numBones ] ); + for ( i = 0 ; i < mdo->numFrames ; i++, frame++) { + frame = (mdoFrame_t *) ( (byte *)mdo + mdo->ofsFrames + i * frameSize ); + frame->radius = LittleFloat( frame->radius ); + for ( j = 0 ; j < 3 ; j++ ) { + frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] ); + frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] ); + frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] ); + } + + for ( j = 0 ; j < mdo->numBones * sizeof( mdoBoneComp_t ) / sizeof( short ); j++ ) { + ( (short *)frame->bones )[j] = LittleShort( ( (short *)frame->bones )[j] ); + } + } + + // swap all the bone infos + bone = (mdoBoneInfo_t *) ( (byte *)mdo + mdo->ofsBones ); + for ( i = 0; i < mdo->numBones; i++, bone++ ){ + // lowercase the bone name so name compares are faster + Q_strlwr( bone->name ); + bone->flags = LittleLong(bone->flags); + bone->parent = LittleLong(bone->parent); + } + + // swap all the LOD's + lod = (mdoLOD_t *) ( (byte *)mdo + mdo->ofsLODs ); + for ( lodindex = 0 ; lodindex < mdo->numLODs ; lodindex++ ) { + LL(lod->numSurfaces); + LL(lod->ofsSurfaces); + LL(lod->ofsEnd); + // swap all the surfaces + surf = (mdoSurface_t *) ( (byte *)lod + lod->ofsSurfaces ); + for ( i = 0 ; i < lod->numSurfaces ; i++) { + //LL(surf->ident); + LL(surf->ofsHeader); // don't swap header offset + LL(surf->numTriangles); + LL(surf->ofsTriangles); + LL(surf->numVerts); + LL(surf->ofsVerts); + LL(surf->numBoneRefs); + LL(surf->ofsBoneRefs); + LL(surf->ofsEnd); + + + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { + ri.Error (ERR_DROP, "R_LoadMDO: %s has more than %i verts on a surface (%i)", + mod_name, SHADER_MAX_VERTEXES, surf->numVerts ); + } + if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { + ri.Error (ERR_DROP, "R_LoadMDO: %s has more than %i triangles on a surface (%i)", + mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles ); + } + + // change to surface identifier + surf->ident = SF_MDO; + + // lowercase the surface name so skin compares are faster + Q_strlwr( surf->name ); + + // register the shaders + sh = R_FindShader(surf->shader, LIGHTMAP_NONE, qtrue); + if ( sh->defaultShader ) { + surf->shaderIndex = 0; + } else { + surf->shaderIndex = sh->index; + } + + // swap all the vertexes and texcoords + v = (mdoVertex_t *) ( (byte *)surf + surf->ofsVerts); + for ( j = 0 ; j < surf->numVerts ; j++ ) { + v->xyz[0] = LittleFloat( v->xyz[0] ); + v->xyz[1] = LittleFloat( v->xyz[1] ); + v->xyz[2] = LittleFloat( v->xyz[2] ); + + v->texCoords[0] = LittleFloat( v->texCoords[0] ); + v->texCoords[1] = LittleFloat( v->texCoords[1] ); + + v->normal = LittleShort( v->normal ); + // num bone weights + weights[] are bytes + v = (mdoVertex_t *)&v->weights[v->numWeights]; + } + + // swap all the triangles + tri = (mdoTriangle_t *) ( (byte *)surf + surf->ofsTriangles ); + for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) { + LL(tri->indexes[0]); + LL(tri->indexes[1]); + LL(tri->indexes[2]); + } + + // swap all the bone references + boneRef = ( int * )( ( byte *)surf + surf->ofsBoneRefs ); + for ( j = 0; j < surf->numBoneRefs; j++, boneRef++ ){ + *boneRef = LittleLong( *boneRef ); + } + + // find the next surface + surf = (mdoSurface_t *)( (byte *)surf + surf->ofsEnd ); + } + + // find the next LOD + lod = (mdoLOD_t *)( (byte *)lod + lod->ofsEnd ); + } + + return qtrue; +} + +/* +================= +DRAWING CODE +================= +*/ + +/* +============= +R_CullMDO +============= +*/ + +static int R_CullMDO( mdoHeader_t *header, trRefEntity_t *ent ) { + vec3_t bounds[2]; + mdoFrame_t *oldFrame, *newFrame; + int i, frameSize; + + frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ header->numBones ] ); + + // compute frame pointers + newFrame = ( mdoFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); + oldFrame = ( mdoFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.oldframe); + + // cull bounding sphere ONLY if this is not an upscaled entity + if ( !ent->e.nonNormalizedAxes ) + { + if ( ent->e.frame == ent->e.oldframe ) + { + switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) + { + + case CULL_OUT: + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + + case CULL_IN: + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + + case CULL_CLIP: + tr.pc.c_sphere_cull_md3_clip++; + break; + } + } + else + { + int sphereCull, sphereCullB; + + sphereCull = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ); + if ( newFrame == oldFrame ) { + sphereCullB = sphereCull; + } else { + sphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius ); + } + + if ( sphereCull == sphereCullB ) + { + if ( sphereCull == CULL_OUT ) + { + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + } + else if ( sphereCull == CULL_IN ) + { + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + } + else + { + tr.pc.c_sphere_cull_md3_clip++; + } + } + } + } + + // calculate a bounding box in the current coordinate system + for (i = 0 ; i < 3 ; i++) { + bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; + bounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i]; + } + + switch ( R_CullLocalBox( bounds ) ) + { + case CULL_IN: + tr.pc.c_box_cull_md3_in++; + return CULL_IN; + case CULL_CLIP: + tr.pc.c_box_cull_md3_clip++; + return CULL_CLIP; + case CULL_OUT: + default: + tr.pc.c_box_cull_md3_out++; + return CULL_OUT; + } +} + +/* +================= +R_ComputeMDOFogNum + +================= +*/ +int R_ComputeMDOFogNum( mdoHeader_t *header, trRefEntity_t *ent ) { + int i, j; + fog_t *fog; + mdoFrame_t *frame; + vec3_t localOrigin; + int frameSize; + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return 0; + } + + frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ header->numBones ] ); + + // FIXME: non-normalized axis issues + frame = ( mdoFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); + VectorAdd( ent->e.origin, frame->localOrigin, localOrigin ); + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { + fog = &tr.world->fogs[i]; + for ( j = 0 ; j < 3 ; j++ ) { + if ( localOrigin[j] - frame->radius >= fog->bounds[1][j] ) { + break; + } + if ( localOrigin[j] + frame->radius <= fog->bounds[0][j] ) { + break; + } + } + if ( j == 3 ) { + return i; + } + } + + return 0; +} + +/* +============== +R_AddMDOSurfaces +============== +*/ +void R_AddMDOSurfaces( trRefEntity_t *ent ) { + mdoHeader_t *header; + mdoSurface_t *surface; + mdoLOD_t *lod; + shader_t *shader; + skin_t *skin; + int i, j, k; + int lodnum = 0; + int fogNum = 0; + int cull; + qboolean personalModel; + + header = (mdoHeader_t *) tr.currentModel->modelData; + + personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; + + if ( ent->e.renderfx & RF_WRAP_FRAMES ) + { + ent->e.frame %= header->numFrames; + ent->e.oldframe %= header->numFrames; + } + + // + // Validate the frames so there is no chance of a crash. + // This will write directly into the entity structure, so + // when the surfaces are rendered, they don't need to be + // range checked again. + // + if ((ent->e.frame >= header->numFrames) + || (ent->e.frame < 0) + || (ent->e.oldframe >= header->numFrames) + || (ent->e.oldframe < 0) ) + { + ri.Printf( PRINT_DEVELOPER, "R_AddMDOSurfaces: no such frame %d to %d for '%s'\n", + ent->e.oldframe, ent->e.frame, tr.currentModel->name ); + ent->e.frame = 0; + ent->e.oldframe = 0; + } + + // + // cull the entire model if merged bounding box of both frames + // is outside the view frustum. + // + cull = R_CullMDO (header, ent); + if ( cull == CULL_OUT ) { + return; + } + + // figure out the current LOD of the model we're rendering, and set the lod pointer respectively. + lodnum = R_ComputeLOD(ent); + // check whether this model has as that many LODs at all. If not, try the closest thing we got. + if(header->numLODs <= 0) + return; + if(header->numLODs <= lodnum) + lodnum = header->numLODs - 1; + + lod = (mdoLOD_t *)( (byte *)header + header->ofsLODs); + for(i = 0; i < lodnum; i++) + { + lod = (mdoLOD_t *) ((byte *) lod + lod->ofsEnd); + } + + // set up lighting + if ( !personalModel || r_shadows->integer > 1 ) + { + R_SetupEntityLighting( &tr.refdef, ent ); + } + + // fogNum + fogNum = R_ComputeMDOFogNum( header, ent ); + + surface = (mdoSurface_t *)( (byte *)lod + lod->ofsSurfaces ); + + for ( i = 0 ; i < lod->numSurfaces ; i++ ) + { + + if(ent->e.customShader) + shader = R_GetShaderByHandle(ent->e.customShader); + else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) + { + skin = R_GetSkinByHandle(ent->e.customSkin); + shader = tr.defaultShader; + + for(j = 0; j < skin->numSurfaces; j++) + { + if (!strcmp(skin->surfaces[j]->name, surface->name)) + { + shader = skin->surfaces[j]->shader; + break; + } + } + } + else if(surface->shaderIndex > 0) + shader = R_GetShaderByHandle( surface->shaderIndex ); + else + shader = tr.defaultShader; + + // we will add shadows even if the main object isn't visible in the view + // stencil shadows can't do personal models unless I polyhedron clip if ( !personalModel && r_shadows->integer == 2 @@ -470,299 +470,299 @@ void R_AddMDOSurfaces( trRefEntity_t *ent ) { } if (!personalModel) - R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse ); - - surface = (mdoSurface_t *)( (byte *)surface + surface->ofsEnd ); - } -} - -/* -================= -ANIMATION -================= -*/ - -void CompBoneToMatrix( const vec4_t quat, vec3_t trans, float matrix[3][4] ) { - float xx = 2.0f * quat[0] * quat[0]; - float yy = 2.0f * quat[1] * quat[1]; - float zz = 2.0f * quat[2] * quat[2]; - float xy = 2.0f * quat[0] * quat[1]; - float xz = 2.0f * quat[0] * quat[2]; - float yz = 2.0f * quat[1] * quat[2]; - float wx = 2.0f * quat[3] * quat[0]; - float wy = 2.0f * quat[3] * quat[1]; - float wz = 2.0f * quat[3] * quat[2]; - - matrix[0][0] = ( 1.0f - ( yy + zz ) ); - matrix[0][1] = ( xy - wz ); - matrix[0][2] = ( xz + wy ); - matrix[0][3] = trans[0]; - - matrix[1][0] = ( xy + wz); - matrix[1][1] = ( 1.0f - ( xx + zz ) ); - matrix[1][2] = ( yz - wx); - matrix[1][3] = trans[1]; - - matrix[2][0] = ( xz - wy ); - matrix[2][1] = ( yz + wx ); - matrix[2][2] = ( 1.0f - ( xx + yy ) ); - matrix[2][3] = trans[2]; -} - -void R_UncompressBone( int boneIndex, mdoFrame_t *frame, float matrix[3][4] ) -{ - mdoBoneComp_t *bone = &frame->bones[boneIndex]; - vec4_t quat; - vec3_t trans; - - - quat[0] = bone->rotQuat[0] * MDO_QUAT_SCALE; - quat[1] = bone->rotQuat[1] * MDO_QUAT_SCALE; - quat[2] = bone->rotQuat[2] * MDO_QUAT_SCALE; - quat[3] = bone->rotQuat[3] * MDO_QUAT_SCALE; - - trans[0] = bone->translation[0] * MDO_TRANSLATION_SCALE; - trans[1] = bone->translation[1] * MDO_TRANSLATION_SCALE; - trans[2] = bone->translation[2] * MDO_TRANSLATION_SCALE; - - CompBoneToMatrix( quat, trans, matrix ); -} - -void Matrix3x4Lerp( float mat1[3][4], float mat2[3][4], float blerp, float out[3][4], qboolean slerp ) -{ - float flerp = 1.0f - blerp; - - out[0][0] = flerp * mat1[0][0] + blerp * mat2[0][0]; - out[0][1] = flerp * mat1[0][1] + blerp * mat2[0][1]; - out[0][2] = flerp * mat1[0][2] + blerp * mat2[0][2]; - out[0][3] = flerp * mat1[0][3] + blerp * mat2[0][3]; - - out[1][0] = flerp * mat1[1][0] + blerp * mat2[1][0]; - out[1][1] = flerp * mat1[1][1] + blerp * mat2[1][1]; - out[1][2] = flerp * mat1[1][2] + blerp * mat2[1][2]; - out[1][3] = flerp * mat1[1][3] + blerp * mat2[1][3]; - - out[2][0] = flerp * mat1[2][0] + blerp * mat2[2][0]; - out[2][1] = flerp * mat1[2][1] + blerp * mat2[2][1]; - out[2][2] = flerp * mat1[2][2] + blerp * mat2[2][2]; - out[2][3] = flerp * mat1[2][3] + blerp * mat2[2][3]; - - if( slerp ){ // unsquash the rotations - VectorNormalize( out[0] ); - VectorNormalize( out[1] ); - VectorNormalize( out[2] ); - } -} - -/* -================ -R_GetMDOTag -================ -*/ -md3Tag_t *R_GetMDOTag( mdoHeader_t *mod, int framenum, const char *tagName, md3Tag_t * dest) -{ - int i, j, k; - int frameSize; - mdoFrame_t *frame; - mdoBoneInfo_t *bone; - - if ( framenum >= mod->numFrames ) - { - // it is possible to have a bad frame while changing models, so don't error - framenum = mod->numFrames - 1; - } - - bone = (mdoBoneInfo_t *)((byte *)mod + mod->ofsBones); - for ( i = 0; i < mod->numBones; i++, bone++ ) - { - if( !(bone->flags & BFLAG_TAG) ){ - continue; - } - - if ( !strcmp( bone->name, tagName ) ) - { - vec4_t quat; - vec3_t trans; - float matrix[3][4]; - - Q_strncpyz(dest->name, bone->name, sizeof(dest->name)); - - frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ mod->numBones ] ); - frame = (mdoFrame_t *)((byte *)mod + mod->ofsFrames + framenum * frameSize ); - - R_UncompressBone( i, frame, matrix); - + R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse ); + + surface = (mdoSurface_t *)( (byte *)surface + surface->ofsEnd ); + } +} + +/* +================= +ANIMATION +================= +*/ + +void CompBoneToMatrix( const vec4_t quat, vec3_t trans, float matrix[3][4] ) { + float xx = 2.0f * quat[0] * quat[0]; + float yy = 2.0f * quat[1] * quat[1]; + float zz = 2.0f * quat[2] * quat[2]; + float xy = 2.0f * quat[0] * quat[1]; + float xz = 2.0f * quat[0] * quat[2]; + float yz = 2.0f * quat[1] * quat[2]; + float wx = 2.0f * quat[3] * quat[0]; + float wy = 2.0f * quat[3] * quat[1]; + float wz = 2.0f * quat[3] * quat[2]; + + matrix[0][0] = ( 1.0f - ( yy + zz ) ); + matrix[0][1] = ( xy - wz ); + matrix[0][2] = ( xz + wy ); + matrix[0][3] = trans[0]; + + matrix[1][0] = ( xy + wz); + matrix[1][1] = ( 1.0f - ( xx + zz ) ); + matrix[1][2] = ( yz - wx); + matrix[1][3] = trans[1]; + + matrix[2][0] = ( xz - wy ); + matrix[2][1] = ( yz + wx ); + matrix[2][2] = ( 1.0f - ( xx + yy ) ); + matrix[2][3] = trans[2]; +} + +void R_UncompressBone( int boneIndex, mdoFrame_t *frame, float matrix[3][4] ) +{ + mdoBoneComp_t *bone = &frame->bones[boneIndex]; + vec4_t quat; + vec3_t trans; + + + quat[0] = bone->rotQuat[0] * MDO_QUAT_SCALE; + quat[1] = bone->rotQuat[1] * MDO_QUAT_SCALE; + quat[2] = bone->rotQuat[2] * MDO_QUAT_SCALE; + quat[3] = bone->rotQuat[3] * MDO_QUAT_SCALE; + + trans[0] = bone->translation[0] * MDO_TRANSLATION_SCALE; + trans[1] = bone->translation[1] * MDO_TRANSLATION_SCALE; + trans[2] = bone->translation[2] * MDO_TRANSLATION_SCALE; + + CompBoneToMatrix( quat, trans, matrix ); +} + +void Matrix3x4Lerp( float mat1[3][4], float mat2[3][4], float blerp, float out[3][4], qboolean slerp ) +{ + float flerp = 1.0f - blerp; + + out[0][0] = flerp * mat1[0][0] + blerp * mat2[0][0]; + out[0][1] = flerp * mat1[0][1] + blerp * mat2[0][1]; + out[0][2] = flerp * mat1[0][2] + blerp * mat2[0][2]; + out[0][3] = flerp * mat1[0][3] + blerp * mat2[0][3]; + + out[1][0] = flerp * mat1[1][0] + blerp * mat2[1][0]; + out[1][1] = flerp * mat1[1][1] + blerp * mat2[1][1]; + out[1][2] = flerp * mat1[1][2] + blerp * mat2[1][2]; + out[1][3] = flerp * mat1[1][3] + blerp * mat2[1][3]; + + out[2][0] = flerp * mat1[2][0] + blerp * mat2[2][0]; + out[2][1] = flerp * mat1[2][1] + blerp * mat2[2][1]; + out[2][2] = flerp * mat1[2][2] + blerp * mat2[2][2]; + out[2][3] = flerp * mat1[2][3] + blerp * mat2[2][3]; + + if( slerp ){ // unsquash the rotations + VectorNormalize( out[0] ); + VectorNormalize( out[1] ); + VectorNormalize( out[2] ); + } +} + +/* +================ +R_GetMDOTag +================ +*/ +md3Tag_t *R_GetMDOTag( mdoHeader_t *mod, int framenum, const char *tagName, md3Tag_t * dest) +{ + int i, j, k; + int frameSize; + mdoFrame_t *frame; + mdoBoneInfo_t *bone; + + if ( framenum >= mod->numFrames ) + { + // it is possible to have a bad frame while changing models, so don't error + framenum = mod->numFrames - 1; + } + + bone = (mdoBoneInfo_t *)((byte *)mod + mod->ofsBones); + for ( i = 0; i < mod->numBones; i++, bone++ ) + { + if( !(bone->flags & BFLAG_TAG) ){ + continue; + } + + if ( !strcmp( bone->name, tagName ) ) + { + vec4_t quat; + vec3_t trans; + float matrix[3][4]; + + Q_strncpyz(dest->name, bone->name, sizeof(dest->name)); + + frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ mod->numBones ] ); + frame = (mdoFrame_t *)((byte *)mod + mod->ofsFrames + framenum * frameSize ); + + R_UncompressBone( i, frame, matrix); + for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++){ dest->axis[j][k] = matrix[k][j]; } dest->origin[j] = matrix[j][3]; - } - - return dest; - } - } - - return NULL; -} - -/* -================ -RB_SurfaceMDO -================ -*/ -#define FTABLESIZE_DIV_256 4 // optimizations, may want to move this right next to the functables -#define FTABLESIZE_DIV_4 256 // and use it for other functions that use them -void RB_SurfaceMDO( mdoSurface_t *surface ) -{ - int i, j, k; - int frameSize; - float frontlerp, backlerp; - int *triangles; - int indexes; - int baseIndex, baseVertex; - int numVerts; - int *boneRefList; - int *boneRef; - mdoVertex_t *v; - mdoHeader_t *header; - mdoFrame_t *frame; - mdoFrame_t *oldFrame; - boneMatrix_t bones[MDO_MAX_BONES], *bonePtr, *bone; - mdoBoneInfo_t *boneInfo; - refEntity_t *ent; - - ent = &backEnd.currentEntity->e; - - // don't lerp if lerping off, or this is the only frame, or the last frame... - // - if (ent->oldframe == ent->frame) - { - backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used - frontlerp = 1; - } - else - { - backlerp = ent->backlerp; - frontlerp = 1.0f - backlerp; - } - - header = (mdoHeader_t *)((byte *)surface - surface->ofsHeader); - - - // - // Set up all triangles. - // - RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles * 3 ); - triangles = (int *) ((byte *)surface + surface->ofsTriangles); - indexes = surface->numTriangles * 3; - baseIndex = tess.numIndexes; - baseVertex = tess.numVertexes; - - for (j = 0 ; j < indexes ; j++) - { - tess.indexes[baseIndex + j] = baseVertex + triangles[j]; - } - tess.numIndexes += indexes; - - // - // Setup and lerp all the needed bones - // - frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ header->numBones ] ); - - frame = (mdoFrame_t *)((byte *)header + header->ofsFrames + ent->frame * frameSize ); - oldFrame = (mdoFrame_t *)((byte *)header + header->ofsFrames + ent->oldframe * frameSize ); - - // boneRefs - boneRefList = ( int * )( (byte *)surface + surface->ofsBoneRefs ); - boneRef = boneRefList; - - // boneInfos - boneInfo = (mdoBoneInfo_t *)((byte *)header + header->ofsBones); - - bonePtr = bones; - for( i = 0 ; i < surface->numBoneRefs ; i++, boneRef++ ) - { - - if( !backlerp ){ // no need for cache, animation is simple - R_UncompressBone( *boneRef, frame, bonePtr[*boneRef].matrix ); - }else{ - float mat1[3][4], mat2[3][4]; - R_UncompressBone( *boneRef, frame, mat1 ); - R_UncompressBone( *boneRef, oldFrame, mat2 ); - Matrix3x4Lerp(mat1, mat2, backlerp, bonePtr[*boneRef].matrix, qtrue); - } - } - - // - // deform the vertexes by the lerped bones - // - numVerts = surface->numVerts; - v = (mdoVertex_t *) ((byte *)surface + surface->ofsVerts); - for ( j = 0; j < numVerts; j++ ) - { - vec3_t vertex, normal; - vec3_t unCompNormal; - unsigned int lat, lng; - - VectorClear( vertex ); - VectorClear( normal ); - - // Uncompress the normal - lat = ( v->normal >> 8 ) & 0xff; - lng = ( v->normal & 0xff ); - lat *= (FTABLESIZE_DIV_256); - lng *= (FTABLESIZE_DIV_256); - - unCompNormal[0] = tr.sinTable[(lat+(FTABLESIZE_DIV_4))&FUNCTABLE_MASK] * tr.sinTable[lng]; - unCompNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; - unCompNormal[2] = tr.sinTable[(lng+(FTABLESIZE_DIV_4))&FUNCTABLE_MASK]; - - if( !v->numWeights || !header->numBones ){ // static model, or un weighted vertex - vertex[0] = v->xyz[0]; - vertex[1] = v->xyz[1]; - vertex[2] = v->xyz[2]; - - normal[0] = unCompNormal[0]; - normal[1] = unCompNormal[1]; - normal[2] = unCompNormal[2]; - - VectorNormalizeFast(normal); // ensure a normalized normal - }else{ - mdoWeight_t *w; - w = v->weights; - for( k = 0; k < v->numWeights; k++, w++ ){ - float fWeight = w->boneWeight * MDO_BYTE_WEIGHT_SCALE; - int boneIndex = w->boneIndex; - - bone = bonePtr + boneIndex; - // Transform the vert and normal - vertex[0] += fWeight * ( DotProduct( bone->matrix[0], v->xyz ) + bone->matrix[0][3] ); - vertex[1] += fWeight * ( DotProduct( bone->matrix[1], v->xyz ) + bone->matrix[1][3] ); - vertex[2] += fWeight * ( DotProduct( bone->matrix[2], v->xyz ) + bone->matrix[2][3] ); - - normal[0] += fWeight * DotProduct( bone->matrix[0], unCompNormal ); - normal[1] += fWeight * DotProduct( bone->matrix[1], unCompNormal ); - normal[2] += fWeight * DotProduct( bone->matrix[2], unCompNormal ); - } - VectorNormalizeFast(normal); // ensure a normalized normal - } - - tess.xyz[baseVertex + j][0] = vertex[0]; - tess.xyz[baseVertex + j][1] = vertex[1]; - tess.xyz[baseVertex + j][2] = vertex[2]; - - tess.normal[baseVertex + j][0] = normal[0]; - tess.normal[baseVertex + j][1] = normal[1]; - tess.normal[baseVertex + j][2] = normal[2]; - - tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; - tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; - - v = (mdoVertex_t *)&v->weights[v->numWeights]; - } - - tess.numVertexes += surface->numVerts; -} - + } + + return dest; + } + } + + return NULL; +} + +/* +================ +RB_SurfaceMDO +================ +*/ +#define FTABLESIZE_DIV_256 4 // optimizations, may want to move this right next to the functables +#define FTABLESIZE_DIV_4 256 // and use it for other functions that use them +void RB_SurfaceMDO( mdoSurface_t *surface ) +{ + int i, j, k; + int frameSize; + float frontlerp, backlerp; + int *triangles; + int indexes; + int baseIndex, baseVertex; + int numVerts; + int *boneRefList; + int *boneRef; + mdoVertex_t *v; + mdoHeader_t *header; + mdoFrame_t *frame; + mdoFrame_t *oldFrame; + boneMatrix_t bones[MDO_MAX_BONES], *bonePtr, *bone; + mdoBoneInfo_t *boneInfo; + refEntity_t *ent; + + ent = &backEnd.currentEntity->e; + + // don't lerp if lerping off, or this is the only frame, or the last frame... + // + if (ent->oldframe == ent->frame) + { + backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used + frontlerp = 1; + } + else + { + backlerp = ent->backlerp; + frontlerp = 1.0f - backlerp; + } + + header = (mdoHeader_t *)((byte *)surface - surface->ofsHeader); + + + // + // Set up all triangles. + // + RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles * 3 ); + triangles = (int *) ((byte *)surface + surface->ofsTriangles); + indexes = surface->numTriangles * 3; + baseIndex = tess.numIndexes; + baseVertex = tess.numVertexes; + + for (j = 0 ; j < indexes ; j++) + { + tess.indexes[baseIndex + j] = baseVertex + triangles[j]; + } + tess.numIndexes += indexes; + + // + // Setup and lerp all the needed bones + // + frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ header->numBones ] ); + + frame = (mdoFrame_t *)((byte *)header + header->ofsFrames + ent->frame * frameSize ); + oldFrame = (mdoFrame_t *)((byte *)header + header->ofsFrames + ent->oldframe * frameSize ); + + // boneRefs + boneRefList = ( int * )( (byte *)surface + surface->ofsBoneRefs ); + boneRef = boneRefList; + + // boneInfos + boneInfo = (mdoBoneInfo_t *)((byte *)header + header->ofsBones); + + bonePtr = bones; + for( i = 0 ; i < surface->numBoneRefs ; i++, boneRef++ ) + { + + if( !backlerp ){ // no need for cache, animation is simple + R_UncompressBone( *boneRef, frame, bonePtr[*boneRef].matrix ); + }else{ + float mat1[3][4], mat2[3][4]; + R_UncompressBone( *boneRef, frame, mat1 ); + R_UncompressBone( *boneRef, oldFrame, mat2 ); + Matrix3x4Lerp(mat1, mat2, backlerp, bonePtr[*boneRef].matrix, qtrue); + } + } + + // + // deform the vertexes by the lerped bones + // + numVerts = surface->numVerts; + v = (mdoVertex_t *) ((byte *)surface + surface->ofsVerts); + for ( j = 0; j < numVerts; j++ ) + { + vec3_t vertex, normal; + vec3_t unCompNormal; + unsigned int lat, lng; + + VectorClear( vertex ); + VectorClear( normal ); + + // Uncompress the normal + lat = ( v->normal >> 8 ) & 0xff; + lng = ( v->normal & 0xff ); + lat *= (FTABLESIZE_DIV_256); + lng *= (FTABLESIZE_DIV_256); + + unCompNormal[0] = tr.sinTable[(lat+(FTABLESIZE_DIV_4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + unCompNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + unCompNormal[2] = tr.sinTable[(lng+(FTABLESIZE_DIV_4))&FUNCTABLE_MASK]; + + if( !v->numWeights || !header->numBones ){ // static model, or un weighted vertex + vertex[0] = v->xyz[0]; + vertex[1] = v->xyz[1]; + vertex[2] = v->xyz[2]; + + normal[0] = unCompNormal[0]; + normal[1] = unCompNormal[1]; + normal[2] = unCompNormal[2]; + + VectorNormalizeFast(normal); // ensure a normalized normal + }else{ + mdoWeight_t *w; + w = v->weights; + for( k = 0; k < v->numWeights; k++, w++ ){ + float fWeight = w->boneWeight * MDO_BYTE_WEIGHT_SCALE; + int boneIndex = w->boneIndex; + + bone = bonePtr + boneIndex; + // Transform the vert and normal + vertex[0] += fWeight * ( DotProduct( bone->matrix[0], v->xyz ) + bone->matrix[0][3] ); + vertex[1] += fWeight * ( DotProduct( bone->matrix[1], v->xyz ) + bone->matrix[1][3] ); + vertex[2] += fWeight * ( DotProduct( bone->matrix[2], v->xyz ) + bone->matrix[2][3] ); + + normal[0] += fWeight * DotProduct( bone->matrix[0], unCompNormal ); + normal[1] += fWeight * DotProduct( bone->matrix[1], unCompNormal ); + normal[2] += fWeight * DotProduct( bone->matrix[2], unCompNormal ); + } + VectorNormalizeFast(normal); // ensure a normalized normal + } + + tess.xyz[baseVertex + j][0] = vertex[0]; + tess.xyz[baseVertex + j][1] = vertex[1]; + tess.xyz[baseVertex + j][2] = vertex[2]; + + tess.normal[baseVertex + j][0] = normal[0]; + tess.normal[baseVertex + j][1] = normal[1]; + tess.normal[baseVertex + j][2] = normal[2]; + + tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; + tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; + + v = (mdoVertex_t *)&v->weights[v->numWeights]; + } + + tess.numVertexes += surface->numVerts; +} + diff --git a/code/renderer_oa/tr_particles.c b/code/renderer_oa/tr_particles.c index f28871b1..00e021ff 100644 --- a/code/renderer_oa/tr_particles.c +++ b/code/renderer_oa/tr_particles.c @@ -60,8 +60,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_TRAIL_POINTS 8 #define TRAIL_LENGTH_SPLIT 64 -typedef struct particle_s -{ +typedef struct particle_s { struct particle_s *next; float time; @@ -169,8 +168,7 @@ static int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 }; -typedef enum -{ +typedef enum { P_NONE, P_WEATHER, P_FLAT, @@ -227,8 +225,7 @@ static float THEtime; // lazy struct hack to make quake code backporting quicker and painless -typedef struct -{ +typedef struct { double time; } imlazy_t; @@ -244,10 +241,11 @@ static imlazy_t cl; #define pt_fire P_QUAKEFIRE void CM_Trace( trace_t *results, const vec3_t start, const vec3_t end, vec3_t mins, vec3_t maxs, - clipHandle_t model, const vec3_t origin, int brushmask, int capsule, sphere_t *sphere ); + clipHandle_t model, const vec3_t origin, int brushmask, int capsule, sphere_t *sphere ); static void P_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, - int skipNumber, int mask ) { + int skipNumber, int mask ) +{ CM_Trace(result, start, end, NULL, NULL, 0, start, mask, 0, NULL); } @@ -266,8 +264,7 @@ void R_ClearParticles (void) free_particles = &particles[0]; active_particles = NULL; - for (i=0 ;ifogNum > 0 && p->fogNum < tr.world->numfogs) - { + if(tr.world && p->fogNum > 0 && p->fogNum < tr.world->numfogs) { tess.numVertexes = 1; VectorCopy(org, tess.xyz[0]); tess.fogNum = p->fogNum; @@ -338,12 +334,13 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) vec3_t rr, ru; vec3_t rotate_ang; - if (p->colortype == P_LFX) { + if (p->colortype == P_LFX) { // Ramp // hack to prevent that one long particle from going crazy in the world. - if (p->startfade > THEtime){ - p->bounce = 0; p->bubbleit = 0; //no cpu expensive checks + if (p->startfade > THEtime) { + p->bounce = 0; + p->bubbleit = 0; //no cpu expensive checks return; } @@ -364,7 +361,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) int et; vec4_t fcol; - for(et=0;et<4;et++) { + for(et=0; et<4; et++) { if (invratio < 0.25f) { fcol[et] = (p->cols[et][3] * inv1) + (p->cols[et][4] * (1 - inv1)); } @@ -378,9 +375,13 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) fcol[et] = (p->cols[et][0] * inv4) + (p->cols[et][1] * (1 - inv4)); } } - for(et=0;et<4;et++){ - if (fcol[et]>1) { fcol[et]=1.0f; } - if (fcol[et]<0) { fcol[et]=0.0f; } + for(et=0; et<4; et++) { + if (fcol[et]>1) { + fcol[et]=1.0f; + } + if (fcol[et]<0) { + fcol[et]=0.0f; + } } color[0] = fcol[0]; color[1] = fcol[1]; @@ -636,7 +637,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) VectorMA( right, -line[0], backEnd.refdef.viewaxis[2], right ); VectorNormalize( right ); - RB_BeginSurface( p->pshader, fogNum ); + RB_BeginSurface( p->pshader, fogNum ); VectorMA( finish, width, right, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; @@ -689,7 +690,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) else if (p->rendertype == LFXTRAIL) { // STRETCHY TRAIL sprite - used for..... i dunno // like burst but splits into more trails when the certain length is achieved - // TO RETURN + // TO RETURN } else { // VP PARALLEL sprite @@ -708,7 +709,8 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) if (p->roll) { VectorMA (org, -height, ru, point); VectorMA (point, -width, rr, point); - } else { + } + else { VectorMA (org, -height, pvup, point); VectorMA (point, -width, pvright, point); } @@ -729,7 +731,8 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) if (p->roll) { VectorMA (point, 2*height, ru, point); - } else { + } + else { VectorMA (point, 2*height, pvup, point); } VectorCopy (point, tess.xyz[tess.numVertexes] ); @@ -743,7 +746,8 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) if (p->roll) { VectorMA (point, 2*width, rr, point); - } else { + } + else { VectorMA (point, 2*width, pvright, point); } VectorCopy (point, tess.xyz[tess.numVertexes] ); @@ -757,7 +761,8 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) if (p->roll) { VectorMA (point, -2*height, ru, point); - } else { + } + else { VectorMA (point, -2*height, pvup, point); } VectorCopy (point, tess.xyz[tess.numVertexes] ); @@ -784,7 +789,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha) if (!p->pshader) { - // force a shader. + // force a shader. p->pshader = alfball; return; } @@ -870,7 +875,7 @@ void R_AddParticles (void) p->endwidth= scal; p->bounce = 0; p->bubbleit = 0; - // ri.Printf( PRINT_ALL, "boung!"); + // ri.Printf( PRINT_ALL, "boung!"); p->colortype = P_INDEXED; p->alpha = 1; p->qolor = p->color; @@ -884,7 +889,7 @@ void R_AddParticles (void) - if (p->rendertype != LFXQUAKE){ + if (p->rendertype != LFXQUAKE) { p->vel[0] += p->accel[0]*frametime; p->vel[1] += p->accel[1]*frametime; p->vel[2] += p->accel[2]*frametime; @@ -895,58 +900,58 @@ void R_AddParticles (void) p->vel[2] += frametime; int i; switch (p->type) { - case pt_static: - break; - case pt_fire: - p->ramp += time1; - if (p->ramp >= 6) - p->die = -1; - else - p->color = ramp3[(int)p->ramp]; - p->vel[2] += grav; - break; + case pt_static: + break; + case pt_fire: + p->ramp += time1; + if (p->ramp >= 6) + p->die = -1; + else + p->color = ramp3[(int)p->ramp]; + p->vel[2] += grav; + break; - case pt_explode: - p->ramp += time2; - if (p->ramp >=8) - p->die = -1; - else - p->color = ramp1[(int)p->ramp]; - for (i=0 ; i<3 ; i++) - p->vel[i] += p->vel[i]*dvel; - p->vel[2] -= grav; - break; + case pt_explode: + p->ramp += time2; + if (p->ramp >=8) + p->die = -1; + else + p->color = ramp1[(int)p->ramp]; + for (i=0 ; i<3 ; i++) + p->vel[i] += p->vel[i]*dvel; + p->vel[2] -= grav; + break; - case pt_explode2: - p->ramp += time3; - if (p->ramp >=8) - p->die = -1; - else - p->color = ramp2[(int)p->ramp]; - for (i=0 ; i<3 ; i++) - p->vel[i] -= p->vel[i]*frametime; - p->vel[2] -= grav; - break; + case pt_explode2: + p->ramp += time3; + if (p->ramp >=8) + p->die = -1; + else + p->color = ramp2[(int)p->ramp]; + for (i=0 ; i<3 ; i++) + p->vel[i] -= p->vel[i]*frametime; + p->vel[2] -= grav; + break; - case pt_blob: - for (i=0 ; i<3 ; i++) - p->vel[i] += p->vel[i]*dvel; - p->vel[2] -= grav; - break; + case pt_blob: + for (i=0 ; i<3 ; i++) + p->vel[i] += p->vel[i]*dvel; + p->vel[2] -= grav; + break; - case pt_blob2: - for (i=0 ; i<2 ; i++) - p->vel[i] -= p->vel[i]*dvel; - p->vel[2] -= grav; - break; + case pt_blob2: + for (i=0 ; i<2 ; i++) + p->vel[i] -= p->vel[i]*dvel; + p->vel[2] -= grav; + break; - case pt_grav: - p->vel[2] -= grav * 20; - break; + case pt_grav: + p->vel[2] -= grav * 20; + break; - case pt_slowgrav: - p->accel[2] -= grav; - break; + case pt_slowgrav: + p->accel[2] -= grav; + break; } if (THEtime> p->endtime) { @@ -1000,12 +1005,12 @@ void R_AddParticles (void) if (p->rendertype != LFXQUAKE) { if (alpha > 1.0) alpha = 1; - if (p->rollfriction){ + if (p->rollfriction) { f = 1.0f - MINe(p->rollfriction * frametime, 1); p->rollvel *= f; } - if (p->airfriction){ + if (p->airfriction) { f = 1.0f - MINe(p->airfriction * frametime, 1); VectorScale(p->vel, f, p->vel); } @@ -1013,7 +1018,7 @@ void R_AddParticles (void) alpha = p->alpha + time*p->alphavel; // hack to prevent that one long particle from going crazy in the world. - if (p->startfade > THEtime){ + if (p->startfade > THEtime) { p->alpha = -1; // kill it } @@ -1107,17 +1112,25 @@ void R_AddParticles (void) p->accel[0] = 0; p->accel[1] = 0; p->accel[2] = 66; - p->cols[0][0] = 1; p->cols[0][1] = 1; p->cols[0][2] = 1; - p->cols[1][0] = 1; p->cols[1][1] = 1; p->cols[1][2] = 1; - p->cols[2][0] = 1; p->cols[2][1] = 1; p->cols[2][2] = 1; - p->cols[3][0] = 1; p->cols[3][1] = 1; p->cols[3][2] = 1; + p->cols[0][0] = 1; + p->cols[0][1] = 1; + p->cols[0][2] = 1; + p->cols[1][0] = 1; + p->cols[1][1] = 1; + p->cols[1][2] = 1; + p->cols[2][0] = 1; + p->cols[2][1] = 1; + p->cols[2][2] = 1; + p->cols[3][0] = 1; + p->cols[3][1] = 1; + p->cols[3][2] = 1; p->endtime += 1000; // last it a wile } } if(p->type == LFXBUBBLE) { int contents = CM_PointContents( p->org, 0 ); - if ( contents | ( CONTENTS_WATER | CONTENTS_SLIME ) ) { + if ( contents | ( CONTENTS_WATER | CONTENTS_SLIME ) ) { p->endtime = THEtime; } else { @@ -1137,7 +1150,7 @@ void R_AddParticles (void) // Do the trace of truth P_Trace (&trace, oldorg, NULL, NULL, p->org, -1, CONTENTS_SOLID); { - if (trace.fraction < 1){ + if (trace.fraction < 1) { VectorCopy(trace.endpos, p->org); // particle where we've hit from if (p->bounce < 0) { // bounce -1 means remove on impact @@ -1221,59 +1234,59 @@ void R_RenderParticles (void) // -void R_LFX_Blood (vec3_t org, vec3_t dir, float pressure) +void R_LFX_Blood (const vec3_t org, const vec3_t dir, float pressure) { int i, j; int count = pressure * 4; particle_t *p; - for (i = 0; i < count; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - p->time = THEtime; - p->bubbleit = 2; // dissolve - p->endtime = THEtime+ (1200 * (crandom() * 22)); - //p->startfade = p->endtime; - //p->color = GREY75; - p->rendertype = LFXSMOKE; - p->alpha = 1.0f; - p->alphavel = 2.0f; - p->height = 1.5; - p->width = 1.5; - p->endheight = 1.5; - p->endwidth = 1.5; + for (i = 0; i < count; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = THEtime; + p->bubbleit = 2; // dissolve + p->endtime = THEtime+ (1200 * (crandom() * 22)); + //p->startfade = p->endtime; + //p->color = GREY75; + p->rendertype = LFXSMOKE; + p->alpha = 1.0f; + p->alphavel = 2.0f; + p->height = 1.5; + p->width = 1.5; + p->endheight = 1.5; + p->endwidth = 1.5; - p->cols[0][0] = p->cols[0][1] = p->cols[0][2] = p->cols[0][3] = p->cols[0][4] = 1.0; - p->cols[1][0] = p->cols[1][1] = p->cols[1][2] = p->cols[1][3] = p->cols[1][4] = 0.0; - p->cols[2][0] = p->cols[2][1] = p->cols[2][2] = p->cols[2][3] = p->cols[2][4] = 0.0; + p->cols[0][0] = p->cols[0][1] = p->cols[0][2] = p->cols[0][3] = p->cols[0][4] = 1.0; + p->cols[1][0] = p->cols[1][1] = p->cols[1][2] = p->cols[1][3] = p->cols[1][4] = 0.0; + p->cols[2][0] = p->cols[2][1] = p->cols[2][2] = p->cols[2][3] = p->cols[2][4] = 0.0; - // Manage blending Functions - p->pshader = addsmoke; + // Manage blending Functions + p->pshader = addsmoke; - p->colortype = P_LFX; + p->colortype = P_LFX; - VectorCopy(org, p->org); - p->bounce = 1.1f; - for (j = 0; j < 3; j++) { - //p->org[j] = org[j] + ((rand() & (count/8)) - (count/16)); - p->org[j] = org[j] + ((crandom() * (count/16)) - (count/32)); - p->vel[j] = dir[j] * (i * 2.6); + VectorCopy(org, p->org); + p->bounce = 1.1f; + for (j = 0; j < 3; j++) { + //p->org[j] = org[j] + ((rand() & (count/8)) - (count/16)); + p->org[j] = org[j] + ((crandom() * (count/16)) - (count/32)); + p->vel[j] = dir[j] * (i * 2.6); - p->vel[j] *= 0.01; - } + p->vel[j] *= 0.01; + } - p->accel[0] = p->accel[1] = p->accel[2] = 0; - p->accel[2] = -(PARTICLE_GRAVITY*8); + p->accel[0] = p->accel[1] = p->accel[2] = 0; + p->accel[2] = -(PARTICLE_GRAVITY*8); - p->airfriction = 0; - // p->org[j] = org[j] + (rand()&((count))-(count)); - // p->vel[j] = dir[j]*(rand()*(count*0.5))-(count) * 0.7; - // p->vel[2] += (i / 5); + p->airfriction = 0; + // p->org[j] = org[j] + (rand()&((count))-(count)); + // p->vel[j] = dir[j]*(rand()*(count*0.5))-(count) * 0.7; + // p->vel[2] += (i / 5); // } @@ -1283,7 +1296,7 @@ void R_LFX_Blood (vec3_t org, vec3_t dir, float pressure) } -void R_LFX_Smoke (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) +void R_LFX_Smoke (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) { int i, j; int cont = 50; @@ -1291,92 +1304,92 @@ void R_LFX_Smoke (vec3_t org, vec3_t dir, float spread, float speed, vec4_t colo cont = (44 / (count / 2 + 1)) + 1; - for (i = 0; i < cont; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - p->time = THEtime; + for (i = 0; i < cont; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = THEtime; - p->endtime = THEtime+ duration; - p->startfade = THEtime; + p->endtime = THEtime+ duration; + p->startfade = THEtime; - p->rendertype = LFXSMOKE; - p->alpha = 0.1f; - p->alphavel = 0.0f; - p->height = p->width = 1.0 * (count / 3); - p->bubbleit = 0; - p->endheight = p->height + scaleup; - p->endwidth = p->width + scaleup; + p->rendertype = LFXSMOKE; + p->alpha = 0.1f; + p->alphavel = 0.0f; + p->height = p->width = 1.0 * (count / 3); + p->bubbleit = 0; + p->endheight = p->height + scaleup; + p->endwidth = p->width + scaleup; - // Manage random roll and - p->rotate = qtrue; - p->roll = crandom()*179; + // Manage random roll and + p->rotate = qtrue; + p->roll = crandom()*179; - p->cols[0][0] = color1[0]; - p->cols[1][0] = color1[1]; - p->cols[2][0] = color1[2]; - p->cols[3][0] = color1[3]; + p->cols[0][0] = color1[0]; + p->cols[1][0] = color1[1]; + p->cols[2][0] = color1[2]; + p->cols[3][0] = color1[3]; - p->cols[0][1] = color2[0]; - p->cols[1][1] = color2[1]; - p->cols[2][1] = color2[2]; - p->cols[3][1] = color2[3]; + p->cols[0][1] = color2[0]; + p->cols[1][1] = color2[1]; + p->cols[2][1] = color2[2]; + p->cols[3][1] = color2[3]; - p->cols[0][2] = color3[0]; - p->cols[1][2] = color3[1]; - p->cols[2][2] = color3[2]; - p->cols[3][2] = color3[3]; + p->cols[0][2] = color3[0]; + p->cols[1][2] = color3[1]; + p->cols[2][2] = color3[2]; + p->cols[3][2] = color3[3]; - p->cols[0][3] = color4[0]; - p->cols[1][3] = color4[1]; - p->cols[2][3] = color4[2]; - p->cols[3][3] = color4[3]; + p->cols[0][3] = color4[0]; + p->cols[1][3] = color4[1]; + p->cols[2][3] = color4[2]; + p->cols[3][3] = color4[3]; - p->cols[0][4] = color5[0]; - p->cols[1][4] = color5[1]; - p->cols[2][4] = color5[2]; - p->cols[3][4] = color5[3]; + p->cols[0][4] = color5[0]; + p->cols[1][4] = color5[1]; + p->cols[2][4] = color5[2]; + p->cols[3][4] = color5[3]; - // Manage blending Functions - if (blendfunc == 1) - p->pshader = addsmoke; - else if (blendfunc == 2) - p->pshader = modsmoke; - else if (blendfunc == 3) - p->pshader = subsmoke; - else if (blendfunc == 8) - p->pshader = fireball; - else - p->pshader = alfsmoke; + // Manage blending Functions + if (blendfunc == 1) + p->pshader = addsmoke; + else if (blendfunc == 2) + p->pshader = modsmoke; + else if (blendfunc == 3) + p->pshader = subsmoke; + else if (blendfunc == 8) + p->pshader = fireball; + else + p->pshader = alfsmoke; - p->colortype = P_LFX; + p->colortype = P_LFX; - VectorCopy(org, p->org); + VectorCopy(org, p->org); - // Manage spread of origin and velocity - for (j = 0; j < 3; j++) { - //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); - p->org[j] = org[j]; + // Manage spread of origin and velocity + for (j = 0; j < 3; j++) { + //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); + p->org[j] = org[j]; - p->vel[j] = (crandom() * dir[j]) * speed; - p->vel[j] += ((crandom() * (spread)) - (spread/2)); + p->vel[j] = (crandom() * dir[j]) * speed; + p->vel[j] += ((crandom() * (spread)) - (spread/2)); } - p->airfriction = 1.6f; - p->bounce = 1.7f; - p->rollvel = crandom() * 40 - 20; - p->rollfriction = 0.7; + p->airfriction = 1.6f; + p->bounce = 1.7f; + p->rollvel = crandom() * 40 - 20; + p->rollfriction = 0.7; } } -void R_LFX_Smoke2 (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scale, float scaleup, int blendfunc) +void R_LFX_Smoke2 (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scale, float scaleup, int blendfunc) { int i, j; int cont = 50; @@ -1386,214 +1399,214 @@ void R_LFX_Smoke2 (vec3_t org, vec3_t dir, float spread, float speed, vec4_t col p = 0; // die warnings - for (i = 0; i < cont; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - p->time = THEtime; + for (i = 0; i < cont; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = THEtime; - p->endtime = THEtime+ duration; - p->startfade = THEtime; - p->bubbleit = 1; - p->rendertype = LFXSMOKE; - p->alpha = 0.1f; - p->alphavel = 0.0f; - p->height = p->width = (1.0 * scale); + p->endtime = THEtime+ duration; + p->startfade = THEtime; + p->bubbleit = 1; + p->rendertype = LFXSMOKE; + p->alpha = 0.1f; + p->alphavel = 0.0f; + p->height = p->width = (1.0 * scale); - p->endheight = p->height + scaleup; - p->endwidth = p->width + scaleup; + p->endheight = p->height + scaleup; + p->endwidth = p->width + scaleup; - // Manage random roll and - p->rotate = qtrue; - p->roll = crandom()*179; + // Manage random roll and + p->rotate = qtrue; + p->roll = crandom()*179; - p->cols[0][0] = color1[0]; - p->cols[1][0] = color1[1]; - p->cols[2][0] = color1[2]; - p->cols[3][0] = color1[3]; + p->cols[0][0] = color1[0]; + p->cols[1][0] = color1[1]; + p->cols[2][0] = color1[2]; + p->cols[3][0] = color1[3]; - p->cols[0][1] = color2[0]; - p->cols[1][1] = color2[1]; - p->cols[2][1] = color2[2]; - p->cols[3][1] = color2[3]; + p->cols[0][1] = color2[0]; + p->cols[1][1] = color2[1]; + p->cols[2][1] = color2[2]; + p->cols[3][1] = color2[3]; - p->cols[0][2] = color3[0]; - p->cols[1][2] = color3[1]; - p->cols[2][2] = color3[2]; - p->cols[3][2] = color3[3]; + p->cols[0][2] = color3[0]; + p->cols[1][2] = color3[1]; + p->cols[2][2] = color3[2]; + p->cols[3][2] = color3[3]; - p->cols[0][3] = color4[0]; - p->cols[1][3] = color4[1]; - p->cols[2][3] = color4[2]; - p->cols[3][3] = color4[3]; + p->cols[0][3] = color4[0]; + p->cols[1][3] = color4[1]; + p->cols[2][3] = color4[2]; + p->cols[3][3] = color4[3]; - p->cols[0][4] = color5[0]; - p->cols[1][4] = color5[1]; - p->cols[2][4] = color5[2]; - p->cols[3][4] = color5[3]; + p->cols[0][4] = color5[0]; + p->cols[1][4] = color5[1]; + p->cols[2][4] = color5[2]; + p->cols[3][4] = color5[3]; - if (blendfunc == 1) - p->pshader = addsmoke; - else if (blendfunc == 2) - p->pshader = modsmoke; - else if (blendfunc == 3) - p->pshader = subsmoke; - else if (blendfunc == 8) - p->pshader = fireball; - else - p->pshader = alfsmoke; + if (blendfunc == 1) + p->pshader = addsmoke; + else if (blendfunc == 2) + p->pshader = modsmoke; + else if (blendfunc == 3) + p->pshader = subsmoke; + else if (blendfunc == 8) + p->pshader = fireball; + else + p->pshader = alfsmoke; - p->colortype = P_LFX; + p->colortype = P_LFX; - VectorCopy(org, p->org); -/* - // Manage spread of origin and velocity - for (j = 0; j < 3; j++) { - //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); - p->org[j] = org[j]; + VectorCopy(org, p->org); + /* + // Manage spread of origin and velocity + for (j = 0; j < 3; j++) { + //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); + p->org[j] = org[j]; - p->vel[j] = (crandom() * dir[j]) * speed; - p->vel[j] += ((crandom() * (spread)) - (spread/2)); - } + p->vel[j] = (crandom() * dir[j]) * speed; + p->vel[j] += ((crandom() * (spread)) - (spread/2)); + } - } -*/ - // Manage spread of origin and velocity - for (j = 0; j < 3; j++) { - p->org[j] = org[j]; - p->vel[j] = (rand() & (int)spread) - (int)(spread * 0.5f); - p->vel[j] += dir[j]; - p->vel[j] += (dir[j] * (rand() & (int)speed)); + } + */ + // Manage spread of origin and velocity + for (j = 0; j < 3; j++) { + p->org[j] = org[j]; + p->vel[j] = (rand() & (int)spread) - (int)(spread * 0.5f); + p->vel[j] += dir[j]; + p->vel[j] += (dir[j] * (rand() & (int)speed)); } - //p->rollvel = crandom() * (50 - 100)*DotProduct(p->vel); - p->rollvel = crandom() * ((p->vel[0]+p->vel[1]+p->vel[2])/6) - ((p->vel[0]+p->vel[1]+p->vel[2])/3); - p->rollfriction = 2; - p->airfriction = 3.7f; - p->accel[2] = (PARTICLE_GRAVITY*1.3); - p->bounce = 3.5f; + //p->rollvel = crandom() * (50 - 100)*DotProduct(p->vel); + p->rollvel = crandom() * ((p->vel[0]+p->vel[1]+p->vel[2])/6) - ((p->vel[0]+p->vel[1]+p->vel[2])/3); + p->rollfriction = 2; + p->airfriction = 3.7f; + p->accel[2] = (PARTICLE_GRAVITY*1.3); + p->bounce = 3.5f; - p->bounce = 0.0f; // bounce is slow... + p->bounce = 0.0f; // bounce is slow... } } -void R_LFX_Shock (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) +void R_LFX_Shock (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) { int i, j; particle_t *p; - for (i = 0; i < count; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - p->time = THEtime; + for (i = 0; i < count; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = THEtime; - p->endtime = THEtime+ duration; - p->startfade = THEtime; - p->bubbleit = 0; - p->rendertype = LFXSHOCK; + p->endtime = THEtime+ duration; + p->startfade = THEtime; + p->bubbleit = 0; + p->rendertype = LFXSHOCK; // p->rendertype = BLOODRED; // note - not actually bloodred. - p->alpha = 0.1f; - p->alphavel = 0.0f; - //p->qolor = (color & ~7) + (rand() & 7); - p->height = p->width = 1.0 * (count / 3); + p->alpha = 0.1f; + p->alphavel = 0.0f; + //p->qolor = (color & ~7) + (rand() & 7); + p->height = p->width = 1.0 * (count / 3); - p->endheight = p->height + scaleup; - p->endwidth = p->width + scaleup; + p->endheight = p->height + scaleup; + p->endwidth = p->width + scaleup; - // Manage random roll and - p->rotate = qtrue; - //p->rotate = qtrue; - p->roll = crandom()*179; - //p->roll = rand()%179; + // Manage random roll and + p->rotate = qtrue; + //p->rotate = qtrue; + p->roll = crandom()*179; + //p->roll = rand()%179; - p->dir[0] = dir[0]; - p->dir[1] = dir[1]; - p->dir[2] = dir[2]; + p->dir[0] = dir[0]; + p->dir[1] = dir[1]; + p->dir[2] = dir[2]; - p->cols[0][0] = color1[0]; - p->cols[1][0] = color1[1]; - p->cols[2][0] = color1[2]; - p->cols[3][0] = color1[3]; + p->cols[0][0] = color1[0]; + p->cols[1][0] = color1[1]; + p->cols[2][0] = color1[2]; + p->cols[3][0] = color1[3]; - p->cols[0][1] = color2[0]; - p->cols[1][1] = color2[1]; - p->cols[2][1] = color2[2]; - p->cols[3][1] = color2[3]; + p->cols[0][1] = color2[0]; + p->cols[1][1] = color2[1]; + p->cols[2][1] = color2[2]; + p->cols[3][1] = color2[3]; - p->cols[0][2] = color3[0]; - p->cols[1][2] = color3[1]; - p->cols[2][2] = color3[2]; - p->cols[3][2] = color3[3]; + p->cols[0][2] = color3[0]; + p->cols[1][2] = color3[1]; + p->cols[2][2] = color3[2]; + p->cols[3][2] = color3[3]; - p->cols[0][3] = color4[0]; - p->cols[1][3] = color4[1]; - p->cols[2][3] = color4[2]; - p->cols[3][3] = color4[3]; + p->cols[0][3] = color4[0]; + p->cols[1][3] = color4[1]; + p->cols[2][3] = color4[2]; + p->cols[3][3] = color4[3]; - p->cols[0][4] = color5[0]; - p->cols[1][4] = color5[1]; - p->cols[2][4] = color5[2]; - p->cols[3][4] = color5[3]; + p->cols[0][4] = color5[0]; + p->cols[1][4] = color5[1]; + p->cols[2][4] = color5[2]; + p->cols[3][4] = color5[3]; - // Manage blending Functions - if (blendfunc == 1) - p->pshader = addshock; - else if (blendfunc == 2) - p->pshader = modshock; - else if (blendfunc == 14) - p->pshader = watsplash; - else if (blendfunc == 3) - p->pshader = subshock; - else + // Manage blending Functions + if (blendfunc == 1) + p->pshader = addshock; + else if (blendfunc == 2) + p->pshader = modshock; + else if (blendfunc == 14) + p->pshader = watsplash; + else if (blendfunc == 3) + p->pshader = subshock; + else - p->pshader = alfshock; - p->colortype = P_LFX; + p->pshader = alfshock; + p->colortype = P_LFX; - VectorCopy(org, p->org); + VectorCopy(org, p->org); - // Manage spread of origin and velocity - for (j = 0; j < 3; j++) { - //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); - p->org[j] = org[j]; + // Manage spread of origin and velocity + for (j = 0; j < 3; j++) { + //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); + p->org[j] = org[j]; - p->vel[j] = (crandom() * dir[j]) * speed; - p->vel[j] += ((crandom() * (spread)) - (spread/2)); + p->vel[j] = (crandom() * dir[j]) * speed; + p->vel[j] += ((crandom() * (spread)) - (spread/2)); } - // Manage the Air Friction hack. + // Manage the Air Friction hack. - // for (j = 0; j < 3; j++) { - // p->accel[j] = (p->vel[j] * -1); - // } + // for (j = 0; j < 3; j++) { + // p->accel[j] = (p->vel[j] * -1); + // } - //p->accel[0] = p->accel[1] = p->accel[2] = 0; - //p->accel[2] = -(PARTICLE_GRAVITY / 2); + //p->accel[0] = p->accel[1] = p->accel[2] = 0; + //p->accel[2] = -(PARTICLE_GRAVITY / 2); - p->airfriction = 0; + p->airfriction = 0; } } -void R_LFX_Spark (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) +void R_LFX_Spark (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) { int i, j; int cont = 50; @@ -1601,123 +1614,123 @@ void R_LFX_Spark (vec3_t org, vec3_t dir, float spread, float speed, vec4_t colo cont = count; - for (i = 0; i < cont; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - p->time = THEtime; + for (i = 0; i < cont; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = THEtime; - p->endtime = THEtime+ duration; - p->startfade = THEtime; + p->endtime = THEtime+ duration; + p->startfade = THEtime; - p->rendertype = LFXSPARK; - //p->color = EMISIVEFADE; - p->alpha = 1.0f; - p->alphavel = 0.0f; - //p->qolor = (color & ~7) + (rand() & 7); - p->height = p->width = scaleup; + p->rendertype = LFXSPARK; + //p->color = EMISIVEFADE; + p->alpha = 1.0f; + p->alphavel = 0.0f; + //p->qolor = (color & ~7) + (rand() & 7); + p->height = p->width = scaleup; - p->endheight = p->height; - p->endwidth = p->width; + p->endheight = p->height; + p->endwidth = p->width; - p->rotate = qfalse; // sparks don't rotate - p->roll = 0; // sparks don't roll + p->rotate = qfalse; // sparks don't rotate + p->roll = 0; // sparks don't roll - p->accel[0] = p->accel[1] = p->accel[2] = 0; + p->accel[0] = p->accel[1] = p->accel[2] = 0; - p->bubbleit = 1; + p->bubbleit = 1; - p->cols[0][0] = color1[0]; - p->cols[1][0] = color1[1]; - p->cols[2][0] = color1[2]; - p->cols[3][0] = color1[3]; + p->cols[0][0] = color1[0]; + p->cols[1][0] = color1[1]; + p->cols[2][0] = color1[2]; + p->cols[3][0] = color1[3]; - p->cols[0][1] = color2[0]; - p->cols[1][1] = color2[1]; - p->cols[2][1] = color2[2]; - p->cols[3][1] = color2[3]; + p->cols[0][1] = color2[0]; + p->cols[1][1] = color2[1]; + p->cols[2][1] = color2[2]; + p->cols[3][1] = color2[3]; - p->cols[0][2] = color3[0]; - p->cols[1][2] = color3[1]; - p->cols[2][2] = color3[2]; - p->cols[3][2] = color3[3]; + p->cols[0][2] = color3[0]; + p->cols[1][2] = color3[1]; + p->cols[2][2] = color3[2]; + p->cols[3][2] = color3[3]; - p->cols[0][3] = color4[0]; - p->cols[1][3] = color4[1]; - p->cols[2][3] = color4[2]; - p->cols[3][3] = color4[3]; + p->cols[0][3] = color4[0]; + p->cols[1][3] = color4[1]; + p->cols[2][3] = color4[2]; + p->cols[3][3] = color4[3]; - p->cols[0][4] = color5[0]; - p->cols[1][4] = color5[1]; - p->cols[2][4] = color5[2]; - p->cols[3][4] = color5[3]; + p->cols[0][4] = color5[0]; + p->cols[1][4] = color5[1]; + p->cols[2][4] = color5[2]; + p->cols[3][4] = color5[3]; - // Manage blending Functions - if (blendfunc == 1) - p->pshader = addball; - else if (blendfunc == 2) - p->pshader = modball; - else if (blendfunc == 3) - p->pshader = subball; - else if (blendfunc == 666) - p->pshader = blood1; - else - p->pshader = alfball; + // Manage blending Functions + if (blendfunc == 1) + p->pshader = addball; + else if (blendfunc == 2) + p->pshader = modball; + else if (blendfunc == 3) + p->pshader = subball; + else if (blendfunc == 666) + p->pshader = blood1; + else + p->pshader = alfball; - //p->pshader = cgs.media.whiteShader; + //p->pshader = cgs.media.whiteShader; // - p->colortype = P_LFX; + p->colortype = P_LFX; - VectorCopy(org, p->org); + VectorCopy(org, p->org); - // Manage spread of origin and velocity - for (j = 0; j < 3; j++) { - p->org[j] = org[j]; - p->vel[j] = (rand() & (int)spread) - (int)(spread * 0.5f); - p->vel[j] += dir[j]; - p->vel[j] += (dir[j] * (rand() & (int)speed)); + // Manage spread of origin and velocity + for (j = 0; j < 3; j++) { + p->org[j] = org[j]; + p->vel[j] = (rand() & (int)spread) - (int)(spread * 0.5f); + p->vel[j] += dir[j]; + p->vel[j] += (dir[j] * (rand() & (int)speed)); } -/* - for (j = 0; j < 3; j++) { - float sped = speed * (1 + crandom()) + (speed * 0.3f); - //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); - p->org[j] = org[j]; + /* + for (j = 0; j < 3; j++) { + float sped = speed * (1 + crandom()) + (speed * 0.3f); + //p->org[j] = org[j] + ((crandom() * (spread / 8)) - (spread/16)); + p->org[j] = org[j]; - p->vel[j] = (dir[j]) * sped; - p->vel[j] += ((crandom() * (spread)) - (spread/2)); + p->vel[j] = (dir[j]) * sped; + p->vel[j] += ((crandom() * (spread)) - (spread/2)); - // p->vel[j] *= crandom(); + // p->vel[j] *= crandom(); - } -*/ + } + */ // a little kick up p->vel[2] += (speed * 0.4f); - p->accel[0] = p->accel[1] = p->accel[2] = 0; - p->accel[2] = -(800 * 0.5f); // TODO: insert proper gravity. + p->accel[0] = p->accel[1] = p->accel[2] = 0; + p->accel[2] = -(800 * 0.5f); // TODO: insert proper gravity. - // prepare the initial stretch frame + // prepare the initial stretch frame - p->airfriction = 1.6f; - p->bounce = 1.6f; - if (blendfunc == 666){ - p->bounce = 666; // instantly make a red decal and kill itself. for blood - p->accel[2] = -(800); // TODO: insert proper gravity. - } + p->airfriction = 1.6f; + p->bounce = 1.6f; + if (blendfunc == 666) { + p->bounce = 666; // instantly make a red decal and kill itself. for blood + p->accel[2] = -(800); // TODO: insert proper gravity. + } } // VectorCopy(p->org,p->torg[0]); // a org to stretch from. @@ -1726,7 +1739,7 @@ void R_LFX_Spark (vec3_t org, vec3_t dir, float spread, float speed, vec4_t colo -void R_LFX_Burst (vec3_t org, vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) +void R_LFX_Burst (const vec3_t org, const vec3_t dir, float spread, float speed, vec4_t color1, vec4_t color2, vec4_t color3, vec4_t color4, vec4_t color5, int count, int duration, float scaleup, int blendfunc) { int i, j; int cont = 50; @@ -1734,107 +1747,107 @@ void R_LFX_Burst (vec3_t org, vec3_t dir, float spread, float speed, vec4_t colo cont = count; - for (i = 0; i < cont; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; + for (i = 0; i < cont; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; - p->time = THEtime; + p->time = THEtime; - p->endtime = THEtime+ duration; - p->startfade = THEtime; + p->endtime = THEtime+ duration; + p->startfade = THEtime; - p->rendertype = LFXBURST; - //p->color = EMISIVEFADE; - p->alpha = 1.0f; - p->alphavel = 0.0f; - //p->qolor = (color & ~7) + (rand() & 7); - p->height = p->width = scaleup; + p->rendertype = LFXBURST; + //p->color = EMISIVEFADE; + p->alpha = 1.0f; + p->alphavel = 0.0f; + //p->qolor = (color & ~7) + (rand() & 7); + p->height = p->width = scaleup; - p->endheight = p->height; - p->endwidth = p->width; + p->endheight = p->height; + p->endwidth = p->width; - p->rotate = qfalse; // sparks don't rotate - p->roll = 0; // sparks don't roll + p->rotate = qfalse; // sparks don't rotate + p->roll = 0; // sparks don't roll - p->accel[0] = p->accel[1] = p->accel[2] = 0; + p->accel[0] = p->accel[1] = p->accel[2] = 0; - p->cols[0][0] = color1[0]; - p->cols[1][0] = color1[1]; - p->cols[2][0] = color1[2]; - p->cols[3][0] = color1[3]; + p->cols[0][0] = color1[0]; + p->cols[1][0] = color1[1]; + p->cols[2][0] = color1[2]; + p->cols[3][0] = color1[3]; - p->cols[0][1] = color2[0]; - p->cols[1][1] = color2[1]; - p->cols[2][1] = color2[2]; - p->cols[3][1] = color2[3]; + p->cols[0][1] = color2[0]; + p->cols[1][1] = color2[1]; + p->cols[2][1] = color2[2]; + p->cols[3][1] = color2[3]; - p->cols[0][2] = color3[0]; - p->cols[1][2] = color3[1]; - p->cols[2][2] = color3[2]; - p->cols[3][2] = color3[3]; + p->cols[0][2] = color3[0]; + p->cols[1][2] = color3[1]; + p->cols[2][2] = color3[2]; + p->cols[3][2] = color3[3]; - p->cols[0][3] = color4[0]; - p->cols[1][3] = color4[1]; - p->cols[2][3] = color4[2]; - p->cols[3][3] = color4[3]; + p->cols[0][3] = color4[0]; + p->cols[1][3] = color4[1]; + p->cols[2][3] = color4[2]; + p->cols[3][3] = color4[3]; - p->cols[0][4] = color5[0]; - p->cols[1][4] = color5[1]; - p->cols[2][4] = color5[2]; - p->cols[3][4] = color5[3]; + p->cols[0][4] = color5[0]; + p->cols[1][4] = color5[1]; + p->cols[2][4] = color5[2]; + p->cols[3][4] = color5[3]; - // Manage blending Functions - if (blendfunc == 1) - p->pshader = addball; - else if (blendfunc == 2) - p->pshader = modball; - else if (blendfunc == 3) - p->pshader = subball; - else if (blendfunc == 7) - p->pshader = watburst; - else if (blendfunc == 666) - p->pshader = blood2; - else - p->pshader = alfball; + // Manage blending Functions + if (blendfunc == 1) + p->pshader = addball; + else if (blendfunc == 2) + p->pshader = modball; + else if (blendfunc == 3) + p->pshader = subball; + else if (blendfunc == 7) + p->pshader = watburst; + else if (blendfunc == 666) + p->pshader = blood2; + else + p->pshader = alfball; - p->colortype = P_LFX; + p->colortype = P_LFX; - VectorCopy(org, p->org); + VectorCopy(org, p->org); - // Manage spread of origin and velocity - for (j = 0; j < 3; j++) { - float sped = speed * (1 + crandom()) + (speed * 0.3f); - p->vel[j] = ((crandom() * (spread)) - (spread/2)) / 360; - p->vel[j] *= sped; + // Manage spread of origin and velocity + for (j = 0; j < 3; j++) { + float sped = speed * (1 + crandom()) + (speed * 0.3f); + p->vel[j] = ((crandom() * (spread)) - (spread/2)) / 360; + p->vel[j] *= sped; } - p->accel[0] = p->accel[1] = p->accel[2] = 0; + p->accel[0] = p->accel[1] = p->accel[2] = 0; - // prepare the initial stretch frame + // prepare the initial stretch frame - p->airfriction = 1.6f; - //p->bounce = 2.0f; - VectorCopy(p->org,p->torg[0]); // a org to stretch from. + p->airfriction = 1.6f; + //p->bounce = 2.0f; + VectorCopy(p->org,p->torg[0]); // a org to stretch from. - if (blendfunc == 666){ + if (blendfunc == 666) { p->airfriction = 2.9f; - // p->bounce = 1.3f; + // p->bounce = 1.3f; p->accel[2] = -(PARTICLE_GRAVITY/2); } - // for water splashes - if (blendfunc == 7){ + // for water splashes + if (blendfunc == 7) { p->airfriction = 1.8f; p->bounce = 0.0f; p->vel[0] = dir[0]; @@ -1957,7 +1970,7 @@ void R_LFX_Generic (int type, vec3_t org, vec3_t dir, float alpha, int spread, i // give some turbulence to smokes -void R_LFX_PushSmoke (vec3_t there, float force) +void R_LFX_PushSmoke (const vec3_t there, float force) { // will reimplement properly later } @@ -1988,92 +2001,88 @@ void R_LetsBounce ( particle_t *p) // attempt at generic particles function similar to quake... -void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count) +void R_RunParticleEffect (const vec3_t org, const vec3_t dir, int color, int count) { - int i, j; - particle_t *p; - - for (i = 0; i < count; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - p->die = cl.time + 0.1*(rand()%5); - p->color = (color&~7) + (rand()&7); - p->type = pt_slowgrav; - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + ((rand()&15)-8); - p->vel[j] = dir[j]*15;// + (rand()%300)-150; - } + for (int i = 0; i < count; i++) { + if (!free_particles) + return; + particle_t *p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->die = cl.time + 0.1*(rand()%5); + p->color = (color&~7) + (rand()&7); + p->type = pt_slowgrav; + for (int j=0 ; j<3 ; j++) { + p->org[j] = org[j] + ((rand()&15)-8); + p->vel[j] = dir[j]*15;// + (rand()%300)-150; + } } } // also from Quake! -void R_QarticleExplosion(vec3_t org) +void R_QarticleExplosion(const vec3_t org) { - int i, j; - particle_t *p; + int i, j; + particle_t *p; - for (i = 0; i < 512; i++) { - if (!free_particles) - return; - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; + for (i = 0; i < 512; i++) { + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; - p->rendertype = EMISIVEFADE; - p->alpha = 1.0f; - p->alphavel = 1.0f; - p->time = THEtime; + p->rendertype = EMISIVEFADE; + p->alpha = 1.0f; + p->alphavel = 1.0f; + p->time = THEtime; - p->bubbleit = 0; - // crap for q3's particle system... - p->endtime = THEtime+ 500; - p->startfade = p->endtime; - p->height = 0.5; - p->width = 0.5; - p->endheight = 0.5; - p->endwidth = 0.5; - p->pshader = alfsmoke; - p->qolor = ramp1[0]; + p->bubbleit = 0; + // crap for q3's particle system... + p->endtime = THEtime+ 500; + p->startfade = p->endtime; + p->height = 0.5; + p->width = 0.5; + p->endheight = 0.5; + p->endwidth = 0.5; + p->pshader = alfsmoke; + p->qolor = ramp1[0]; // p->qolor = 44; - VectorCopy(org, p->org); + VectorCopy(org, p->org); - p->ramp = rand() & 3; - if (i & 1) { + p->ramp = rand() & 3; + if (i & 1) { // p->type = P_QUAKE; - for (j = 0; j < 3; j++) { - p->org[j] = org[j] + ((rand() % 32) - 16); - p->vel[j] = (rand() % 512) - 256; - p->accel[j] = p->vel[j] * 4; - } - } else { + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + ((rand() % 32) - 16); + p->vel[j] = (rand() % 512) - 256; + p->accel[j] = p->vel[j] * 4; + } + } + else { // p->type = P_QUAKE; - for (j = 0; j < 3; j++) { - p->org[j] = org[j] + ((rand() % 32) - 16); - p->vel[j] = (rand() % 512) - 256; - p->accel[j] = p->vel[j] * 4; - } + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + ((rand() % 32) - 16); + p->vel[j] = (rand() % 512) - 256; + p->accel[j] = p->vel[j] * 4; + } + } } - } } -void Q_ParticleExplosion (vec3_t org) +void Q_ParticleExplosion (const vec3_t org) { int i, j; particle_t *p; - for (i=0 ; i<1024 ; i++) - { + for (i=0 ; i<1024 ; i++) { if (!free_particles) return; p = free_particles; @@ -2084,20 +2093,16 @@ void Q_ParticleExplosion (vec3_t org) p->die = cl.time + 5; p->color = ramp1[0]; p->ramp = rand()&3; - if (i & 1) - { + if (i & 1) { p->type = pt_explode; - for (j=0 ; j<3 ; j++) - { + for (j=0 ; j<3 ; j++) { p->org[j] = org[j] + ((rand()%32)-16); p->vel[j] = (rand()%512)-256; } } - else - { + else { p->type = pt_explode2; - for (j=0 ; j<3 ; j++) - { + for (j=0 ; j<3 ; j++) { p->org[j] = org[j] + ((rand()%32)-16); p->vel[j] = (rand()%512)-256; } @@ -2118,14 +2123,12 @@ void Q_RocketTrail (vec3_t start, vec3_t end, int type) len = VectorNormalize (vec); if (type < 128) dec = 3; - else - { + else { dec = 1; type -= 128; } - while (len > 0) - { + while (len > 0) { len -= dec; if (!free_particles) @@ -2138,70 +2141,67 @@ void Q_RocketTrail (vec3_t start, vec3_t end, int type) VectorCopy (vec3_origin, p->vel); p->die = cl.time + 2; - switch (type) - { - case 0: // rocket trail - p->ramp = (rand()&3); - p->qolor = ramp3[(int)p->ramp]; - p->type = pt_fire; - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - break; + switch (type) { + case 0: // rocket trail + p->ramp = (rand()&3); + p->qolor = ramp3[(int)p->ramp]; + p->type = pt_fire; + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + break; - case 1: // smoke smoke - p->ramp = (rand()&3) + 2; - p->color = ramp3[(int)p->ramp]; - p->type = pt_fire; - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - break; + case 1: // smoke smoke + p->ramp = (rand()&3) + 2; + p->color = ramp3[(int)p->ramp]; + p->type = pt_fire; + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + break; - case 2: // blood - p->type = pt_grav; - p->color = 67 + (rand()&3); - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - break; + case 2: // blood + p->type = pt_grav; + p->color = 67 + (rand()&3); + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + break; - case 3: - case 5: // tracer - p->die = cl.time + 0.5; - p->type = pt_static; - if (type == 3) - p->color = 52 + ((tracercount&4)<<1); - else - p->color = 230 + ((tracercount&4)<<1); + case 3: + case 5: // tracer + p->die = cl.time + 0.5; + p->type = pt_static; + if (type == 3) + p->color = 52 + ((tracercount&4)<<1); + else + p->color = 230 + ((tracercount&4)<<1); - tracercount++; + tracercount++; - VectorCopy (start, p->org); - if (tracercount & 1) - { - p->vel[0] = 30*vec[1]; - p->vel[1] = 30*-vec[0]; - } - else - { - p->vel[0] = 30*-vec[1]; - p->vel[1] = 30*vec[0]; - } - break; + VectorCopy (start, p->org); + if (tracercount & 1) { + p->vel[0] = 30*vec[1]; + p->vel[1] = 30*-vec[0]; + } + else { + p->vel[0] = 30*-vec[1]; + p->vel[1] = 30*vec[0]; + } + break; - case 4: // slight blood - p->type = pt_grav; - p->color = 67 + (rand()&3); - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - len -= 3; - break; + case 4: // slight blood + p->type = pt_grav; + p->color = 67 + (rand()&3); + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + len -= 3; + break; - case 6: // voor trail - p->color = 9*16 + 8 + (rand()&3); - p->type = pt_static; - p->die = cl.time + 0.3; - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()&15)-8); - break; + case 6: // voor trail + p->color = 9*16 + 8 + (rand()&3); + p->type = pt_static; + p->die = cl.time + 0.3; + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()&15)-8); + break; } @@ -2243,44 +2243,39 @@ void LFX_ShaderInit ( void ) // 1996 - it's like the first game ok // - just dots -void LFX_ParticleEffect1996 (int effect, vec3_t org, vec3_t dir) +void LFX_ParticleEffect1996 (int effect, const vec3_t org, const vec3_t dir) { vec3_t notatall; // Smoke trails on grenades and rockets - if (effect == 1) - { - R_RunParticleEffect (org, notatall, 10, 8); - //Q_RocketTrail(org, dir, r_leidebug->integer); - } + if (effect == 1) { + R_RunParticleEffect (org, notatall, 10, 8); + //Q_RocketTrail(org, dir, r_leidebug->integer); + } // Bullet Hit - if (effect == 2 || effect == 3) - { - R_RunParticleEffect (org, notatall, 6, 20); + if (effect == 2 || effect == 3) { + R_RunParticleEffect (org, notatall, 6, 20); - } + } // Grenade/Rocket/Prox Explosion - else if (effect == 5 || effect == 4 || effect == 11) - { - Q_ParticleExplosion(org); + else if (effect == 5 || effect == 4 || effect == 11) { + Q_ParticleExplosion(org); - } + } // Blood Sprays for bullets - if (effect == 14) - { + if (effect == 14) { R_RunParticleEffect (org, dir,21, 20); - } + } // Water Splash for bullets - if (effect == 19) - { + if (effect == 19) { R_RunParticleEffect (org, dir,41, 20); - } + } } @@ -2289,7 +2284,7 @@ void LFX_ParticleEffect1996 (int effect, vec3_t org, vec3_t dir) // 200X - most games of that decade... // - usually ltos of particles // - usually -void LFX_ParticleEffect200X (int effect, vec3_t org, vec3_t dir) +void LFX_ParticleEffect200X (int effect, const vec3_t org, const vec3_t dir) { vec3_t origin, sprOrg, sprVel; // laziness vec4_t colory, colory2, colory3, colory4; @@ -2299,170 +2294,332 @@ void LFX_ParticleEffect200X (int effect, vec3_t org, vec3_t dir) VectorCopy(dir, sprVel); // Smoke trails on grenades and rockets - if (effect == 1) - { - colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 1.0; - colory2[0] = 0.5; colory2[1] = 0.5; colory2[2] = 0.5; colory2[3] = 0.8; - colory3[0] = 0.5; colory3[1] = 0.4; colory3[2] = 0.3; colory3[3] = 0.5; - colory4[0] = 0.5; colory4[1] = 0.4; colory4[2] = 0.3; colory4[3] = 0.0; - R_LFX_Smoke2 (sprOrg, sprVel, 1 + (random()*3), 0.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 2470, 4, 8+ (random()*6), 4); - } + if (effect == 1) { + colory[0] = 0.7; + colory[1] = 0.7; + colory[2] = 0.7; + colory[3] = 1.0; + colory2[0] = 0.5; + colory2[1] = 0.5; + colory2[2] = 0.5; + colory2[3] = 0.8; + colory3[0] = 0.5; + colory3[1] = 0.4; + colory3[2] = 0.3; + colory3[3] = 0.5; + colory4[0] = 0.5; + colory4[1] = 0.4; + colory4[2] = 0.3; + colory4[3] = 0.0; + R_LFX_Smoke2 (sprOrg, sprVel, 1 + (random()*3), 0.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 2470, 4, 8+ (random()*6), 4); + } // Bullet Hit - if (effect == 2) - { - colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 0.0; - colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.6; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.6; colory4[1] = 0.6; colory4[2] = 0.6; colory4[3] = 0.0; + if (effect == 2) { + colory[0] = 0.7; + colory[1] = 0.7; + colory[2] = 0.7; + colory[3] = 0.0; + colory2[0] = 0.7; + colory2[1] = 0.7; + colory2[2] = 0.7; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.6; + colory3[2] = 0.6; + colory3[3] = 0.8; + colory4[0] = 0.6; + colory4[1] = 0.6; + colory4[2] = 0.6; + colory4[3] = 0.0; VectorMA( origin, 4, dir, sprOrg ); VectorScale( dir, 1, sprVel ); - // Sparks - colory[0] = 1; colory[1] = 1; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 1; colory2[1] = 1; colory2[2] = 0.8; colory2[3] = 0.9; - colory3[0] = 0.7; colory3[1] = 0.5; colory3[2] = 0.2; colory3[3] = 0.7; - colory4[0] = 0.1; colory4[1] = 0.06; colory4[2] = 0.0; colory4[3] = 0.0; + // Sparks + colory[0] = 1; + colory[1] = 1; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 1; + colory2[1] = 1; + colory2[2] = 0.8; + colory2[3] = 0.9; + colory3[0] = 0.7; + colory3[1] = 0.5; + colory3[2] = 0.2; + colory3[3] = 0.7; + colory4[0] = 0.1; + colory4[1] = 0.06; + colory4[2] = 0.0; + colory4[3] = 0.0; - R_LFX_Burst (sprOrg, sprVel, 8366, 2, colory, colory2, colory3, colory4, colory4, 4, 50, 2, 1); + R_LFX_Burst (sprOrg, sprVel, 8366, 2, colory, colory2, colory3, colory4, colory4, 4, 50, 2, 1); - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 1, sprVel ); - R_LFX_Spark (sprOrg, sprVel, 95, 325, colory, colory2, colory3, colory4, colory4, 5, 140, 0.5f, 1); - R_LFX_Spark (sprOrg, sprVel, 95, 85, colory, colory2, colory3, colory4, colory4, 1, 1540, 0.5f, 1); + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 1, sprVel ); + R_LFX_Spark (sprOrg, sprVel, 95, 325, colory, colory2, colory3, colory4, colory4, 5, 140, 0.5f, 1); + R_LFX_Spark (sprOrg, sprVel, 95, 85, colory, colory2, colory3, colory4, colory4, 1, 1540, 0.5f, 1); - //R_LFX_PushSmoke (sprOrg, 44); + //R_LFX_PushSmoke (sprOrg, 44); - } + } // Shotgun Hit - if (effect == 3) - { - colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 0.0; - colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.6; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.6; colory4[1] = 0.6; colory4[2] = 0.6; colory4[3] = 0.0; - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 7, sprVel ); - R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); - R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); - colory[0] = 0.9; colory[1] = 0.8; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 0.7; colory2[1] = 0.5; colory2[2] = 0.2; colory2[3] = 0.9; - colory3[0] = 0.1; colory3[1] = 0.1; colory3[2] = 0.1; colory3[3] = 0.7; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - VectorMA( origin, 4, dir, sprOrg ); - VectorScale( dir, 64, sprVel ); - R_LFX_Shock (origin, dir, 0, 32, colory, colory2, colory3, colory4, colory4, 1, 200, 50,1); - colory[0] = 1; colory[1] = 1; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 1; colory2[1] = 1; colory2[2] = 0.8; colory2[3] = 0.9; - colory3[0] = 0.7; colory3[1] = 0.5; colory3[2] = 0.2; colory3[3] = 0.7; - colory4[0] = 0.1; colory4[1] = 0.06; colory4[2] = 0.0; colory4[3] = 0.0; - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 1, sprVel ); - R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 3, 2540, 0.5f, 1); - } + if (effect == 3) { + colory[0] = 0.7; + colory[1] = 0.7; + colory[2] = 0.7; + colory[3] = 0.0; + colory2[0] = 0.7; + colory2[1] = 0.7; + colory2[2] = 0.7; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.6; + colory3[2] = 0.6; + colory3[3] = 0.8; + colory4[0] = 0.6; + colory4[1] = 0.6; + colory4[2] = 0.6; + colory4[3] = 0.0; + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 7, sprVel ); + R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); + R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); + colory[0] = 0.9; + colory[1] = 0.8; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 0.7; + colory2[1] = 0.5; + colory2[2] = 0.2; + colory2[3] = 0.9; + colory3[0] = 0.1; + colory3[1] = 0.1; + colory3[2] = 0.1; + colory3[3] = 0.7; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorMA( origin, 4, dir, sprOrg ); + VectorScale( dir, 64, sprVel ); + R_LFX_Shock (origin, dir, 0, 32, colory, colory2, colory3, colory4, colory4, 1, 200, 50,1); + colory[0] = 1; + colory[1] = 1; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 1; + colory2[1] = 1; + colory2[2] = 0.8; + colory2[3] = 0.9; + colory3[0] = 0.7; + colory3[1] = 0.5; + colory3[2] = 0.2; + colory3[3] = 0.7; + colory4[0] = 0.1; + colory4[1] = 0.06; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 1, sprVel ); + R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 3, 2540, 0.5f, 1); + } // Plasma Hit - if (effect == 6) - { - colory[0] = 1.0; colory[1] = 0.7; colory[2] = 1.0; colory[3] = 0.0; - colory2[0] = 0.3; colory2[1] = 0.7; colory2[2] = 1.0; colory2[3] = 0.5; - colory3[0] = 0.1; colory3[1] = 0.2; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 7, sprVel ); - R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); - VectorMA( origin, 2, dir, sprOrg ); - VectorScale( dir, 64, sprVel ); - R_LFX_Shock (sprOrg, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1,600, 80,1); - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 1, sprVel ); - R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 5, 5540, 0.5f, 1); - } + if (effect == 6) { + colory[0] = 1.0; + colory[1] = 0.7; + colory[2] = 1.0; + colory[3] = 0.0; + colory2[0] = 0.3; + colory2[1] = 0.7; + colory2[2] = 1.0; + colory2[3] = 0.5; + colory3[0] = 0.1; + colory3[1] = 0.2; + colory3[2] = 0.6; + colory3[3] = 0.8; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 7, sprVel ); + R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); + VectorMA( origin, 2, dir, sprOrg ); + VectorScale( dir, 64, sprVel ); + R_LFX_Shock (sprOrg, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1,600, 80,1); + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 1, sprVel ); + R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 5, 5540, 0.5f, 1); + } // Lightning Hit - if (effect == 8) - { - colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 0.0; - colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.6; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.6; colory4[1] = 0.6; colory4[2] = 0.6; colory4[3] = 0.0; - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 7, sprVel ); - R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); - } + if (effect == 8) { + colory[0] = 0.7; + colory[1] = 0.7; + colory[2] = 0.7; + colory[3] = 0.0; + colory2[0] = 0.7; + colory2[1] = 0.7; + colory2[2] = 0.7; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.6; + colory3[2] = 0.6; + colory3[3] = 0.8; + colory4[0] = 0.6; + colory4[1] = 0.6; + colory4[2] = 0.6; + colory4[3] = 0.0; + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 7, sprVel ); + R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); + } // Grenade/Rocket/Prox Explosion - else if (effect == 5 || effect == 4 || effect == 11) - { + else if (effect == 5 || effect == 4 || effect == 11) { - colory[0] = 1.0; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 1.0; colory2[1] = 1.0; colory2[2] = 0.5; colory2[3] = 0.9; - colory3[0] = 0.7; colory3[1] = 0.3; colory3[2] = 0.1; colory3[3] = 0.7; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - VectorMA( origin, 4, dir, sprOrg ); - VectorScale( dir, 64, sprVel ); + colory[0] = 1.0; + colory[1] = 1.0; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 1.0; + colory2[1] = 1.0; + colory2[2] = 0.5; + colory2[3] = 0.9; + colory3[0] = 0.7; + colory3[1] = 0.3; + colory3[2] = 0.1; + colory3[3] = 0.7; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorMA( origin, 4, dir, sprOrg ); + VectorScale( dir, 64, sprVel ); - R_LFX_Shock (sprOrg, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 500, 270, 1); + R_LFX_Shock (sprOrg, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 500, 270, 1); - // fireball + // fireball - colory[0] = 1.0; colory[1] = 0.2; colory[2] = 0.1; colory[3] = 0.0; - colory2[0] = 0.5; colory2[1] = 0.0; colory2[2] = 0.0; colory2[3] = 0.2; - colory3[0] = 0.1; colory3[1] = 0.0; colory3[2] = 0.0; colory3[3] = 0.7; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - VectorMA( origin, 12, dir, sprOrg ); - VectorScale( dir, 64, sprVel ); + colory[0] = 1.0; + colory[1] = 0.2; + colory[2] = 0.1; + colory[3] = 0.0; + colory2[0] = 0.5; + colory2[1] = 0.0; + colory2[2] = 0.0; + colory2[3] = 0.2; + colory3[0] = 0.1; + colory3[1] = 0.0; + colory3[2] = 0.0; + colory3[3] = 0.7; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorMA( origin, 12, dir, sprOrg ); + VectorScale( dir, 64, sprVel ); - R_LFX_Smoke (sprOrg, sprVel, 32, 3.54, colory, colory2, colory3, colory4, colory4, 16, 1000, 94, 1); + R_LFX_Smoke (sprOrg, sprVel, 32, 3.54, colory, colory2, colory3, colory4, colory4, 16, 1000, 94, 1); - colory[0] = 1.0; colory[1] = 1.0; colory[2] = 0.9; colory[3] = 1.0; - colory2[0] = 1.0; colory2[1] = 0.7; colory2[2] = 0.2; colory2[3] = 0.9; - colory3[0] = 0.3; colory3[1] = 0.2; colory3[2] = 0.1; colory3[3] = 0.7; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 1.0; + colory[1] = 1.0; + colory[2] = 0.9; + colory[3] = 1.0; + colory2[0] = 1.0; + colory2[1] = 0.7; + colory2[2] = 0.2; + colory2[3] = 0.9; + colory3[0] = 0.3; + colory3[1] = 0.2; + colory3[2] = 0.1; + colory3[3] = 0.7; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; - R_LFX_Smoke (sprOrg, sprVel, 62, 2, colory, colory2, colory3, colory4, colory4, 12, 200,84, 8); - R_LFX_Smoke (sprOrg, sprVel, 32, 1.54, colory, colory2, colory3, colory4, colory4, 22, 600, 74, 8); + R_LFX_Smoke (sprOrg, sprVel, 62, 2, colory, colory2, colory3, colory4, colory4, 12, 200,84, 8); + R_LFX_Smoke (sprOrg, sprVel, 32, 1.54, colory, colory2, colory3, colory4, colory4, 22, 600, 74, 8); - R_LFX_Smoke (sprOrg, sprVel, 44, 1.3, colory, colory2, colory3, colory4, colory4, 3, 800,3, 8); + R_LFX_Smoke (sprOrg, sprVel, 44, 1.3, colory, colory2, colory3, colory4, colory4, 3, 800,3, 8); - R_LFX_Smoke (sprOrg, sprVel, 32, 0.54, colory, colory2, colory3, colory4, colory4, 12, 600, 74, 8); + R_LFX_Smoke (sprOrg, sprVel, 32, 0.54, colory, colory2, colory3, colory4, colory4, 12, 600, 74, 8); - // Shroom Cloud - VectorMA( origin, 16, dir, sprOrg ); - VectorScale( dir, 64, sprVel ); + // Shroom Cloud + VectorMA( origin, 16, dir, sprOrg ); + VectorScale( dir, 64, sprVel ); - colory[0] = 0.5; colory[1] = 0.0; colory[2] = 0.0; colory[3] = 0.0; - colory2[0] = 1.0; colory2[1] = 1.0; colory2[2] = 0.2; colory2[3] = 0.2; - colory3[0] = 0.5; colory3[1] = 0.1; colory3[2] = 0.0; colory3[3] = 0.5; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - R_LFX_Smoke (sprOrg, sprVel, 3, 0.7, colory, colory2, colory3, colory4, colory4, 22, 300,135, 8); + colory[0] = 0.5; + colory[1] = 0.0; + colory[2] = 0.0; + colory[3] = 0.0; + colory2[0] = 1.0; + colory2[1] = 1.0; + colory2[2] = 0.2; + colory2[3] = 0.2; + colory3[0] = 0.5; + colory3[1] = 0.1; + colory3[2] = 0.0; + colory3[3] = 0.5; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + R_LFX_Smoke (sprOrg, sprVel, 3, 0.7, colory, colory2, colory3, colory4, colory4, 22, 300,135, 8); - // Sparks! + // Sparks! - colory[0] = 1; colory[1] = 1; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 1; colory2[1] = 1; colory2[2] = 0.8; colory2[3] = 0.9; - colory3[0] = 0.7; colory3[1] = 0.5; colory3[2] = 0.2; colory3[3] = 0.7; - colory4[0] = 0.1; colory4[1] = 0.06; colory4[2] = 0.0; colory4[3] = 0.0; - VectorMA( origin, 12, dir, sprOrg ); - VectorScale( dir, 64, sprVel ); + colory[0] = 1; + colory[1] = 1; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 1; + colory2[1] = 1; + colory2[2] = 0.8; + colory2[3] = 0.9; + colory3[0] = 0.7; + colory3[1] = 0.5; + colory3[2] = 0.2; + colory3[3] = 0.7; + colory4[0] = 0.1; + colory4[1] = 0.06; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorMA( origin, 12, dir, sprOrg ); + VectorScale( dir, 64, sprVel ); - R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 15, 240, 22, 1); + R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 15, 240, 22, 1); - R_LFX_Spark (sprOrg, sprVel, 175, 5, colory, colory2, colory3, colory4, colory4, 25, 1240, 0.8f, 1); + R_LFX_Spark (sprOrg, sprVel, 175, 5, colory, colory2, colory3, colory4, colory4, 25, 1240, 0.8f, 1); - } + } // BFG else if (effect == 9) { - colory[0] = 1.0; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 0.3; colory2[1] = 1.0; colory2[2] = 0.2; colory2[3] = 0.9; - colory3[0] = 0.0; colory3[1] = 0.3; colory3[2] = 0.1; colory3[3] = 0.7; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 1.0; + colory[1] = 1.0; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 0.3; + colory2[1] = 1.0; + colory2[2] = 0.2; + colory2[3] = 0.9; + colory3[0] = 0.0; + colory3[1] = 0.3; + colory3[2] = 0.1; + colory3[3] = 0.7; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; VectorMA( origin, 4, dir, sprOrg ); VectorScale( dir, 64, sprVel ); @@ -2502,18 +2659,42 @@ void LFX_ParticleEffect200X (int effect, vec3_t org, vec3_t dir) // Nail Hit if (effect == 10) { - colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 0.0; - colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.6; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.6; colory4[1] = 0.6; colory4[2] = 0.6; colory4[3] = 0.0; + colory[0] = 0.7; + colory[1] = 0.7; + colory[2] = 0.7; + colory[3] = 0.0; + colory2[0] = 0.7; + colory2[1] = 0.7; + colory2[2] = 0.7; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.6; + colory3[2] = 0.6; + colory3[3] = 0.8; + colory4[0] = 0.6; + colory4[1] = 0.6; + colory4[2] = 0.6; + colory4[3] = 0.0; VectorMA( origin, 1, dir, sprOrg ); VectorScale( dir, 7, sprVel ); R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); - colory[0] = 0.7; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 0.0; - colory2[0] = 0.3; colory2[1] = 0.7; colory2[2] = 1.0; colory2[3] = 0.5; - colory3[0] = 0.0; colory3[1] = 0.2; colory3[2] = 0.5; colory3[3] = 0.8; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 0.7; + colory[1] = 1.0; + colory[2] = 1.0; + colory[3] = 0.0; + colory2[0] = 0.3; + colory2[1] = 0.7; + colory2[2] = 1.0; + colory2[3] = 0.5; + colory3[0] = 0.0; + colory3[1] = 0.2; + colory3[2] = 0.5; + colory3[3] = 0.8; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; VectorMA( origin, 4, dir, sprOrg ); VectorScale( dir, 1, sprVel ); @@ -2529,107 +2710,163 @@ void LFX_ParticleEffect200X (int effect, vec3_t org, vec3_t dir) } // Blood Sprays for bullets - if (effect == 14 && com_blood->integer) - { - sprVel[2] += 54; - colory[0] = 1.0; colory[1] = 0.0; colory[2] = 0.0; colory[3] = 1.0; - colory2[0] = 0.8; colory2[1] = 0.0; colory2[2] = 0.0; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.0; colory3[2] = 0.0; colory3[3] = 0.8; - colory4[0] = 0.3; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); - //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); - R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 2, 1755, 12, 666); - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 2, sprVel ); - //R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 8, 2386, 0.5f, 666); - } + if (effect == 14 && com_blood->integer) { + sprVel[2] += 54; + colory[0] = 1.0; + colory[1] = 0.0; + colory[2] = 0.0; + colory[3] = 1.0; + colory2[0] = 0.8; + colory2[1] = 0.0; + colory2[2] = 0.0; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.0; + colory3[2] = 0.0; + colory3[3] = 0.8; + colory4[0] = 0.3; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); + //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); + R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 2, 1755, 12, 666); + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 2, sprVel ); + //R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 8, 2386, 0.5f, 666); + } // "Blood" Sprays for bullets - if (effect == 14 && !com_blood->integer) - { + if (effect == 14 && !com_blood->integer) { - // nonviolent blue center - colory[0] = 0.0; colory[1] = 0.7; colory[2] = 1.0; colory[3] = 0.0; - colory2[0] = 0.0; colory2[1] = 0.0; colory2[2] = 1.0; colory2[3] = 0.5; - colory3[0] = 0.0; colory3[1] = 0.0; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 2, 105, 12, 1); - R_LFX_Smoke (sprOrg, sprVel, 0, 0, colory, colory2, colory3, colory4, colory4, 32, 400, -33, 1); - VectorMA( origin, 1, dir, sprOrg ); - VectorScale( dir, 1, sprVel ); + // nonviolent blue center + colory[0] = 0.0; + colory[1] = 0.7; + colory[2] = 1.0; + colory[3] = 0.0; + colory2[0] = 0.0; + colory2[1] = 0.0; + colory2[2] = 1.0; + colory2[3] = 0.5; + colory3[0] = 0.0; + colory3[1] = 0.0; + colory3[2] = 0.6; + colory3[3] = 0.8; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 2, 105, 12, 1); + R_LFX_Smoke (sprOrg, sprVel, 0, 0, colory, colory2, colory3, colory4, colory4, 32, 400, -33, 1); + VectorMA( origin, 1, dir, sprOrg ); + VectorScale( dir, 1, sprVel ); - colory[0] = 1; colory[1] = 1; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 1; colory2[1] = 1; colory2[2] = 0.8; colory2[3] = 0.9; - colory3[0] = 0.7; colory3[1] = 0.5; colory3[2] = 0.2; colory3[3] = 0.7; - colory4[0] = 0.1; colory4[1] = 0.06; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 1; + colory[1] = 1; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 1; + colory2[1] = 1; + colory2[2] = 0.8; + colory2[3] = 0.9; + colory3[0] = 0.7; + colory3[1] = 0.5; + colory3[2] = 0.2; + colory3[3] = 0.7; + colory4[0] = 0.1; + colory4[1] = 0.06; + colory4[2] = 0.0; + colory4[3] = 0.0; - R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 2,586, 0.5f, 1); - R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 255, 39,1); - } + R_LFX_Spark (sprOrg, sprVel, 25, 85, colory, colory2, colory3, colory4, colory4, 2,586, 0.5f, 1); + R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 255, 39,1); + } // Blood Spray for a gibbing - if (effect == 16 && com_blood->integer) - { - sprVel[2] += 124; - colory[0] = 1.0; colory[1] = 0.0; colory[2] = 0.0; colory[3] = 1.0; - colory2[0] = 0.8; colory2[1] = 0.0; colory2[2] = 0.0; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.0; colory3[2] = 0.0; colory3[3] = 0.8; - colory4[0] = 0.3; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + if (effect == 16 && com_blood->integer) { + sprVel[2] += 124; + colory[0] = 1.0; + colory[1] = 0.0; + colory[2] = 0.0; + colory[3] = 1.0; + colory2[0] = 0.8; + colory2[1] = 0.0; + colory2[2] = 0.0; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.0; + colory3[2] = 0.0; + colory3[3] = 0.8; + colory4[0] = 0.3; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; // R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); // R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); - R_LFX_Burst (sprOrg, sprVel, 275, 4, colory, colory2, colory3, colory4, colory4, 9, 1455, 42, 666); - } + R_LFX_Burst (sprOrg, sprVel, 275, 4, colory, colory2, colory3, colory4, colory4, 9, 1455, 42, 666); + } // Water Splash for bullets - if (effect == 19) - { - colory[0] = 1.0; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 0.3; colory2[1] = 0.5; colory2[2] = 0.6; colory2[3] = 0.6; - colory3[0] = 0.1; colory3[1] = 0.2; colory3[2] = 0.3; colory3[3] = 0.3; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - VectorScale( dir, 39, sprVel ); - R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 800, 80,14); - R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 1900, 5, 7); - R_LFX_Spark (sprOrg, sprVel, 134, 4, colory, colory2, colory3, colory4, colory4, 7, 1286, 0.5f, 1); - } -/* - // these are not properly implemented through cgame yet as they call *every* frame instead of being a truly one shot effect. - // muzzieflash plasmagun - if (effect == 66) - { - colory[0] = 1.0; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 0.3; colory2[1] = 0.5; colory2[2] = 0.6; colory2[3] = 0.5; - colory3[0] = 0.1; colory3[1] = 0.2; colory3[2] = 0.3; colory3[3] = 0.8; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - VectorScale( dir, 39, sprVel ); - R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 255, 8,1); - //R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 144, 2, 7); - //R_LFX_Spark (sprOrg, sprVel, 134, 4, colory, colory2, colory3, colory4, colory4, 7, 1556, 0.25f, 1); - } - // muzzleflash shotgun - if (effect == 63) - { - colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 0.0; - colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.6; colory3[2] = 0.6; colory3[3] = 0.8; - colory4[0] = 0.6; colory4[1] = 0.6; colory4[2] = 0.6; colory4[3] = 0.0; + if (effect == 19) { + colory[0] = 1.0; + colory[1] = 1.0; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 0.3; + colory2[1] = 0.5; + colory2[2] = 0.6; + colory2[3] = 0.6; + colory3[0] = 0.1; + colory3[1] = 0.2; + colory3[2] = 0.3; + colory3[3] = 0.3; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + VectorScale( dir, 39, sprVel ); + R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 800, 80,14); + R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 1900, 5, 7); + R_LFX_Spark (sprOrg, sprVel, 134, 4, colory, colory2, colory3, colory4, colory4, 7, 1286, 0.5f, 1); + } + /* + // these are not properly implemented through cgame yet as they call *every* frame instead of being a truly one shot effect. + // muzzieflash plasmagun + if (effect == 66) + { + colory[0] = 1.0; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 1.0; + colory2[0] = 0.3; colory2[1] = 0.5; colory2[2] = 0.6; colory2[3] = 0.5; + colory3[0] = 0.1; colory3[1] = 0.2; colory3[2] = 0.3; colory3[3] = 0.8; + colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + VectorScale( dir, 39, sprVel ); + R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 255, 8,1); + //R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 144, 2, 7); + //R_LFX_Spark (sprOrg, sprVel, 134, 4, colory, colory2, colory3, colory4, colory4, 7, 1556, 0.25f, 1); + } + // muzzleflash shotgun + if (effect == 63) + { + colory[0] = 0.7; colory[1] = 0.7; colory[2] = 0.7; colory[3] = 0.0; + colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.5; + colory3[0] = 0.6; colory3[1] = 0.6; colory3[2] = 0.6; colory3[3] = 0.8; + colory4[0] = 0.6; colory4[1] = 0.6; colory4[2] = 0.6; colory4[3] = 0.0; - //R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 144, 2, 7); + //R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 144, 2, 7); - R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*55.7), colory, colory2, colory3, colory4, colory4, 4, 300 + (random()*3000), 2, 8+ (random()*6), 4); - VectorScale( dir, 39, sprVel ); - R_LFX_Spark (sprOrg, sprVel, 14, 8, colory, colory2, colory3, colory4, colory4, 22, 556, 0.25f, 1); - } + R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*55.7), colory, colory2, colory3, colory4, colory4, 4, 300 + (random()*3000), 2, 8+ (random()*6), 4); + VectorScale( dir, 39, sprVel ); + R_LFX_Spark (sprOrg, sprVel, 14, 8, colory, colory2, colory3, colory4, colory4, 22, 556, 0.25f, 1); + } -*/ + */ } // 1997 - // - alpha blends ONLY! // - low amounts of polygons // - high atlas usage -void LFX_ParticleEffect1997 (int effect, vec3_t org, vec3_t dir) +void LFX_ParticleEffect1997 (int effect, const vec3_t org, const vec3_t dir) { vec3_t origin, sprOrg, sprVel; // laziness vec4_t colory, colory2, colory3, colory4; @@ -2640,85 +2877,86 @@ void LFX_ParticleEffect1997 (int effect, vec3_t org, vec3_t dir) // Smoke trails on grenades and rockets // this should be several smoke atlases along a line. - if (effect == 1) - { + if (effect == 1) { - } + } // Bullet Hit // a smoke puff, a badly looping spark model, and an occasional ball spark (no stretch) of a random amount from 1 to 6 balls. - if (effect == 2) - { + if (effect == 2) { - } + } // Shotgun Hit // can be just smoke puffs, preferably atlasy. - if (effect == 3) - { + if (effect == 3) { - } + } // Plasma Hit // should become a plain sprite atlas animation. - if (effect == 6) - { + if (effect == 6) { - } + } // Lightning Hit // can become a plain sprite, but we already have that, so..... - if (effect == 8) - { + if (effect == 8) { - } + } // Grenade/Rocket/Prox Explosion // should be an explosion atlas, but on later versions there's several more delayed explosion atlases to spice up the variety - else if (effect == 5 || effect == 4 || effect == 11) - { + else if (effect == 5 || effect == 4 || effect == 11) { - } + } // BFG, could be an expanding sphere with an explosion atlas - else if (effect == 9) - { + else if (effect == 9) { - } + } // Blood Sprays for bullets - if (effect == 14 && com_blood->integer) - { - colory[0] = 1.0; colory[1] = 0.0; colory[2] = 0.0; colory[3] = 1.0; - colory2[0] = 0.8; colory2[1] = 0.0; colory2[2] = 0.0; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.0; colory3[2] = 0.0; colory3[3] = 0.8; - colory4[0] = 0.3; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; - //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); - //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); - } + if (effect == 14 && com_blood->integer) { + colory[0] = 1.0; + colory[1] = 0.0; + colory[2] = 0.0; + colory[3] = 1.0; + colory2[0] = 0.8; + colory2[1] = 0.0; + colory2[2] = 0.0; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.0; + colory3[2] = 0.0; + colory3[3] = 0.8; + colory4[0] = 0.3; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; + //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); + //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); + } // "Blood" Sprays for bullets - if (effect == 14 && !com_blood->integer) - { - // usually there are none. - } + if (effect == 14 && !com_blood->integer) { + // usually there are none. + } // Blood Spray for a gibbing - if (effect == 16 && com_blood->integer) - { - // usually there are none. - } + if (effect == 16 && com_blood->integer) { + // usually there are none. + } // Water Splash for bullets - a splash atlas burst animation. - if (effect == 19) - { + if (effect == 19) { - } + } } @@ -2730,7 +2968,7 @@ void LFX_ParticleEffect1997 (int effect, vec3_t org, vec3_t dir) // - sparks, but sparsely and no collision // - some flare testing on some effects -void LFX_ParticleEffect1998 (int effect, vec3_t org, vec3_t dir) +void LFX_ParticleEffect1998 (int effect, const vec3_t org, const vec3_t dir) { vec3_t origin, sprOrg, sprVel; // laziness vec4_t colory, colory2, colory3, colory4; @@ -2753,10 +2991,22 @@ void LFX_ParticleEffect1998 (int effect, vec3_t org, vec3_t dir) if (effect == 2) { // Sparks - colory[0] = 0.6; colory[1] = 0.4; colory[2] = 0.0; colory[3] = 1.0; - colory2[0] = 0.7; colory2[1] = 0.4; colory2[2] = 0.0; colory2[3] = 0.9; - colory3[0] = 0.5; colory3[1] = 0.2; colory3[2] = 0.0; colory3[3] = 0.7; - colory4[0] = 0.1; colory4[1] = 0.06; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 0.6; + colory[1] = 0.4; + colory[2] = 0.0; + colory[3] = 1.0; + colory2[0] = 0.7; + colory2[1] = 0.4; + colory2[2] = 0.0; + colory2[3] = 0.9; + colory3[0] = 0.5; + colory3[1] = 0.2; + colory3[2] = 0.0; + colory3[3] = 0.7; + colory4[0] = 0.1; + colory4[1] = 0.06; + colory4[2] = 0.0; + colory4[3] = 0.0; VectorMA( origin, 1, dir, sprOrg ); VectorScale( dir, 1, sprVel ); @@ -2764,35 +3014,47 @@ void LFX_ParticleEffect1998 (int effect, vec3_t org, vec3_t dir) R_LFX_Spark (sprOrg, sprVel, 11, 32, colory, colory2, colory3, colory4, colory4, 4, 440, 0.5f, 1); sprVel[2] += 64; R_LFX_Generic ( - LFXSMOKE, // Particle Type - sprOrg, // Origin - sprVel, // Velocity - 1.0f, // Starting Alpha - 85, // Spread Factor - 3, // Random Origin Offset - 0, // Random Roll Value - 0, // Additional Random Speed - 8, // Particle Color Red - 8, // Particle Color Green - 8, // Particle Color Blue - 8, // Particle Count - 400, // Particle Life - 0.5f, // Particle Scale - 0.5f, // Particle Scale Towards - 0.1f, // Particle Bounce Factor - 0, // Air Friction (stopping particle velocity in air) - -16.0f, // Particle Gravity Factor - 0.0f, // Particle Rolling Friction - alfball // Particle Shader + LFXSMOKE, // Particle Type + sprOrg, // Origin + sprVel, // Velocity + 1.0f, // Starting Alpha + 85, // Spread Factor + 3, // Random Origin Offset + 0, // Random Roll Value + 0, // Additional Random Speed + 8, // Particle Color Red + 8, // Particle Color Green + 8, // Particle Color Blue + 8, // Particle Count + 400, // Particle Life + 0.5f, // Particle Scale + 0.5f, // Particle Scale Towards + 0.1f, // Particle Bounce Factor + 0, // Air Friction (stopping particle velocity in air) + -16.0f, // Particle Gravity Factor + 0.0f, // Particle Rolling Friction + alfball // Particle Shader ); } else if (effect == 3) { - if (rand() < 0.5f){ // only happens for half the pellets + if (rand() < 0.5f) { // only happens for half the pellets // Sparks - colory[0] = 0.6; colory[1] = 0.4; colory[2] = 0.0; colory[3] = 1.0; - colory2[0] = 0.7; colory2[1] = 0.4; colory2[2] = 0.0; colory2[3] = 0.9; - colory3[0] = 0.5; colory3[1] = 0.2; colory3[2] = 0.0; colory3[3] = 0.7; - colory4[0] = 0.1; colory4[1] = 0.06; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 0.6; + colory[1] = 0.4; + colory[2] = 0.0; + colory[3] = 1.0; + colory2[0] = 0.7; + colory2[1] = 0.4; + colory2[2] = 0.0; + colory2[3] = 0.9; + colory3[0] = 0.5; + colory3[1] = 0.2; + colory3[2] = 0.0; + colory3[3] = 0.7; + colory4[0] = 0.1; + colory4[1] = 0.06; + colory4[2] = 0.0; + colory4[3] = 0.0; VectorMA( origin, 1, dir, sprOrg ); VectorScale( dir, 1, sprVel ); @@ -2800,26 +3062,26 @@ void LFX_ParticleEffect1998 (int effect, vec3_t org, vec3_t dir) R_LFX_Spark (sprOrg, sprVel, 95, 32, colory, colory2, colory3, colory4, colory4, 3, 440, 0.5f, 1); sprVel[2] += 64; R_LFX_Generic ( - LFXSMOKE, // Particle Type - sprOrg, // Origin - sprVel, // Velocity - 1.0f, // Starting Alpha - 85, // Spread Factor - 3, // Random Origin Offset - 0, // Random Roll Value - 0, // Additional Random Speed - 8, // Particle Color Red - 8, // Particle Color Green - 8, // Particle Color Blue - 8, // Particle Count - 400, // Particle Life - 0.5f, // Particle Scale - 0.5f, // Particle Scale Towards - 0.1f, // Particle Bounce Factor - 0, // Air Friction (stopping particle velocity in air) - -16.0f, // Particle Gravity Factor - 0.0f, // Particle Rolling Friction - alfball // Particle Shader + LFXSMOKE, // Particle Type + sprOrg, // Origin + sprVel, // Velocity + 1.0f, // Starting Alpha + 85, // Spread Factor + 3, // Random Origin Offset + 0, // Random Roll Value + 0, // Additional Random Speed + 8, // Particle Color Red + 8, // Particle Color Green + 8, // Particle Color Blue + 8, // Particle Count + 400, // Particle Life + 0.5f, // Particle Scale + 0.5f, // Particle Scale Towards + 0.1f, // Particle Bounce Factor + 0, // Air Friction (stopping particle velocity in air) + -16.0f, // Particle Gravity Factor + 0.0f, // Particle Rolling Friction + alfball // Particle Shader ); } } @@ -2848,10 +3110,22 @@ void LFX_ParticleEffect1998 (int effect, vec3_t org, vec3_t dir) // should be a nondirectional splat of a center atlas gush // and then several randomly directed blood drops that roll. all is GE128 if (effect == 14 && com_blood->integer) { - colory[0] = 1.0; colory[1] = 0.0; colory[2] = 0.0; colory[3] = 1.0; - colory2[0] = 0.8; colory2[1] = 0.0; colory2[2] = 0.0; colory2[3] = 0.5; - colory3[0] = 0.6; colory3[1] = 0.0; colory3[2] = 0.0; colory3[3] = 0.8; - colory4[0] = 0.3; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 1.0; + colory[1] = 0.0; + colory[2] = 0.0; + colory[3] = 1.0; + colory2[0] = 0.8; + colory2[1] = 0.0; + colory2[2] = 0.0; + colory2[3] = 0.5; + colory3[0] = 0.6; + colory3[1] = 0.0; + colory3[2] = 0.0; + colory3[3] = 0.8; + colory4[0] = 0.3; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); } @@ -2860,7 +3134,7 @@ void LFX_ParticleEffect1998 (int effect, vec3_t org, vec3_t dir) // 1999 - a certain competing game // - high emphasis on atlas animations // - no alpha blending - only alpha blend, subtractive blend (for grenade smoke) and GE128 alpha testing. -void LFX_ParticleEffect1999 (int effect, vec3_t org, vec3_t dir) +void LFX_ParticleEffect1999 (int effect, const vec3_t org, const vec3_t dir) { vec3_t origin, sprOrg, sprVel; // laziness vec4_t colory, colory2, colory3, colory4; @@ -2879,26 +3153,26 @@ void LFX_ParticleEffect1999 (int effect, vec3_t org, vec3_t dir) // a smoke puff, a badly looping spark model, and an occasional ball spark (no stretch) of a random amount from 1 to 6 balls. if (effect == 2) { R_LFX_Generic ( - 777777, // Particle Type - sprOrg, // Origin - sprVel, // Velocity - 1.0f, // Starting Alpha - 96, // Spread Factor - 4, // Random Origin Offset - 0, // Random Roll Value - 200, // Additional Random Speed - 255, // Particle Color Red - 255, // Particle Color Green - 32, // Particle Color Blue - 5, // Particle Count - 600, // Particle Life - 1, // Particle Scale - 1, // Particle Scale Towards - 0.1f, // Particle Bounce Factor - 0, // Air Friction (stopping particle velocity in air) - -12.0f, // Particle Gravity Factor - 0.0f, // Particle Rolling Friction - addball // Particle Shader + 777777, // Particle Type + sprOrg, // Origin + sprVel, // Velocity + 1.0f, // Starting Alpha + 96, // Spread Factor + 4, // Random Origin Offset + 0, // Random Roll Value + 200, // Additional Random Speed + 255, // Particle Color Red + 255, // Particle Color Green + 32, // Particle Color Blue + 5, // Particle Count + 600, // Particle Life + 1, // Particle Scale + 1, // Particle Scale Towards + 0.1f, // Particle Bounce Factor + 0, // Air Friction (stopping particle velocity in air) + -12.0f, // Particle Gravity Factor + 0.0f, // Particle Rolling Friction + addball // Particle Shader ); } @@ -2908,26 +3182,26 @@ void LFX_ParticleEffect1999 (int effect, vec3_t org, vec3_t dir) VectorMA( origin, 8, dir, sprOrg ); sprVel[2] += 20; R_LFX_Generic ( - LFXSMOKE, // Particle Type - sprOrg, // Origin - sprVel, // Velocity - 1.0f, // Starting Alpha - 0, // Spread Factor - 4, // Random Origin Offset - 0, // Random Roll Value - 0, // Additional Random Speed - 255, // Particle Color Red - 255, // Particle Color Green - 255, // Particle Color Blue - 5, // Particle Count - 1200, // Particle Life - 12, // Particle Scale - 12, // Particle Scale Towards - 0, // Particle Bounce Factor - 0, // Air Friction (stopping particle velocity in air) - 0, // Particle Gravity Factor - 10, // Particle Rolling Friction - addsmoke // Particle Shader + LFXSMOKE, // Particle Type + sprOrg, // Origin + sprVel, // Velocity + 1.0f, // Starting Alpha + 0, // Spread Factor + 4, // Random Origin Offset + 0, // Random Roll Value + 0, // Additional Random Speed + 255, // Particle Color Red + 255, // Particle Color Green + 255, // Particle Color Blue + 5, // Particle Count + 1200, // Particle Life + 12, // Particle Scale + 12, // Particle Scale Towards + 0, // Particle Bounce Factor + 0, // Air Friction (stopping particle velocity in air) + 0, // Particle Gravity Factor + 10, // Particle Rolling Friction + addsmoke // Particle Shader ); } @@ -2963,49 +3237,49 @@ void LFX_ParticleEffect1999 (int effect, vec3_t org, vec3_t dir) sprVel[1] = 0; sprVel[0] = 0; R_LFX_Generic ( - LFXSMOKE, // Particle Type - sprOrg, // Origin - sprVel, // Velocity - 1.0f, // Starting Alpha - 0, // Spread Factor - 4, // Random Origin Offset - 0, // Random Roll Value - 0, // Additional Random Speed - 255, // Particle Color Red - 0, // Particle Color Green - 0, // Particle Color Blue - 1, // Particle Count - 700, // Particle Life - 8, // Particle Scale - 8, // Particle Scale Towards - 0, // Particle Bounce Factor - 0, // Air Friction (stopping particle velocity in air) - 0, // Particle Gravity Factor - 10, // Particle Rolling Friction - addsmoke // Particle Shader + LFXSMOKE, // Particle Type + sprOrg, // Origin + sprVel, // Velocity + 1.0f, // Starting Alpha + 0, // Spread Factor + 4, // Random Origin Offset + 0, // Random Roll Value + 0, // Additional Random Speed + 255, // Particle Color Red + 0, // Particle Color Green + 0, // Particle Color Blue + 1, // Particle Count + 700, // Particle Life + 8, // Particle Scale + 8, // Particle Scale Towards + 0, // Particle Bounce Factor + 0, // Air Friction (stopping particle velocity in air) + 0, // Particle Gravity Factor + 10, // Particle Rolling Friction + addsmoke // Particle Shader ); R_LFX_Generic ( - LFXSMOKE, // Particle Type - sprOrg, // Origin - sprVel, // Velocity - 1.0f, // Starting Alpha - 96, // Spread Factor - 4, // Random Origin Offset - 0, // Random Roll Value - 200, // Additional Random Speed - 255, // Particle Color Red - 0, // Particle Color Green - 0, // Particle Color Blue - 5, // Particle Count - 600, // Particle Life - 1, // Particle Scale - 1, // Particle Scale Towards - 0.1f, // Particle Bounce Factor - 0, // Air Friction (stopping particle velocity in air) - -12.0f, // Particle Gravity Factor - 0.0f, // Particle Rolling Friction - alfsmoke // Particle Shader + LFXSMOKE, // Particle Type + sprOrg, // Origin + sprVel, // Velocity + 1.0f, // Starting Alpha + 96, // Spread Factor + 4, // Random Origin Offset + 0, // Random Roll Value + 200, // Additional Random Speed + 255, // Particle Color Red + 0, // Particle Color Green + 0, // Particle Color Blue + 5, // Particle Count + 600, // Particle Life + 1, // Particle Scale + 1, // Particle Scale Towards + 0.1f, // Particle Bounce Factor + 0, // Air Friction (stopping particle velocity in air) + -12.0f, // Particle Gravity Factor + 0.0f, // Particle Rolling Friction + alfsmoke // Particle Shader ); } @@ -3022,16 +3296,28 @@ void LFX_ParticleEffect1999 (int effect, vec3_t org, vec3_t dir) // Water Splash for bullets - there should only be a polygonal white ring. but we don't do model drawing right now if (effect == 19) { - colory[0] = 1.0; colory[1] = 1.0; colory[2] = 1.0; colory[3] = 1.0; - colory2[0] = 0.7; colory2[1] = 0.7; colory2[2] = 0.7; colory2[3] = 0.6; - colory3[0] = 0.4; colory3[1] = 0.4; colory3[2] = 0.4; colory3[3] = 0.3; - colory4[0] = 0.0; colory4[1] = 0.0; colory4[2] = 0.0; colory4[3] = 0.0; + colory[0] = 1.0; + colory[1] = 1.0; + colory[2] = 1.0; + colory[3] = 1.0; + colory2[0] = 0.7; + colory2[1] = 0.7; + colory2[2] = 0.7; + colory2[3] = 0.6; + colory3[0] = 0.4; + colory3[1] = 0.4; + colory3[2] = 0.4; + colory3[3] = 0.3; + colory4[0] = 0.0; + colory4[1] = 0.0; + colory4[2] = 0.0; + colory4[3] = 0.0; VectorScale( dir, 39, sprVel ); R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 800, 80,14); } } -void LFX_ParticleEffect (int effect, vec3_t org, vec3_t dir) +void LFX_ParticleEffect (int effect, const vec3_t org, const vec3_t dir) { // choosing particle sets