15 Sep 2013

This commit is contained in:
g-cont 2013-09-15 00:00:00 +04:00 committed by Alibek Omarov
parent 0e5ba36d21
commit 82a9942d1c
17 changed files with 64 additions and 46 deletions

View File

@ -23,6 +23,7 @@ typedef struct
int length;
float value;
qboolean interp; // allow to interpolate this lightstyle
float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence
} lightstyle_t;
#endif//LIGHTSTYLE_H

View File

@ -72,4 +72,19 @@ typedef struct ref_params_s
float fov_x, fov_y; // actual fov can be overrided on nextView
} ref_params_t;
// same as ref_params but for overview mode
typedef struct ref_overview_s
{
vec3_t origin;
qboolean rotated;
float xLeft;
float xRight;
float xTop;
float xBottom;
float zFar;
float zNear;
float flZoom;
} ref_overview_t;
#endif//REF_PARAMS_H

View File

@ -174,6 +174,7 @@ typedef struct render_api_s
void (*R_StoreEfragsExt)( struct efrag_s **ppefrag, int framecount ); // store efrags for static entities
void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
struct mstudiotex_s *( *StudioGetTexture )( struct cl_entity_s *e ); // moved here to avoid incompatibility with IEngineStudio official iface
const struct ref_overview_s *( *GetOverviewParms )( void );
} render_api_t;
// render callbacks

View File

@ -35,7 +35,7 @@ class CApache : public CBaseMonster
void Spawn( void );
void Precache( void );
int Classify( void ) { return CLASS_HUMAN_MILITARY; };
int Classify( void ) { return m_iClass ? m_iClass : CLASS_HUMAN_MILITARY; };
int BloodColor( void ) { return DONT_BLEED; }
void Killed( entvars_t *pevAttacker, int iGib );
void GibMonster( void );

View File

