08 Aug 2012

This commit is contained in:
g-cont 2012-08-08 00:00:00 +04:00 committed by Alibek Omarov
parent 9a8003fcf2
commit 714f316c79
20 changed files with 131 additions and 22 deletions

View File

@ -81,6 +81,7 @@ typedef enum
TF_TEXTURE_1D = (1<<18), // this is GL_TEXTURE_1D
TF_BORDER = (1<<19),
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
TF_FLOAT = (1<<21), // use GL_FLOAT instead of GL_UNSIGNED_BYTE
} texFlags_t;
typedef struct beam_s BEAM;

View File

@ -1813,6 +1813,10 @@ void CTriggerPush :: Spawn( )
if (pev->speed == 0)
pev->speed = 100;
// this flag was changed and flying barrels on c2a5 stay broken
if ( FStrEq( STRING( gpGlobals->mapname ), "c2a5" ) && pev->spawnflags & 4)
pev->spawnflags |= SF_TRIG_PUSH_ONCE;
if ( FBitSet (pev->spawnflags, SF_TRIGGER_PUSH_START_OFF) )// if flagged to Start Turned Off, make trigger nonsolid.
pev->solid = SOLID_NOT;

View File

@ -3134,6 +3134,7 @@ void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
if( !bOn )
{
pglDisable( GL_FOG );
RI.fogCustom = false;
return;
}

View File

@ -89,6 +89,10 @@ void GL_BackendEndFrame( void )
case 5:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i tempents\n%3i viewbeams\n%3i particles",
r_stats.c_active_tents_count, r_stats.c_view_beams_count, r_stats.c_particle_count );
break;
case 6:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i mirrors\n", r_stats.c_mirror_passes );
break;
}
Q_memset( &r_stats, 0, sizeof( r_stats ));

View File

