diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index 0d84d771..cbb86534 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -875,13 +875,84 @@ static void R_EndGL( void ) pglDisable( GL_CLIP_PLANE0 ); } +/* +============= +R_RecursiveFindWaterTexture + +using to find source waterleaf with +watertexture to grab fog values from it +============= +*/ +static gltexture_t *R_RecursiveFindWaterTexture( const mnode_t *node, const mnode_t *ignore, qboolean down ) +{ + gltexture_t *tex = NULL; + + // assure the initial node is not null + // we could check it here, but we would rather check it + // outside the call to get rid of one additional recursion level + ASSERT( node != NULL ); + + // ignore solid nodes + if( node->contents == CONTENTS_SOLID ) + return NULL; + + if( node->contents < 0 ) + { + mleaf_t *pleaf; + msurface_t **mark; + int i, c; + + // ignore non-liquid leaves + if( node->contents != CONTENTS_WATER && node->contents != CONTENTS_LAVA && node->contents != CONTENTS_SLIME ) + return NULL; + + // find texture + pleaf = (mleaf_t *)node; + mark = pleaf->firstmarksurface; + c = pleaf->nummarksurfaces; + + for( i = 0; i < c; i++, mark++ ) + { + if( (*mark)->flags & SURF_DRAWTURB && (*mark)->texinfo && (*mark)->texinfo->texture ) + return R_GetTexture( (*mark)->texinfo->texture->gl_texturenum ); + } + + // texture not found + return NULL; + } + + // this is a regular node + // traverse children + if( node->children[0] && ( node->children[0] != ignore )) + { + tex = R_RecursiveFindWaterTexture( node->children[0], node, true ); + if( tex ) return tex; + } + + if( node->children[1] && ( node->children[1] != ignore )) + { + tex = R_RecursiveFindWaterTexture( node->children[1], node, true ); + if( tex ) return tex; + } + + // for down recursion, return immediately + if( down ) return NULL; + + // texture not found, step up if any + if( node->parent ) + return R_RecursiveFindWaterTexture( node->parent, node, false ); + + // top-level node, bail out + return NULL; +} + /* ============= R_CheckFog check for underwater fog -FIXME: this code is wrong, we need to compute fog volumes (as water volumes) -and get fog params from texture water on a surface. +Using backward recursion to find waterline leaf +from underwater leaf (idea: XaeroX) ============= */ static void R_CheckFog( void ) @@ -931,23 +1002,11 @@ static void R_CheckFog( void ) } else { - msurface_t **surf; - - count = r_viewleaf->nummarksurfaces; - - for( i = 0, surf = r_viewleaf->firstmarksurface; i < count; i++, surf++ ) - { - if((*surf)->flags & SURF_DRAWTURB && (*surf)->texinfo && (*surf)->texinfo->texture ) - { - tex = R_GetTexture( (*surf)->texinfo->texture->gl_texturenum ); - RI.cached_contents = r_viewleaf->contents; - break; - } - } + tex = R_RecursiveFindWaterTexture( r_viewleaf->parent, NULL, false ); + if( tex ) RI.cached_contents = r_viewleaf->contents; } - if( i == count || !tex ) - return; // no valid fogs + if( !tex ) return; // no valid fogs // copy fog params RI.fogColor[0] = tex->fogParams[0] / 255.0f; diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index 5d8a9057..c9243d8e 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -3509,9 +3509,20 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded ) Q_memcpy( loadmodel->cache.data, buffer, phdr->length ); #endif // setup bounding box - VectorCopy( phdr->bbmin, loadmodel->mins ); - VectorCopy( phdr->bbmax, loadmodel->maxs ); + if( VectorIsNull( phdr->bbmin ) && VectorIsNull( phdr->bbmax )) + { + mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex); + // just to have something valid here + VectorCopy( pseqdesc[0].bbmin, loadmodel->mins ); + VectorCopy( pseqdesc[0].bbmax, loadmodel->maxs ); + } + else + { + VectorCopy( phdr->bbmin, loadmodel->mins ); + VectorCopy( phdr->bbmax, loadmodel->maxs ); + } + loadmodel->numframes = R_StudioBodyVariations( loadmodel ); loadmodel->radius = RadiusFromBounds( loadmodel->mins, loadmodel->maxs ); loadmodel->flags = phdr->flags; // copy header flags diff --git a/engine/client/s_main.c b/engine/client/s_main.c index e2854df1..f2820d11 100644 --- a/engine/client/s_main.c +++ b/engine/client/s_main.c @@ -359,7 +359,7 @@ channel_t *SND_PickStaticChannel( int entnum, sfx_t *sfx, const vec3_t pos ) int i, dupe = 0; #if 1 // TODO: remove this code when predicting is will be done - // check for dupliacte sounds + // check for duplicate sounds for( i = 0; i < total_channels; i++ ) { if( channels[i].sfx == sfx && VectorCompare( channels[i].origin, pos )) diff --git a/engine/client/sound.h b/engine/client/sound.h index de2b0841..4ea60a22 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -220,7 +220,7 @@ void SNDDMA_Submit( void ); //==================================================================== #define MAX_DYNAMIC_CHANNELS (28 + NUM_AMBIENTS) -#define MAX_CHANNELS 128 +#define MAX_CHANNELS (128 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp #define MAX_RAW_SAMPLES 8192 extern sound_t ambient_sfx[NUM_AMBIENTS]; diff --git a/engine/common/build.c b/engine/common/build.c index c768a4d5..0a792213 100644 --- a/engine/common/build.c +++ b/engine/common/build.c @@ -23,7 +23,7 @@ static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int Q_buildnum( void ) { // do not touch this! Only author of Xash3D can increase buildnumbers! -#if 0 +#if 1 int m = 0, d = 0, y = 0; static int b = 0;