@ -764,11 +764,13 @@ void CL_ParseLightStyle( sizebuf_t *msg )
{
int style;
const char *s;
float f;
style = BF_ReadByte( msg );
s = BF_ReadString( msg );
f = BF_ReadFloat( msg );
CL_SetLightstyle( style, s );
CL_SetLightstyle( style, s, f );
}
/*

View File

@ -2295,7 +2295,7 @@ void CL_ClearLightStyles( void )
Q_memset( cl.lightstyles, 0, sizeof( cl.lightstyles ));
}
void CL_SetLightstyle( int style, const char *s )
void CL_SetLightstyle( int style, const char *s, float f )
{
int i, k;
lightstyle_t *ls;
@ -2309,15 +2309,16 @@ void CL_SetLightstyle( int style, const char *s )
Q_strncpy( ls->pattern, s, sizeof( ls->pattern ));
ls->length = Q_strlen( s );
ls->time = f; // set local time
for( i = 0; i < ls->length; i++ )
ls->map[i] = (float)(s[i] - 'a');
ls->interp = true;
ls->interp = (ls->length <= 1) ? false : true;
// check for allow interpolate
// NOTE: fast flickering styles looks ugly when interpolation is running
for( k = 0; k < ls->length; k++ )
for( k = 0; k < (ls->length - 1); k++ )
{
val1 = ls->map[(k+0) % ls->length];
val2 = ls->map[(k+1) % ls->length];

View File

@ -283,21 +283,6 @@ typedef struct
model_t *model; // for catch model changes
} remap_info_t;
// same as ref_params but for overview mode
typedef struct
{
vec3_t origin;
qboolean rotated;
float xLeft;
float xRight;
float xTop;
float xBottom;
float zFar;
float zNear;
float flZoom;
} ref_overview_t;
typedef struct
{
net_response_t resp;
@ -556,7 +541,7 @@ extern convar_t *hltv;
//=============================================================================
void CL_SetLightstyle( int style, const char* s );
void CL_SetLightstyle( int style, const char* s, float f );
void CL_RunLightStyles( void );
void CL_AddEntities( void );

View File

@ -1568,10 +1568,10 @@ void CL_DrawBeams( int fTrans )
{
RI.currentbeam = cl_custombeams[i];
if( fTrans && RI.currentbeam->curstate.renderfx & FBEAM_SOLID )
if( fTrans && ((RI.currentbeam->curstate.rendermode & 0xF0) & FBEAM_SOLID ))
continue;
if( !fTrans && !( RI.currentbeam->curstate.renderfx & FBEAM_SOLID ))
if( !fTrans && !((RI.currentbeam->curstate.rendermode & 0xF0) & FBEAM_SOLID ))
continue;
CL_DrawCustomBeam( RI.currentbeam );

View File

@ -47,11 +47,6 @@ void R_AnimateLight( void )
// light animations
// 'm' is normal light, 'a' is no light, 'z' is double bright
flight = (int)floor( cl.time * 10 );
clight = (int)ceil( cl.time * 10 );
lerpfrac = ( cl.time * 10 ) - flight;
backlerp = 1.0f - lerpfrac;
for( i = 0, ls = cl.lightstyles; i < MAX_LIGHTSTYLES; i++, ls++ )
{
if( r_fullbright->integer || !cl.worldmodel->lightdata )
@ -61,6 +56,14 @@ void R_AnimateLight( void )
continue;
}
if( !RI.refdef.paused && RI.refdef.frametime <= 0.1f )
ls->time += RI.refdef.frametime; // evaluate local time
flight = (int)floor( ls->time * 10 );
clight = (int)ceil( ls->time * 10 );
lerpfrac = ( ls->time * 10 ) - flight;
backlerp = 1.0f - lerpfrac;
if( !ls->length )
{
RI.lightstylevalue[i] = 256 * scale;

View File

@ -1296,7 +1296,7 @@ void R_RenderFrame( const ref_params_t *fd, qboolean drawWorld )
RI.clipFlags = 15;
RI.drawWorld = drawWorld;
RI.thirdPerson = cl.thirdperson;
RI.drawOrtho = gl_overview->integer;
RI.drawOrtho = (RI.drawWorld) ? gl_overview->integer : 0;
GL_BackendStartFrame();
@ -1569,6 +1569,11 @@ static void GL_StoreEfrags( efrag_t **ppefrag )
R_StoreEfrags( ppefrag, tr.framecount );
}
static const ref_overview_t *GL_GetOverviewParms( void )
{
return &clgame.overView;
}
static render_api_t gRenderAPI =
{
GL_RenderGetParm,
@ -1614,6 +1619,7 @@ static render_api_t gRenderAPI =
R_StoreEfrags,
GL_TextureTarget,
R_StudioGetTexture, // moved here to avoid incompatibility with official expanded interface of IEngineStduio (HLSDK Update at 30.08.2013)
GL_GetOverviewParms,
};
/*

View File

@ -48,6 +48,6 @@ int Q_buildnum( void )
return b;
#else
return 2402;
return 2411;
#endif
}

View File

@ -16,7 +16,7 @@ GNU General Public License for more details.
#ifndef PROTOCOL_H
#define PROTOCOL_H
#define PROTOCOL_VERSION 47
#define PROTOCOL_VERSION 48
// server to client
#define svc_bad 0 // immediately crash client when received
@ -31,7 +31,7 @@ GNU General Public License for more details.
#define svc_stufftext 9 // [string] stuffed into client's console buffer
#define svc_setangle 10 // [angle angle angle] set the view angle to this absolute value
#define svc_serverdata 11 // [long] protocol ...
#define svc_lightstyle 12 // [index][pattern]
#define svc_lightstyle 12 // [index][pattern][float]
#define svc_updateuserinfo 13 // [byte] playernum, [string] userinfo
#define svc_deltatable 14 // [table header][...]
#define svc_clientdata 15 // [...]

View File

@ -626,7 +626,7 @@ void SV_TouchLinks( edict_t *ent, areanode_t *node );
int SV_TruePointContents( const vec3_t p );
int SV_PointContents( const vec3_t p );
void SV_RunLightStyles( void );
void SV_SetLightStyle( int style, const char* s );
void SV_SetLightStyle( int style, const char* s, float f );
const char *SV_GetLightStyle( int style );
int SV_LightForEntity( edict_t *pEdict );
void SV_ClearPhysEnts( void );

View File

@ -1438,6 +1438,7 @@ void SV_WriteLightstyles_f( sv_client_t *cl )
BF_WriteByte( &cl->netchan.message, svc_lightstyle );
BF_WriteByte( &cl->netchan.message, start );
BF_WriteString( &cl->netchan.message, sv.lightstyles[start].pattern );
BF_WriteFloat( &cl->netchan.message, sv.lightstyles[start].time );
}
start++;
}

View File

@ -2359,7 +2359,7 @@ void pfnLightStyle( int style, const char* val )
if( style >= MAX_LIGHTSTYLES )
Host_Error( "SV_LightStyle: style: %i >= %d", style, MAX_LIGHTSTYLES );
SV_SetLightStyle( style, val ); // set correct style
SV_SetLightStyle( style, val, 0.0f ); // set correct style
}
/*

View File

@ -98,7 +98,8 @@ typedef struct
typedef struct
{
int index;
char style[64];
char style[256];
float time;
} SAVE_LIGHTSTYLE;
static TYPEDESCRIPTION gGameHeader[] =
@ -144,7 +145,8 @@ static TYPEDESCRIPTION gAdjacency[] =
static TYPEDESCRIPTION gLightStyle[] =
{
DEFINE_FIELD( SAVE_LIGHTSTYLE, index, FIELD_INTEGER ),
DEFINE_ARRAY( SAVE_LIGHTSTYLE, style, FIELD_CHARACTER, 64 ),
DEFINE_ARRAY( SAVE_LIGHTSTYLE, style, FIELD_CHARACTER, 256 ),
DEFINE_FIELD( SAVE_LIGHTSTYLE, time, FIELD_FLOAT ),
};
static TYPEDESCRIPTION gEntityTable[] =
@ -845,6 +847,7 @@ void SV_SaveGameStateGlobals( SAVERESTOREDATA *pSaveData )
if( sv.lightstyles[i].pattern[0] )
{
light.index = i;
light.time = sv.lightstyles[i].time;
Q_strncpy( light.style, sv.lightstyles[i].pattern, sizeof( light.style ));
svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "LIGHTSTYLE", &light, gLightStyle, ARRAYSIZE( gLightStyle ));
}
@ -974,7 +977,7 @@ void SV_ParseSaveTables( SAVERESTOREDATA *pSaveData, SAVE_HEADER *pHeader, int s
for( i = 0; i < pHeader->lightStyleCount; i++ )
{
svgame.dllFuncs.pfnSaveReadFields( pSaveData, "LIGHTSTYLE", &light, gLightStyle, ARRAYSIZE( gLightStyle ));
if( setupLightstyles ) SV_SetLightStyle( light.index, light.style );
if( setupLightstyles ) SV_SetLightStyle( light.index, light.style, light.time );
}
}

View File

@ -31,8 +31,6 @@ typedef struct moveclip_s
int flags; // trace flags
} moveclip_t;
static int sv_lastofs; // lightstyles code use this
/*
===============================================================================
@ -414,8 +412,10 @@ void SV_ClearWorld( void )
// clear lightstyles
for( i = 0; i < MAX_LIGHTSTYLES; i++ )
{
sv.lightstyles[i].value = 256.0f;
sv_lastofs = -1;
sv.lightstyles[i].time = 0.0f;
}
Q_memset( sv_areanodes, 0, sizeof( sv_areanodes ));
sv_numareanodes = 0;
@ -1537,13 +1537,11 @@ void SV_RunLightStyles( void )
lightstyle_t *ls;
// run lightstyles animation
ofs = (sv.time * 10);
if( ofs == sv_lastofs ) return;
sv_lastofs = ofs;
for( i = 0, ls = sv.lightstyles; i < MAX_LIGHTSTYLES; i++, ls++ )
{
ls->time += host.frametime;
ofs = (ls->time * 10);
if( ls->length == 0 ) ls->value = 256.0f * sv_lighting_modulate->value; // disable this light
else if( ls->length == 1 ) ls->value = ls->map[0] * 22.0f * sv_lighting_modulate->value;
else ls->value = ls->map[ofs%ls->length] * 22.0f * sv_lighting_modulate->value;
@ -1557,11 +1555,12 @@ SV_SetLightStyle
needs to get correct working SV_LightPoint
==================
*/
void SV_SetLightStyle( int style, const char* s )
void SV_SetLightStyle( int style, const char* s, float f )
{
int j, k;
Q_strncpy( sv.lightstyles[style].pattern, s, sizeof( sv.lightstyles[0].pattern ));
sv.lightstyles[style].time = f;
j = Q_strlen( s );
sv.lightstyles[style].length = j;
@ -1575,6 +1574,7 @@ void SV_SetLightStyle( int style, const char* s )
BF_WriteByte( &sv.reliable_datagram, svc_lightstyle );
BF_WriteByte( &sv.reliable_datagram, style );
BF_WriteString( &sv.reliable_datagram, sv.lightstyles[style].pattern );
BF_WriteFloat( &sv.reliable_datagram, sv.lightstyles[style].time );
}
/*