@ -180,7 +180,7 @@ qboolean R_CullSurface( msurface_t *surf, uint clipflags )
if( r_faceplanecull->integer && glState.faceCull != 0 )
{
if(!(surf->flags & SURF_DRAWTURB) || !RI.currentWaveHeight )
if( RI.currentWaveHeight == 0.0f )
{
if( !VectorIsNull( surf->plane->normal ))
{

View File

@ -804,6 +804,7 @@ sgis generate mipmap
void GL_GenerateMipmaps( byte *buffer, rgbdata_t *pic, gltexture_t *tex, GLenum glTarget, GLenum inFormat, int side, qboolean subImage )
{
int mipLevel;
int dataType = GL_UNSIGNED_BYTE;
int w, h;
// not needs
@ -818,6 +819,9 @@ void GL_GenerateMipmaps( byte *buffer, rgbdata_t *pic, gltexture_t *tex, GLenum
return;
}
if( tex->flags & TF_FLOAT )
dataType = GL_FLOAT;
mipLevel = 0;
w = tex->width;
h = tex->height;
@ -832,8 +836,8 @@ void GL_GenerateMipmaps( byte *buffer, rgbdata_t *pic, gltexture_t *tex, GLenum
h = (h+1)>>1;
mipLevel++;
if( subImage ) pglTexSubImage2D( tex->target + side, mipLevel, 0, 0, w, h, inFormat, GL_UNSIGNED_BYTE, buffer );
else pglTexImage2D( tex->target + side, mipLevel, tex->format, w, h, 0, inFormat, GL_UNSIGNED_BYTE, buffer );
if( subImage ) pglTexSubImage2D( tex->target + side, mipLevel, 0, 0, w, h, inFormat, dataType, buffer );
else pglTexImage2D( tex->target + side, mipLevel, tex->format, w, h, 0, inFormat, dataType, buffer );
if( pglGetError( )) break; // can't create mip levels
}
}
@ -985,6 +989,9 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag
tex->target = glTarget = GL_TEXTURE_3D;
}
if( tex->flags & TF_FLOAT )
dataType = GL_FLOAT;
pglBindTexture( tex->target, tex->texnum );
buf = pic->buffer;
@ -1009,7 +1016,7 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag
Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name );
// copy or resample the texture
if( tex->width == tex->srcWidth && tex->height == tex->srcHeight )
if(( tex->width == tex->srcWidth && tex->height == tex->srcHeight ) || ( tex->flags & TF_TEXTURE_3D ))
{
data = buf;
}
@ -1020,7 +1027,7 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag
if( !glConfig.deviceSupportsGamma )
{
if(!( tex->flags & TF_NOMIPMAP ) && !( tex->flags & TF_SKYSIDE ))
if(!( tex->flags & TF_NOMIPMAP ) && !( tex->flags & TF_SKYSIDE ) && !( tex->flags & TF_TEXTURE_3D ))
data = GL_ApplyGamma( data, tex->width * tex->height, ( tex->flags & TF_NORMALMAP ));
}
@ -1248,6 +1255,23 @@ int GL_CreateTexture( const char *name, int width, int height, const void *buffe
r_empty.flags = IMAGE_HAS_COLOR | (( flags & TF_HAS_ALPHA ) ? IMAGE_HAS_ALPHA : 0 );
r_empty.buffer = (byte *)buffer;
if( flags & TF_TEXTURE_1D )
{
r_empty.height = 1;
r_empty.size = r_empty.width * 4;
}
else if( flags & TF_TEXTURE_3D )
{
if( !GL_Support( GL_TEXTURE_3D_EXT ))
return 0;
r_empty.depth = r_empty.width;
r_empty.size = r_empty.width * r_empty.height * r_empty.depth * 4;
}
if( flags & TF_FLOAT )
r_empty.size *= 4;
texture = GL_LoadTextureInternal( name, &r_empty, flags, false );
if( flags & TF_DEPTHMAP )

View File

@ -236,6 +236,8 @@ typedef struct
uint c_studio_models_drawn;
uint c_sprite_models_drawn;
uint c_particle_count;
uint c_mirror_passes;
} ref_speeds_t;
extern ref_speeds_t r_stats;

View File

@ -74,8 +74,7 @@ Restore identity texmatrix
*/
void R_EndDrawMirror( void )
{
GL_DisableAllTexGens();
GL_LoadIdentityTexMatrix();
GL_CleanUpTextureUnits( 0 );
pglMatrixMode( GL_MODELVIEW );
}
@ -183,7 +182,7 @@ void R_DrawMirrors( void )
{
ref_instance_t oldRI;
mplane_t plane;
msurface_t *surf;
msurface_t *surf, *surf2;
int i, oldframecount;
mextrasurf_t *es, *tmp, *mirrorchain;
vec3_t forward, right, up;
@ -202,7 +201,7 @@ void R_DrawMirrors( void )
{
mirrorchain = tr.mirror_entities[i].chain;
for( es = mirrorchain; es != NULL; )
for( es = mirrorchain; es != NULL; es = es->mirrorchain )
{
RI.currententity = e = tr.mirror_entities[i].ent;
RI.currentmodel = m = RI.currententity->model;
@ -212,6 +211,38 @@ void R_DrawMirrors( void )
ASSERT( RI.currententity != NULL );
ASSERT( RI.currentmodel != NULL );
// NOTE: copy mirrortexture and mirrormatrix from another surfaces
// from this entity\world that has same planes and reduce number of viewpasses
// make sure what we have one pass at least
if( es != mirrorchain )
{
for( tmp = mirrorchain; tmp != es; tmp = tmp->mirrorchain )
{
surf2 = INFO_SURF( tmp, m );
if( !tmp->mirrortexturenum )
continue; // not filled?
if( surf->plane->dist != surf2->plane->dist )
continue;
if( !VectorCompare( surf->plane->normal, surf2->plane->normal ))
continue;
// found surface with same plane!
break;
}
if( tmp != es && tmp && tmp->mirrortexturenum )
{
// just copy reflection texture from surface with same plane
Matrix4x4_Copy( es->mirrormatrix, tmp->mirrormatrix );
es->mirrortexturenum = tmp->mirrortexturenum;
continue; // pass skiped
}
}
R_PlaneForMirror( surf, &plane, mirrormatrix );
d = -2.0f * ( DotProduct( RI.vieworg, plane.normal ) - plane.dist );
@ -280,6 +311,7 @@ void R_DrawMirrors( void )
tr.framecount++;
R_RenderScene( &RI.refdef );
r_stats.c_mirror_passes++;
es->mirrortexturenum = R_AllocateMirrorTexture();
@ -294,18 +326,21 @@ void R_DrawMirrors( void )
Matrix4x4_Concat( es->mirrormatrix, RI.projectionMatrix, RI.modelviewMatrix );
}
RI = oldRI; // restore ref instance
}
// clear chain for this entity
for( es = mirrorchain; es != NULL; )
{
tmp = es->mirrorchain;
es->mirrorchain = NULL;
es = tmp;
RI = oldRI; // restore ref instance
}
tr.mirror_entities[i].chain = NULL; // done
tr.mirror_entities[i].ent = NULL;
}
r_oldviewleaf = r_viewleaf = NULL; // force markleafs next frame
tr.framecount = oldframecount; // restore real framecount
tr.num_mirror_entities = 0;

View File

@ -1064,6 +1064,14 @@ void R_RenderBrushPoly( msurface_t *fa )
{
GL_Bind( GL_TEXTURE0, SURF_INFO( fa, RI.currentmodel )->mirrortexturenum );
is_mirror = true;
// BEGIN WATER STUFF
if( fa->flags & SURF_DRAWTURB )
{
R_BeginDrawMirror( fa );
GL_Bind( GL_TEXTURE1, t->gl_texturenum );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
}
}
else GL_Bind( GL_TEXTURE0, t->gl_texturenum ); // dummy
@ -1076,6 +1084,8 @@ void R_RenderBrushPoly( msurface_t *fa )
{
// warp texture, no lightmaps
EmitWaterPolys( fa->polys, ( fa->flags & SURF_NOCULL ));
if( is_mirror ) R_EndDrawMirror();
// END WATER STUFF
return;
}

View File

@ -620,7 +620,9 @@ void EmitWaterPolys( glpoly_t *polys, qboolean noCull )
t = ot + r_turbsin[(int)((os * 0.125f + cl.time ) * TURBSCALE) & 255];
t *= ( 1.0f / SUBDIVIDE_SIZE );
pglTexCoord2f( s, t );
if( glState.activeTMU != 0 )
GL_MultiTexCoord2f( glState.activeTMU, s, t );
else pglTexCoord2f( s, t );
pglVertex3f( v[0], v[1], nv );
}
pglEnd();

View File

@ -5106,7 +5106,7 @@ void DSP_SetPreset( int idsp, int ipsetnew )
if( !ppsetnew[i] )
{
MsgDev( D_WARN, "DSP preset failed to allocate.\n" );
MsgDev( D_NOTE, "DSP preset failed to allocate.\n" );
return;
}
}
@ -5431,6 +5431,9 @@ void CheckNewDspPresets( void )
int iroomtype = dsp_room_type->integer;
int iroom;
if( dsp_off->integer )
return;
if( s_listener.waterlevel > 2 )
iroom = 15;
else if( s_listener.inmenu )

View File

@ -1675,7 +1675,7 @@ static void Mod_BuildSurfacePolygons( msurface_t *surf, mextrasurf_t *info )
}
// subdivide water or sky sphere for Quake1 maps
if(( surf->flags & SURF_DRAWTURB ) || ( surf->flags & SURF_DRAWSKY && world.loading && world.sky_sphere ))
if(( surf->flags & SURF_DRAWTURB && !( surf->flags & SURF_REFLECT )) || ( surf->flags & SURF_DRAWSKY && world.loading && world.sky_sphere ))
{
Mod_SubdividePolygon( info, surf, surf->numedges, verts[0] );
Mod_ConvertSurface( info, surf );
@ -1755,7 +1755,8 @@ static void Mod_LoadSurfaces( const dlump_t *l )
out->flags |= SURF_CONVEYOR|SURF_TRANSPARENT;
// g-cont this texture from decals.wad he-he
if( !Q_strncmp( tex->name, "reflect", 7 ))
// support !reflect for reflected water
if( !Q_strncmp( tex->name, "reflect", 7 ) || !Q_strncmp( tex->name, "!reflect", 8 ))
{
out->flags |= SURF_REFLECT;
world.has_mirrors = true;
@ -2008,7 +2009,11 @@ static void Mod_LoadLeafs( const dlump_t *l )
if( out->contents != CONTENTS_EMPTY )
{
for( j = 0; j < out->nummarksurfaces; j++ )
{
// underwater surfaces can't have reflection (perfomance)
out->firstmarksurface[j]->flags |= SURF_UNDERWATER;
out->firstmarksurface[j]->flags &= ~SURF_REFLECT;
}
}
}

View File

@ -78,6 +78,7 @@ static const delta_field_t pm_fields[] =
{ PHYS_DEF( skyvec_x ) },
{ PHYS_DEF( skyvec_y ) },
{ PHYS_DEF( skyvec_z ) },
{ PHYS_DEF( fog_settings ) },
{ PHYS_DEF( wateralpha ) },
{ PHYS_DEF( skydir_x ) },
{ PHYS_DEF( skydir_y ) },
@ -823,6 +824,7 @@ void Delta_Init( void )
Delta_AddField( "movevars_t", "skydir_z", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
Delta_AddField( "movevars_t", "skyangle", DT_ANGLE, 16, 1.0f, 1.0f ); // 0 - 360
Delta_AddField( "movevars_t", "wateralpha", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
Delta_AddField( "movevars_t", "fog_settings", DT_INTEGER, 32, 1.0f, 1.0f );
// now done
dt->bInitialized = true;
}

View File

@ -55,7 +55,8 @@ typedef struct server_physics_api_s
void ( *pfnDrawConsoleStringLen )( const char *string, int *length, int *height );
void ( *Con_NPrintf )( int pos, char *fmt, ... );
void ( *Con_NXPrintf )( struct con_nprint_s *info, char *fmt, ... );
const char *( *pfnGetLightStyle)( int style ); // read custom appreance for selected lightstyle
const char *( *pfnGetLightStyle )( int style ); // read custom appreance for selected lightstyle
void ( *pfnUpdateFogSettings )( unsigned int packed_fog );
} server_physics_api_t;
// physic callbacks

View File

@ -4607,6 +4607,7 @@ void SV_SpawnEntities( const char *mapname, char *entities )
ent->v.modelindex = 1; // world model
ent->v.solid = SOLID_BSP;
ent->v.movetype = MOVETYPE_PUSH;
svgame.movevars.fog_settings = 0;
svgame.globals->maxEntities = GI->max_edicts;
svgame.globals->maxClients = sv_maxclients->integer;

View File

@ -695,9 +695,13 @@ qboolean SV_NewGame( const char *mapName, qboolean loadGame )
return false;
SV_ClearSaveDir ();
SV_Shutdown( true );
}
else
{
S_StopAllSounds ();
SV_DeactivateServer ();
}
SV_Shutdown( true );
sv.loadgame = loadGame;
sv.background = false;

View File

@ -1834,6 +1834,12 @@ void SV_DrawOrthoTriangles( void )
}
}
void SV_UpdateFogSettings( unsigned int packed_fog )
{
svgame.movevars.fog_settings = packed_fog;
physinfo->modified = true; // force to transmit
}
static server_physics_api_t gPhysicsAPI =
{
SV_LinkEdict,
@ -1850,6 +1856,7 @@ static server_physics_api_t gPhysicsAPI =
Con_NPrintf,
Con_NXPrintf,
SV_GetLightStyle,
SV_UpdateFogSettings,
};
/*

View File

@ -2076,6 +2076,9 @@ qboolean SV_LoadGame( const char *pName )
return false;
Q_snprintf( name, sizeof( name ), "save/%s.sav", pName );
if( sv.background )
SV_Shutdown( true );
sv.background = false;
// silently ignore if missed

View File

@ -1142,8 +1142,8 @@ static void SV_ClipToLinks( areanode_t *node, moveclip_t *clip )
continue; // originally this was 'return' but is completely wrong!
}
// monsterclip filter
if( touch->v.solid == SOLID_BSP )
// monsterclip filter (solid custom is a static or dynamic bodies)
if( touch->v.solid == SOLID_BSP || touch->v.solid == SOLID_CUSTOM )
{
if( touch->v.flags & FL_MONSTERCLIP )
{

View File

@ -41,7 +41,7 @@ struct movevars_s
float skyvec_y; //
float skyvec_z; //
int features; // engine features that shared across network
float clienttrace; // Studiomodels scale that applied for the clients (visual effect only)
int fog_settings; // Global fog settings (packed color+density)
float wateralpha; // World water alpha 1.0 - solid 0.0 - transparent
float skydir_x; // skybox rotate direction
float skydir_y; //