Compare commits

..

12 Commits

Author SHA1 Message Date
Alibek Omarov
0cf571602c ref: common: wscript: fix psvita build 2026-04-13 12:48:55 +05:00
Alibek Omarov
a125f90d12 ref: soft: fix build 2026-04-13 10:00:15 +05:00
Alibek Omarov
313cda5478 ref: add GL_ResampleTexture to libref_common 2026-04-12 23:30:08 +05:00
Alibek Omarov
fc4e7eb18b ref: move remaining light functions to libref_common 2026-04-12 23:18:31 +05:00
Alibek Omarov
0836519b2d ref: gl: refactor R_LightVec 2026-04-12 23:06:43 +05:00
Alibek Omarov
5eeb250907 ref: common: add R_PushDlightsForBmodel 2026-04-12 22:44:55 +05:00
Alibek Omarov
2e579d0dd3 ref: move R_PushDlights and R_MarkLights to ref_common 2026-04-12 22:38:43 +05:00
Alibek Omarov
8cd40db261 ref: move RunLightstyles to ref_common 2026-04-12 22:12:50 +05:00
Alibek Omarov
9d03959196 engine: move sprite texture loading back to engine, only leave rendering for renderer 2026-04-12 17:29:45 +05:00
Alibek Omarov
acd3b0258d ref: common: move malloc and GL_InitRandomTable 2026-04-12 16:10:48 +05:00
Alibek Omarov
0b49e60c22 ref: common: draft new static library, containing shared code for ref_gl and ref_soft 2026-04-12 15:52:33 +05:00
Alibek Omarov
6719443d99 engine: draft new RefAPI 14: remove reserved functions from render api, remove CL_AddCustomBeam 2026-04-12 15:25:19 +05:00
23 changed files with 357 additions and 226 deletions

View File

@@ -360,29 +360,6 @@ qboolean V_PreRender( void )
//============================================================================
/*
====================
V_ApplyRefUnderwater
apply underwater fov effect
====================
*/
static void V_ApplyRefUnderwater( ref_viewpass_t *rvp )
{
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP|RF_DRAW_OVERVIEW ))
return;
if( !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
return;
if( cl.local.waterlevel < 3 )
return;
rvp->fov_x = atan( tan( DEG2RAD( rvp->fov_x ) / 2 ) * ( 0.97f + sin( cl.time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
rvp->fov_y = atan( tan( DEG2RAD( rvp->fov_y ) / 2 ) * ( 1.03f - sin( cl.time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
}
/*
==================
V_RenderView
@@ -412,7 +389,6 @@ void V_RenderView( void )
clgame.dllFuncs.pfnCalcRefdef( &rp );
V_GetRefParams( &rp, &rvp );
V_RefApplyOverview( &rvp );
V_ApplyRefUnderwater( &rvp );
if( viewnum == 0 && FBitSet( rvp.flags, RF_ONLY_CLIENTDRAW ))
{

View File

@@ -578,7 +578,7 @@ static void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
if( !plight || !ent )
return;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
if( !RI.drawWorld || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
{
plight->shadelight = 0;
plight->ambientlight = 192;
@@ -1126,7 +1126,7 @@ init current time for a given model
*/
static void R_AliasSetupTimings( void )
{
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
// synchronize with server time
g_alias.time = gp_cl->time;

View File

@@ -61,7 +61,7 @@ void GL_BackendEndFrame( void )
{
mleaf_t *curleaf;
if( r_speeds->value <= 0 || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( r_speeds->value <= 0 || !RI.drawWorld )
return;
if( !RI.viewleaf )
@@ -616,7 +616,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
string basename;
int i = 1, flags, result;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || !WORLDMODEL )
if( !RI.drawWorld || !WORLDMODEL )
return false;
// make sure the specified size is valid
@@ -633,7 +633,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
r_side = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
// use client vieworg
if( !vieworg ) vieworg = RI.rvp.vieworigin;
if( !vieworg ) vieworg = RI.vieworg;
for( i = 0; i < 6; i++ )
{

View File

@@ -98,7 +98,7 @@ static void R_BeamComputeNormal( const vec3_t vStartPos, const vec3_t vNextPos,
VectorSubtract( vStartPos, vNextPos, vTangentY );
// vDirToBeam = vector from viewer origin to beam
VectorSubtract( vStartPos, RI.rvp.vieworigin, vDirToBeam );
VectorSubtract( vStartPos, RI.vieworg, vDirToBeam );
// get a vector that is perpendicular to us and perpendicular to the beam.
// this is used to fatten the beam.
@@ -1006,7 +1006,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
float flDistance;
// fade the beam if the player's not looking at the source
VectorSubtract( RI.rvp.vieworigin, pbeam->source, localDir );
VectorSubtract( RI.vieworg, pbeam->source, localDir );
flDot = DotProduct( delta, localDir );
VectorScale( delta, flDot, vecProjection );
VectorSubtract( localDir, vecProjection, tmp );

View File

@@ -47,7 +47,7 @@ qboolean R_CullModel( const cl_entity_t *e, const vec3_t absmin, const vec3_t ab
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
return true;
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ) && !ENGINE_GET_PARM( PARM_THIRDPERSON ) && CL_IsViewEntityLocalPlayer())
if( RP_NORMALPASS() && !ENGINE_GET_PARM( PARM_THIRDPERSON ) && CL_IsViewEntityLocalPlayer())
return false;
return true;
@@ -85,7 +85,7 @@ int R_CullSurface( const msurface_t *surf, const gl_frustum_t *frustum, uint cli
float dist;
// can use normal.z for world (optimisation)
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
if( RI.drawOrtho )
{
vec3_t orthonormal;

View File

@@ -70,9 +70,17 @@ void VGL_ShimEndFrame( void );
#define SHADE_LAMBERT 1.4953241
#define DEFAULT_ALPHATEST 0.0f
// refparams
#define RP_NONE 0
#define RP_ENVVIEW BIT( 0 ) // used for cubemapshot
#define RP_OLDVIEWLEAF BIT( 1 )
#define RP_CLIPPLANE BIT( 2 )
#define RP_NONVIEWERREF (RP_ENVVIEW)
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
@@ -119,16 +127,27 @@ typedef struct gltexture_s
typedef struct
{
ref_viewpass_t rvp;
int params; // rendering parameters
qboolean drawWorld; // ignore world for drawing PlayerModel
qboolean isSkyVisible; // sky is visible
qboolean onlyClientDraw; // disabled by client request
qboolean drawOrtho; // draw world as orthogonal projection
float fov_x, fov_y; // current view fov
cl_entity_t *currententity;
model_t *currentmodel;
cl_entity_t *currentbeam; // same as above but for beams
int viewport[4];
gl_frustum_t frustum;
mleaf_t *viewleaf;
mleaf_t *oldviewleaf;
vec3_t pvsorigin;
vec3_t vieworg; // locked vieworigin
vec3_t viewangles;
vec3_t vforward;
vec3_t vright;
vec3_t vup;

View File

@@ -101,7 +101,7 @@ static int R_TransEntityCompare( const void *a, const void *b )
{
VectorAverage( ent1->model->mins, ent1->model->maxs, org );
VectorAdd( ent1->origin, org, org );
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
VectorSubtract( RI.vieworg, org, vecLen );
dist1 = DotProduct( vecLen, vecLen );
}
else dist1 = 1000000000;
@@ -110,7 +110,7 @@ static int R_TransEntityCompare( const void *a, const void *b )
{
VectorAverage( ent2->model->mins, ent2->model->maxs, org );
VectorAdd( ent2->origin, org, org );
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
VectorSubtract( RI.vieworg, org, vecLen );
dist2 = DotProduct( vecLen, vecLen );
}
else dist2 = 1000000000;
@@ -317,7 +317,7 @@ static void R_Clear( int bitMask )
pglClear( bits );
// change ordering for overview
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
if( RI.drawOrtho )
{
gldepthmin = 1.0f;
gldepthmax = 0.0f;
@@ -340,7 +340,7 @@ R_GetFarClip
*/
static float R_GetFarClip( void )
{
if( WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( WORLDMODEL && RI.drawWorld )
return tr.movevars->zmax * 1.73f;
return 2048.0f;
}
@@ -352,26 +352,28 @@ R_SetupFrustum
*/
void R_SetupFrustum( void )
{
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
if( RP_NORMALPASS() && FBitSet( gp_host->features, ENGINE_QUAKE_COMPATIBLE ) && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ))
{
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97f + sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03f - sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
}
// build the transformation matrix for the given view angles
AngleVectors( RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup );
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
if( !r_lockfrustum.value )
{
VectorCopy( RI.rvp.vieworigin, RI.cullorigin );
VectorCopy( RI.vieworg, RI.cullorigin );
VectorCopy( RI.vforward, RI.cull_vforward );
VectorCopy( RI.vright, RI.cull_vright );
VectorCopy( RI.vup, RI.cull_vup );
}
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
{
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
if( RI.drawOrtho )
GL_FrustumInitOrtho( &RI.frustum, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
}
else
{
GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.rvp.fov_x, RI.rvp.fov_y ); // NOTE: we ignore nearplane here (mirrors only)
}
else GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.fov_x, RI.fov_y ); // NOTE: we ignore nearplane here (mirrors only)
}
/*
@@ -383,7 +385,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
{
GLfloat xMin, xMax, yMin, yMax, zNear, zFar;
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
if( RI.drawOrtho )
{
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
Matrix4x4_CreateOrtho( m, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
@@ -395,10 +397,10 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
zNear = 4.0f;
zFar = Q_max( 256.0f, RI.farClip );
yMax = zNear * tan( RI.rvp.fov_y * M_PI_F / 360.0f );
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
yMin = -yMax;
xMax = zNear * tan( RI.rvp.fov_x * M_PI_F / 360.0f );
xMax = zNear * tan( RI.fov_x * M_PI_F / 360.0f );
xMin = -xMax;
if( tr.rotation & 1 )
@@ -421,17 +423,17 @@ static void R_SetupModelviewMatrix( matrix4x4 m )
Matrix4x4_CreateModelview( m );
if( tr.rotation & 1 )
{
Matrix4x4_ConcatRotate( m, anglemod( -RI.rvp.viewangles[2] + 90 ), 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[1], 0, 0, 1 );
Matrix4x4_ConcatRotate( m, anglemod( -RI.viewangles[2] + 90 ), 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
}
else
{
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[2], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[1], 0, 0, 1 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[2], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
}
Matrix4x4_ConcatTranslate( m, -RI.rvp.vieworigin[0], -RI.rvp.vieworigin[1], -RI.rvp.vieworigin[2] );
Matrix4x4_ConcatTranslate( m, -RI.vieworg[0], -RI.vieworg[1], -RI.vieworg[2] );
}
/*
@@ -511,7 +513,7 @@ R_FindViewLeaf
void R_FindViewLeaf( void )
{
RI.oldviewleaf = RI.viewleaf;
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes );
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
}
/*
@@ -522,7 +524,7 @@ R_SetupFrame
static void R_SetupFrame( void )
{
// setup viewplane dist
RI.viewplanedist = DotProduct( RI.rvp.vieworigin, RI.vforward );
RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward );
// NOTE: this request is the fps-killer on some NVidia drivers
glState.isFogEnabled = pglIsEnabled( GL_FOG );
@@ -534,8 +536,11 @@ static void R_SetupFrame( void )
}
// current viewleaf
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
RI.isSkyVisible = false; // unknown at this moment
R_FindViewLeaf();
}
}
/*
@@ -552,15 +557,15 @@ void R_SetupGL( qboolean set_gl_state )
if( !set_gl_state ) return;
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
{
int x, x2, y, y2;
// set up viewport (main, playersetup)
x = floor( RI.rvp.viewport[0] * gpGlobals->width / gpGlobals->width );
x2 = ceil(( RI.rvp.viewport[0] + RI.rvp.viewport[2] ) * gpGlobals->width / gpGlobals->width );
y = floor( gpGlobals->height - RI.rvp.viewport[1] * gpGlobals->height / gpGlobals->height );
y2 = ceil( gpGlobals->height - ( RI.rvp.viewport[1] + RI.rvp.viewport[3] ) * gpGlobals->height / gpGlobals->height );
x = floor( RI.viewport[0] * gpGlobals->width / gpGlobals->width );
x2 = ceil(( RI.viewport[0] + RI.viewport[2] ) * gpGlobals->width / gpGlobals->width );
y = floor( gpGlobals->height - RI.viewport[1] * gpGlobals->height / gpGlobals->height );
y2 = ceil( gpGlobals->height - ( RI.viewport[1] + RI.viewport[3] ) * gpGlobals->height / gpGlobals->height );
if( tr.rotation & 1 )
pglViewport( y2, x, y - y2, x2 - x );
@@ -569,7 +574,7 @@ void R_SetupGL( qboolean set_gl_state )
else
{
// envpass, mirrorpass
pglViewport( RI.rvp.viewport[0], RI.rvp.viewport[1], RI.rvp.viewport[2], RI.rvp.viewport[3] );
pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] );
}
pglMatrixMode( GL_PROJECTION );
@@ -578,6 +583,20 @@ void R_SetupGL( qboolean set_gl_state )
pglMatrixMode( GL_MODELVIEW );
GL_LoadMatrix( RI.worldviewMatrix );
if( FBitSet( RI.params, RP_CLIPPLANE ))
{
GLdouble clip[4];
mplane_t *p = &RI.clipPlane;
clip[0] = p->normal[0];
clip[1] = p->normal[1];
clip[2] = p->normal[2];
clip[3] = -p->dist;
pglClipPlane( GL_CLIP_PLANE0, clip );
pglEnable( GL_CLIP_PLANE0 );
}
GL_Cull( GL_FRONT );
pglDisable( GL_BLEND );
@@ -585,6 +604,17 @@ void R_SetupGL( qboolean set_gl_state )
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
/*
=============
R_EndGL
=============
*/
static void R_EndGL( void )
{
if( RI.params & RP_CLIPPLANE )
pglDisable( GL_CLIP_PLANE0 );
}
/*
=============
R_RecursiveFindWaterTexture
@@ -701,7 +731,7 @@ static void R_CheckFog( void )
RI.fogEnabled = false;
if( FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ) || ENGINE_GET_PARM( PARM_WATER_LEVEL ) < 3 || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || !RI.viewleaf )
if( RI.onlyClientDraw || ENGINE_GET_PARM( PARM_WATER_LEVEL ) < 3 || !RI.drawWorld || !RI.viewleaf )
{
if( RI.cached_waterlevel == 3 )
{
@@ -717,7 +747,7 @@ static void R_CheckFog( void )
return;
}
ent = gEngfuncs.CL_GetWaterEntity( RI.rvp.vieworigin );
ent = gEngfuncs.CL_GetWaterEntity( RI.vieworg );
if( ent && ent->model && ent->model->type == mod_brush && ent->curstate.skin < 0 )
cnt = ent->curstate.skin;
else cnt = RI.viewleaf->contents;
@@ -823,7 +853,7 @@ static void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
// first draw solid entities
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.draw_list->solid_entities[i];
RI.currentmodel = RI.currententity->model;
@@ -855,7 +885,7 @@ static void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
// draw sprites seperately, because of alpha blending
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.draw_list->solid_entities[i];
RI.currentmodel = RI.currententity->model;
@@ -873,20 +903,20 @@ static void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
{
gEngfuncs.CL_DrawEFX( tr.frametime, false );
}
GL_CheckForErrors();
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
gEngfuncs.pfnDrawNormalTriangles();
GL_CheckForErrors();
// then draw translucent entities
for( i = 0; i < tr.draw_list->num_trans_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_trans_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.draw_list->trans_entities[i];
RI.currentmodel = RI.currententity->model;
@@ -922,7 +952,7 @@ static void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
gEngfuncs.pfnDrawTransparentTriangles ();
@@ -930,7 +960,7 @@ static void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
{
R_AllowFog( false );
gEngfuncs.CL_DrawEFX( tr.frametime, true );
@@ -941,7 +971,7 @@ static void R_DrawEntitiesOnList( void )
pglDisable( GL_BLEND ); // Trinity Render issues
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
R_DrawViewModel();
gEngfuncs.CL_ExtraUpdate();
@@ -957,11 +987,11 @@ R_SetupRefParams must be called right before
*/
void R_RenderScene( void )
{
if( !WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !WORLDMODEL && RI.drawWorld )
gEngfuncs.Host_Error( "%s: NULL worldmodel\n", __func__ );
// frametime is valid only for normal pass
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0;
@@ -977,7 +1007,7 @@ void R_RenderScene( void )
R_MarkLeaves();
R_DrawFog ();
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
R_AnimateRipples();
R_CheckGLFog();
@@ -989,6 +1019,8 @@ void R_RenderScene( void )
R_DrawEntitiesOnList();
R_DrawWaterSurfaces();
R_EndGL();
}
void R_GammaChanged( qboolean do_reset_gamma )
@@ -1077,9 +1109,28 @@ set initial params for renderer
*/
void R_SetupRefParams( const ref_viewpass_t *rvp )
{
RI.rvp = *rvp;
RI.params = RP_NONE;
RI.drawWorld = FBitSet( rvp->flags, RF_DRAW_WORLD );
RI.onlyClientDraw = FBitSet( rvp->flags, RF_ONLY_CLIENTDRAW );
RI.farClip = 0;
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
else RI.drawOrtho = false;
// setup viewport
RI.viewport[0] = rvp->viewport[0];
RI.viewport[1] = rvp->viewport[1];
RI.viewport[2] = rvp->viewport[2];
RI.viewport[3] = rvp->viewport[3];
// calc FOV
RI.fov_x = rvp->fov_x;
RI.fov_y = rvp->fov_y;
VectorCopy( rvp->vieworigin, RI.vieworg );
VectorCopy( rvp->viewangles, RI.viewangles );
VectorCopy( rvp->vieworigin, RI.pvsorigin );
}
/*
@@ -1095,7 +1146,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
// setup the initial render params
R_SetupRefParams( rvp );
if( gl_finish.value && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( gl_finish.value && RI.drawWorld )
pglFinish();
// completely override rendering
@@ -1113,7 +1164,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
}
tr.fCustomRendering = false;
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
R_RunViewmodelEvents();
tr.realframecount++; // right called after viewmodel events
@@ -1195,7 +1246,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
@@ -1204,7 +1255,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
@@ -1213,7 +1264,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
@@ -1222,7 +1273,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
@@ -1258,7 +1309,7 @@ int CL_FxBlend( cl_entity_t *e )
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, RI.rvp.vieworigin, tmp );
VectorSubtract( tmp, RI.vieworg, tmp );
dist = DotProduct( tmp, RI.vforward );
// turn off distance fade

View File

@@ -73,9 +73,9 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
size = partsize; // get initial size of particle
// scale up to keep particles from disappearing
size += (p->org[0] - RI.rvp.vieworigin[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.rvp.vieworigin[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.rvp.vieworigin[2]) * RI.cull_vforward[2];
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;

View File

@@ -956,7 +956,7 @@ static void EmitWaterPolys( msurface_t *warp, qboolean reverse, qboolean ripples
if( !warp->polys ) return;
// set the current waveheight
if( warp->polys->verts[0][2] >= RI.rvp.vieworigin[2] )
if( warp->polys->verts[0][2] >= RI.vieworg[2] )
waveHeight = -RI.currententity->curstate.scale;
else waveHeight = RI.currententity->curstate.scale;
@@ -1610,7 +1610,7 @@ void R_DrawWaterSurfaces( void )
msurface_t *s;
texture_t *t;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.drawWorld || RI.onlyClientDraw )
return;
// non-transparent water is already drawed
@@ -1792,8 +1792,7 @@ void R_DrawBrushModel( cl_entity_t *e )
qboolean rotated;
qboolean allow_vbo = R_HasEnabledVBO();
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
return;
if( !RI.drawWorld ) return;
model_t *clmodel = e->model;
@@ -3684,7 +3683,7 @@ void R_DrawWorld( void )
return;
RI.currentmodel = RI.currententity->model;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.drawWorld || RI.onlyClientDraw )
return;
VectorCopy( RI.cullorigin, tr.modelorg );
@@ -3700,7 +3699,7 @@ void R_DrawWorld( void )
R_ClearSkyBox ();
start = gEngfuncs.pfnTime();
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
if( RI.drawOrtho )
R_DrawWorldTopView( WORLDMODEL->nodes, RI.frustum.clipFlags );
else R_RecursiveWorldNode( WORLDMODEL->nodes, RI.frustum.clipFlags );
end = gEngfuncs.pfnTime();
@@ -3749,8 +3748,7 @@ void R_MarkLeaves( void )
vec3_t test;
int i;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
return;
if( !RI.drawWorld ) return;
if( FBitSet( r_novis.flags, FCVAR_CHANGED ) || tr.fResetVis )
{
@@ -3760,15 +3758,15 @@ void R_MarkLeaves( void )
RI.viewleaf = NULL;
}
VectorCopy( RI.rvp.vieworigin, test );
VectorCopy( RI.pvsorigin, test );
if( RI.viewleaf != NULL )
{
// merge two leafs that can be a crossed-line contents
if( RI.viewleaf->contents == CONTENTS_EMPTY )
VectorSet( test, RI.rvp.vieworigin[0], RI.rvp.vieworigin[1], RI.rvp.vieworigin[2] - 16.0f );
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
else
VectorSet( test, RI.rvp.vieworigin[0], RI.rvp.vieworigin[1], RI.rvp.vieworigin[2] + 16.0f );
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
@@ -3786,10 +3784,10 @@ void R_MarkLeaves( void )
RI.oldviewleaf = RI.viewleaf;
tr.visframecount++;
if( r_novis.value || FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ) || !RI.viewleaf || !WORLDMODEL->visdata )
if( r_novis.value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
gEngfuncs.R_FatPVS( RI.rvp.vieworigin, r_pvs_radius->value, RI.visbytes, false, novis );
gEngfuncs.R_FatPVS( RI.pvsorigin, r_pvs_radius->value, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis )
gEngfuncs.R_FatPVS( test, r_pvs_radius->value, RI.visbytes, true, novis );

View File

@@ -143,7 +143,7 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
{
// e.g. doom-style sprite monsters
float yaw = ent->angles[YAW];
int angleframe = (int)(Q_rint(( RI.rvp.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
int angleframe = (int)(Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
if( m_fDoInterp )
{
@@ -233,12 +233,12 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
vec3_t glowDist;
pmtrace_t *tr;
VectorSubtract( origin, RI.rvp.vieworigin, glowDist );
VectorSubtract( origin, RI.vieworg, glowDist );
dist = VectorLength( glowDist );
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RP_NORMALPASS( ))
{
tr = gEngfuncs.EV_VisTraceLine( RI.rvp.vieworigin, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
if(( 1.0f - tr->fraction ) * dist > 8.0f )
return 0.0f;
@@ -270,9 +270,9 @@ static qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
TriWorldToScreen( origin, v );
if( v[0] < RI.rvp.viewport[0] || v[0] > RI.rvp.viewport[0] + RI.rvp.viewport[2] )
if( v[0] < RI.viewport[0] || v[0] > RI.viewport[0] + RI.viewport[2] )
return true; // do scissor
if( v[1] < RI.rvp.viewport[1] || v[1] > RI.rvp.viewport[1] + RI.rvp.viewport[3] )
if( v[1] < RI.viewport[1] || v[1] > RI.viewport[1] + RI.viewport[3] )
return true; // do scissor
blend = R_SpriteGlowBlend( origin, e->curstate.rendermode, e->curstate.renderfx, pscale );
@@ -386,7 +386,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
vec3_t v_forward, v_right, v_up;
vec3_t origin, color, color2 = { 0.0f };
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( RI.params & RP_ENVVIEW )
return;
model = e->model;
@@ -495,7 +495,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
VectorSubtract( origin, v_forward, origin );
break;
case SPR_FACING_UPRIGHT:
VectorSet( v_right, origin[1] - RI.rvp.vieworigin[1], -(origin[0] - RI.rvp.vieworigin[0]), 0.0f );
VectorSet( v_right, origin[1] - RI.vieworg[1], -(origin[0] - RI.vieworg[0]), 0.0f );
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
VectorNormalize( v_right );
break;

View File

@@ -167,7 +167,7 @@ init current time for a given model
*/
static void R_StudioSetupTimings( void )
{
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
// synchronize with server time
g_studio.time = gp_cl->time;
@@ -369,7 +369,7 @@ pfnPlayerInfo
*/
player_info_t *pfnPlayerInfo( int index )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
index = -1;
return gEngfuncs.pfnPlayerInfo( index );
@@ -394,7 +394,7 @@ pfnGetPlayerState
*/
static entity_state_t *R_StudioGetPlayerState( int index )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
return &RI.currententity->curstate;
return gEngfuncs.pfnGetPlayerState( index );
@@ -432,7 +432,7 @@ pfnGetViewInfo
*/
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
{
if( origin ) VectorCopy( RI.rvp.vieworigin, origin );
if( origin ) VectorCopy( RI.vieworg, origin );
if( forwardv ) VectorCopy( RI.vforward, forwardv );
if( rightv ) VectorCopy( RI.vright, rightv );
if( upv ) VectorCopy( RI.vup, upv );
@@ -1328,7 +1328,7 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
if( !plight || !ent || !ent->model )
return;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
if( !RI.drawWorld || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
{
plight->shadelight = 0;
plight->ambientlight = 192;
@@ -2662,7 +2662,7 @@ static model_t *R_StudioSetupPlayerModel( int index )
state = &g_studio.player_models[index];
// g-cont: force for "dev-mode", non-local games and menu preview
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) ) && info->model[0] )
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !RI.drawWorld ) && info->model[0] )
{
if( Q_strcmp( state->name, info->model ))
{
@@ -2914,7 +2914,7 @@ R_StudioSetChromeOrigin
*/
static void R_StudioSetChromeOrigin( void )
{
VectorCopy( RI.rvp.vieworigin, g_studio.chrome_origin );
VectorCopy( RI.vieworg, g_studio.chrome_origin );
}
/*
@@ -3398,7 +3398,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( flags & STUDIO_RENDER )
{
// change body if it's a menu entity
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD )))
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !RI.drawWorld ))
{
// show highest resolution multiplayer model
RI.currententity->curstate.body = 255;
@@ -3554,7 +3554,7 @@ R_StudioDrawModelInternal
*/
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
{
if( e->player )
R_StudioDrawPlayer( flags, &e->curstate );
@@ -3589,7 +3589,7 @@ R_DrawStudioModel
*/
void R_DrawStudioModel( cl_entity_t *e )
{
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
if( FBitSet( RI.params, RP_ENVVIEW ))
return;
R_StudioSetupTimings();
@@ -3644,7 +3644,7 @@ void R_RunViewmodelEvents( void )
return;
// ignore in thirdperson, camera view or client is died
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ) || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
RI.currententity = tr.viewent;
@@ -3694,7 +3694,7 @@ void R_DrawViewModel( void )
return;
// ignore in thirdperson, camera view or client is died
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ) || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
tr.blend = CL_FxBlend( view ) / 255.0f;

View File

@@ -226,10 +226,10 @@ int TriWorldToScreen( const float *world, float *screen )
retval = R_WorldToScreen( world, screen );
screen[0] = 0.5f * screen[0] * (float)RI.rvp.viewport[2];
screen[1] = -0.5f * screen[1] * (float)RI.rvp.viewport[3];
screen[0] += 0.5f * (float)RI.rvp.viewport[2];
screen[1] += 0.5f * (float)RI.rvp.viewport[3];
screen[0] = 0.5f * screen[0] * (float)RI.viewport[2];
screen[1] = -0.5f * screen[1] * (float)RI.viewport[3];
screen[0] += 0.5f * (float)RI.viewport[2];
screen[1] += 0.5f * (float)RI.viewport[3];
return retval;
}

View File

@@ -339,6 +339,10 @@ R_DrawSkybox
*/
void R_DrawSkyBox( void )
{
int i;
RI.isSkyVisible = true;
// don't fogging skybox (this fix old Half-Life bug)
if( !RI.fogSkybox ) R_AllowFog( false );
@@ -349,7 +353,7 @@ void R_DrawSkyBox( void )
pglDisable( GL_ALPHA_TEST );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
for( int i = 0; i < SKYBOX_MAX_SIDES; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
continue;
@@ -417,7 +421,7 @@ static void R_CloudTexCoord( const vec3_t v, float speed, float *s, float *t )
speedscale = gp_cl->time * speed;
speedscale -= (int)speedscale & ~127;
VectorSubtract( v, RI.rvp.vieworigin, dir );
VectorSubtract( v, RI.vieworg, dir );
dir[2] *= 3.0f; // flatten the sphere
length = VectorLength( dir );
@@ -529,12 +533,16 @@ Quake-style clouds
*/
void R_DrawClouds( void )
{
int i;
RI.isSkyVisible = true;
if( RI.fogEnabled )
pglFogf( GL_FOG_DENSITY, RI.fogDensity * 0.25f );
pglDepthFunc( GL_GEQUAL );
pglDepthMask( GL_FALSE );
for( int i = 0; i < SKYBOX_MAX_SIDES; i++ )
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
{
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
continue;

View File

@@ -100,7 +100,7 @@ static void R_BeamComputeNormal( const vec3_t vStartPos, const vec3_t vNextPos,
VectorSubtract( vStartPos, vNextPos, vTangentY );
// vDirToBeam = vector from viewer origin to beam
VectorSubtract( vStartPos, RI.rvp.vieworigin, vDirToBeam );
VectorSubtract( vStartPos, RI.vieworg, vDirToBeam );
// get a vector that is perpendicular to us and perpendicular to the beam.
// this is used to fatten the beam.
@@ -1000,7 +1000,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
float flDistance;
// fade the beam if the player's not looking at the source
VectorSubtract( RI.rvp.vieworigin, pbeam->source, localDir );
VectorSubtract( RI.vieworg, pbeam->source, localDir );
flDot = DotProduct( delta, localDir );
VectorScale( delta, flDot, vecProjection );
VectorSubtract( localDir, vecProjection, tmp );

View File

@@ -643,14 +643,14 @@ R_RenderWorld
*/
void R_RenderWorld( void )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
return;
// auto cycle the world frame for texture animation
RI.currententity = CL_GetEntityByIndex( 0 );
// RI.currententity->frame = (int)(gp_cl->time*2);
VectorCopy( RI.rvp.vieworigin, tr.modelorg );
VectorCopy( RI.vieworg, tr.modelorg );
RI.currentmodel = WORLDMODEL;
r_pcurrentvertbase = RI.currentmodel->vertexes;

View File

@@ -877,7 +877,7 @@ static void D_TurbulentSurf( surf_t *s )
// TODO: store once at start of frame
RI.currententity = s->entity; // FIXME: make this passed in to
// R_RotateBmodel ()
VectorSubtract( RI.rvp.vieworigin, RI.currententity->origin,
VectorSubtract( RI.vieworg, RI.currententity->origin,
local_modelorg );
TransformVector( local_modelorg, transformed_modelorg );
@@ -940,7 +940,7 @@ static void D_AlphaSurf( surf_t *s )
// TODO: store once at start of frame
RI.currententity = s->entity; // FIXME: make this passed in to
// R_RotateBmodel ()
VectorSubtract( RI.rvp.vieworigin, RI.currententity->origin, local_modelorg );
VectorSubtract( RI.vieworg, RI.currententity->origin, local_modelorg );
TransformVector( local_modelorg, transformed_modelorg );
R_RotateBmodel(); // FIXME: don't mess with the frustum,
@@ -1021,7 +1021,7 @@ static void D_SolidSurf( surf_t *s )
// TODO: store once at start of frame
RI.currententity = s->entity; // FIXME: make this passed in to
// R_RotateBmodel ()
VectorSubtract( RI.rvp.vieworigin, RI.currententity->origin, local_modelorg );
VectorSubtract( RI.vieworg, RI.currententity->origin, local_modelorg );
TransformVector( local_modelorg, transformed_modelorg );
R_RotateBmodel(); // FIXME: don't mess with the frustum,
@@ -1123,7 +1123,7 @@ void D_DrawSurfaces( void )
surf_t *s;
// currententity = NULL; //&r_worldentity;
VectorSubtract( RI.rvp.vieworigin, vec3_origin, tr.modelorg );
VectorSubtract( RI.vieworg, vec3_origin, tr.modelorg );
TransformVector( tr.modelorg, transformed_modelorg );
VectorCopy( transformed_modelorg, world_transformed_modelorg );
@@ -1148,7 +1148,7 @@ void D_DrawSurfaces( void )
D_DrawflatSurfaces();
// RI.currententity = NULL; //&r_worldentity;
VectorSubtract( RI.rvp.vieworigin, vec3_origin, tr.modelorg );
VectorSubtract( RI.vieworg, vec3_origin, tr.modelorg );
R_TransformFrustum();
}

View File

@@ -61,9 +61,17 @@ typedef int fixed16_t;
#define SHADE_LAMBERT 1.4953241
#define DEFAULT_ALPHATEST 0.0f
// refparams
#define RP_NONE 0
#define RP_ENVVIEW BIT( 0 ) // used for cubemapshot
#define RP_OLDVIEWLEAF BIT( 1 )
#define RP_CLIPPLANE BIT( 2 )
#define RP_NONVIEWERREF ( RP_ENVVIEW )
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
#define RP_LOCALCLIENT( e ) (( e ) != NULL && ( e )->index == ( gp_cl->playernum + 1 ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
@@ -122,16 +130,27 @@ extern viddef_t vid;
typedef struct
{
ref_viewpass_t rvp;
int params; // rendering parameters
qboolean drawWorld; // ignore world for drawing PlayerModel
qboolean isSkyVisible; // sky is visible
qboolean onlyClientDraw; // disabled by client request
qboolean drawOrtho; // draw world as orthogonal projection
float fov_x, fov_y; // current view fov
cl_entity_t *currententity;
model_t *currentmodel;
cl_entity_t *currentbeam; // same as above but for beams
int viewport[4];
// gl_frustum_t frustum;
mleaf_t *viewleaf;
mleaf_t *oldviewleaf;
vec3_t pvsorigin;
vec3_t vieworg; // locked vieworigin
vec3_t viewangles;
vec3_t vforward;
vec3_t vright;
vec3_t vup;

View File

@@ -172,7 +172,7 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
{
VectorAverage( ent1->model->mins, ent1->model->maxs, org );
VectorAdd( ent1->origin, org, org );
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
VectorSubtract( RI.vieworg, org, vecLen );
dist1 = DotProduct( vecLen, vecLen );
}
else
@@ -182,7 +182,7 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
{
VectorAverage( ent2->model->mins, ent2->model->maxs, org );
VectorAdd( ent2->origin, org, org );
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
VectorSubtract( RI.vieworg, org, vecLen );
dist2 = DotProduct( vecLen, vecLen );
}
else
@@ -379,7 +379,7 @@ R_GetFarClip
*/
static float R_GetFarClip( void )
{
if( WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( WORLDMODEL && RI.drawWorld )
return tr.movevars->zmax * 1.73f;
return 2048.0f;
}
@@ -392,10 +392,10 @@ R_SetupFrustum
void R_SetupFrustum( void )
{
// build the transformation matrix for the given view angles
AngleVectors( RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup );
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
{
VectorCopy( RI.rvp.vieworigin, RI.cullorigin );
VectorCopy( RI.vieworg, RI.cullorigin );
VectorCopy( RI.vforward, RI.cull_vforward );
VectorCopy( RI.vright, RI.cull_vright );
VectorCopy( RI.vup, RI.cull_vup );
@@ -411,15 +411,22 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
{
float xMin, xMax, yMin, yMax, zNear, zFar;
if( RI.drawOrtho )
{
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
Matrix4x4_CreateOrtho( m, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
return;
}
RI.farClip = R_GetFarClip();
zNear = 4.0f;
zFar = Q_max( 256.0f, RI.farClip );
yMax = zNear * tan( RI.rvp.fov_y * M_PI_F / 360.0f );
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
yMin = -yMax;
xMax = zNear * tan( RI.rvp.fov_x * M_PI_F / 360.0f );
xMax = zNear * tan( RI.fov_x * M_PI_F / 360.0f );
xMin = -xMax;
Matrix4x4_CreateProjection( m, xMax, xMin, yMax, yMin, zNear, zFar );
@@ -433,10 +440,10 @@ R_SetupModelviewMatrix
static void R_SetupModelviewMatrix( matrix4x4 m )
{
Matrix4x4_CreateModelview( m );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[2], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[1], 0, 0, 1 );
Matrix4x4_ConcatTranslate( m, -RI.rvp.vieworigin[0], -RI.rvp.vieworigin[1], -RI.rvp.vieworigin[2] );
Matrix4x4_ConcatRotate( m, -RI.viewangles[2], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
Matrix4x4_ConcatTranslate( m, -RI.vieworg[0], -RI.vieworg[1], -RI.vieworg[2] );
}
/*
@@ -474,7 +481,7 @@ R_FindViewLeaf
void R_FindViewLeaf( void )
{
RI.oldviewleaf = RI.viewleaf;
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes );
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
}
/*
@@ -485,7 +492,7 @@ R_SetupFrame
static void R_SetupFrame( void )
{
// setup viewplane dist
RI.viewplanedist = DotProduct( RI.rvp.vieworigin, RI.vforward );
RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward );
// if( !gl_nosort->value )
{
@@ -494,8 +501,11 @@ static void R_SetupFrame( void )
}
// current viewleaf
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
RI.isSkyVisible = false; // unknown at this moment
R_FindViewLeaf();
}
// setup twice until globals fully refactored
R_SetupFrameQ();
@@ -517,7 +527,7 @@ static void R_DrawEntitiesOnList( void )
d_pdrawspans = R_PolysetFillSpans8;
GL_SetRenderMode( kRenderNormal );
// first draw solid entities
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.draw_list->solid_entities[i];
RI.currentmodel = RI.currententity->model;
@@ -545,7 +555,7 @@ static void R_DrawEntitiesOnList( void )
R_SetUpWorldTransform();
// draw sprites seperately, because of alpha blending
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.draw_list->solid_entities[i];
RI.currentmodel = RI.currententity->model;
@@ -561,17 +571,17 @@ static void R_DrawEntitiesOnList( void )
}
}
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
{
gEngfuncs.CL_DrawEFX( tr.frametime, false );
}
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
gEngfuncs.pfnDrawNormalTriangles();
d_pdrawspans = R_PolysetDrawSpans8_33;
// then draw translucent entities
for( i = 0; i < tr.draw_list->num_trans_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_trans_entities && !RI.onlyClientDraw; i++ )
{
RI.currententity = tr.draw_list->trans_entities[i];
RI.currentmodel = RI.currententity->model;
@@ -609,10 +619,12 @@ static void R_DrawEntitiesOnList( void )
}
}
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
gEngfuncs.pfnDrawTransparentTriangles();
}
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
{
R_AllowFog( false );
gEngfuncs.CL_DrawEFX( tr.frametime, true );
@@ -621,7 +633,7 @@ static void R_DrawEntitiesOnList( void )
GL_SetRenderMode( kRenderNormal );
R_SetUpWorldTransform();
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
R_DrawViewModel();
gEngfuncs.CL_ExtraUpdate();
@@ -792,7 +804,7 @@ static void R_DrawBEntitiesOnList( void )
VectorCopy( tr.modelorg, oldorigin );
insubmodel = true;
for( i = 0; i < tr.draw_list->num_edge_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
for( i = 0; i < tr.draw_list->num_edge_entities && !RI.onlyClientDraw; i++ )
{
int k;
RI.currententity = tr.draw_list->edge_entities[i];
@@ -820,7 +832,7 @@ static void R_DrawBEntitiesOnList( void )
continue; // no part in a visible leaf
VectorCopy( RI.currententity->origin, r_entorigin );
VectorSubtract( RI.rvp.vieworigin, r_entorigin, tr.modelorg );
VectorSubtract( RI.vieworg, r_entorigin, tr.modelorg );
// VectorSubtract (r_origin, RI.currententity->origin, modelorg);
r_pcurrentvertbase = RI.currentmodel->vertexes;
@@ -878,7 +890,7 @@ void R_DrawBrushModel( cl_entity_t *pent )
surf_t lsurfs[NUMSTACKSURFACES
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
return;
if( auxedges )
@@ -932,7 +944,7 @@ void R_DrawBrushModel( cl_entity_t *pent )
alphaspans = true;
VectorCopy( RI.currententity->origin, r_entorigin );
VectorSubtract( RI.rvp.vieworigin, r_entorigin, tr.modelorg );
VectorSubtract( RI.vieworg, r_entorigin, tr.modelorg );
// VectorSubtract (r_origin, RI.currententity->origin, modelorg);
r_pcurrentvertbase = RI.currentmodel->vertexes;
@@ -986,7 +998,7 @@ static void R_EdgeDrawing( void )
surf_t lsurfs[NUMSTACKSURFACES
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
return;
if( auxedges )
@@ -1041,7 +1053,7 @@ static void R_MarkLeaves( void )
tr.visframecount++;
r_oldviewcluster = r_viewcluster;
gEngfuncs.R_FatPVS( RI.rvp.vieworigin, r_pvs_radius->value, RI.visbytes, false, false );
gEngfuncs.R_FatPVS( RI.pvsorigin, r_pvs_radius->value, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), false );
vis = RI.visbytes;
for( i = 0; i < WORLDMODEL->numleafs; i++ )
@@ -1070,11 +1082,14 @@ R_SetupRefParams must be called right before
*/
void GAME_EXPORT R_RenderScene( void )
{
if( !WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !WORLDMODEL && RI.drawWorld )
gEngfuncs.Host_Error( "%s: NULL worldmodel\n", __func__ );
// frametime is valid only for normal pass
tr.frametime = gp_cl->time - gp_cl->oldtime;
if( RP_NORMALPASS( ))
tr.frametime = gp_cl->time - gp_cl->oldtime;
else
tr.frametime = 0.0;
// begin a new frame
tr.framecount++;
@@ -1145,7 +1160,28 @@ set initial params for renderer
*/
void R_SetupRefParams( const ref_viewpass_t *rvp )
{
RI.rvp = *rvp;
RI.params = RP_NONE;
RI.drawWorld = FBitSet( rvp->flags, RF_DRAW_WORLD );
RI.onlyClientDraw = FBitSet( rvp->flags, RF_ONLY_CLIENTDRAW );
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
else
RI.drawOrtho = false;
// setup viewport
RI.viewport[0] = rvp->viewport[0];
RI.viewport[1] = rvp->viewport[1];
RI.viewport[2] = rvp->viewport[2];
RI.viewport[3] = rvp->viewport[3];
// calc FOV
RI.fov_x = rvp->fov_x;
RI.fov_y = rvp->fov_y;
VectorCopy( rvp->vieworigin, RI.vieworg );
VectorCopy( rvp->viewangles, RI.viewangles );
VectorCopy( rvp->vieworigin, RI.pvsorigin );
}
/*
@@ -1180,7 +1216,7 @@ void GAME_EXPORT R_RenderFrame( const ref_viewpass_t *rvp )
}
tr.fCustomRendering = false;
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
if( !RI.onlyClientDraw )
R_RunViewmodelEvents();
tr.realframecount++; // right called after viewmodel events
@@ -1446,31 +1482,43 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else
e->curstate.renderamt = 0;
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else
e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else
e->curstate.renderamt = 0;
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else
e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else
e->curstate.renderamt = 255;
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else
e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else
e->curstate.renderamt = 255;
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else
e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
@@ -1511,7 +1559,7 @@ int CL_FxBlend( cl_entity_t *e )
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, RI.rvp.vieworigin, tmp );
VectorSubtract( tmp, RI.vieworg, tmp );
dist = DotProduct( tmp, RI.vforward );
// turn off distance fade

View File

@@ -87,8 +87,10 @@ void D_ViewChanged( void )
/*
** clear Z-buffer and color-buffers if we're doing the gallery
*/
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
{
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ));
}
D_Patch();
}
@@ -182,8 +184,8 @@ static void R_ViewChanged( vrect_t *vr )
RI.vrect = *vr;
horizontalFieldOfView = 2 * tan((float)RI.rvp.fov_x / 360.0f * M_PI_F );
verticalFieldOfView = 2 * tan((float)RI.rvp.fov_y / 360.0f * M_PI_F );
horizontalFieldOfView = 2 * tan((float)RI.fov_x / 360.0f * M_PI_F );
verticalFieldOfView = 2 * tan((float)RI.fov_y / 360.0f * M_PI_F );
RI.fvrectx = (float)RI.vrect.x;
RI.fvrectx_adj = (float)RI.vrect.x - 0.5f;
@@ -286,14 +288,14 @@ void R_SetupFrameQ( void )
// build the transformation matrix for the given view angles
VectorCopy( RI.rvp.vieworigin, tr.modelorg );
VectorCopy( RI.vieworg, tr.modelorg );
// AngleVectors (RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup);
// AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup);
// current viewleaf
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes );
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.vieworg, WORLDMODEL->nodes );
r_viewcluster = RI.viewleaf->cluster;
}
@@ -305,10 +307,10 @@ void R_SetupFrameQ( void )
vrect.y = 0;//r_newrefdef.y;
vrect.width = gpGlobals->width;
vrect.height = gpGlobals->height;*/
vrect.x = RI.rvp.viewport[0];
vrect.y = RI.rvp.viewport[1];
vrect.width = RI.rvp.viewport[2];
vrect.height = RI.rvp.viewport[3];
vrect.x = RI.viewport[0];
vrect.y = RI.viewport[1];
vrect.width = RI.viewport[2];
vrect.height = RI.viewport[3];
d_viewbuffer = (void *)vid.buffer;
r_screenwidth = vid.rowbytes;

View File

@@ -72,9 +72,9 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
size = partsize; // get initial size of particle
// scale up to keep particles from disappearing
size += ( p->org[0] - RI.rvp.vieworigin[0] ) * RI.cull_vforward[0];
size += ( p->org[1] - RI.rvp.vieworigin[1] ) * RI.cull_vforward[1];
size += ( p->org[2] - RI.rvp.vieworigin[2] ) * RI.cull_vforward[2];
size += ( p->org[0] - RI.vieworg[0] ) * RI.cull_vforward[0];
size += ( p->org[1] - RI.vieworg[1] ) * RI.cull_vforward[1];
size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2];
if( size < 20.0f )
size = partsize;

View File

@@ -65,12 +65,16 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
float dist, brightness;
vec3_t glowDist;
VectorSubtract( origin, RI.rvp.vieworigin, glowDist );
VectorSubtract( origin, RI.vieworg, glowDist );
dist = VectorLength( glowDist );
pmtrace_t *tr = gEngfuncs.EV_VisTraceLine( RI.rvp.vieworigin, origin, r_traceglow.value ? PM_GLASS_IGNORE : ( PM_GLASS_IGNORE | PM_STUDIO_IGNORE ));
if(( 1.0f - tr->fraction ) * dist > 8.0f )
return 0.0f;
if( RP_NORMALPASS( ))
{
pmtrace_t *tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : ( PM_GLASS_IGNORE | PM_STUDIO_IGNORE ));
if(( 1.0f - tr->fraction ) * dist > 8.0f )
return 0.0f;
}
if( renderfx == kRenderFxNoDissipation )
return 1.0f;
@@ -98,9 +102,9 @@ static qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
TriWorldToScreen( origin, v );
if( v[0] < RI.rvp.viewport[0] || v[0] > RI.rvp.viewport[0] + RI.rvp.viewport[2] )
if( v[0] < RI.viewport[0] || v[0] > RI.viewport[0] + RI.viewport[2] )
return true; // do scissor
if( v[1] < RI.rvp.viewport[1] || v[1] > RI.rvp.viewport[1] + RI.rvp.viewport[3] )
if( v[1] < RI.viewport[1] || v[1] > RI.viewport[1] + RI.viewport[3] )
return true; // do scissor
blend = R_SpriteGlowBlend( origin, e->curstate.rendermode, e->curstate.renderfx, pscale );
@@ -168,6 +172,9 @@ void R_DrawSpriteModel( cl_entity_t *e )
vec3_t v_forward, v_right, v_up;
vec3_t origin, color;
if( RI.params & RP_ENVVIEW )
return;
model = e->model;
psprite = (msprite_t *)model->cache.data;
VectorCopy( e->origin, origin ); // set render origin
@@ -235,7 +242,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
VectorSubtract( origin, v_forward, origin );
break;
case SPR_FACING_UPRIGHT:
VectorSet( v_right, origin[1] - RI.rvp.vieworigin[1], -( origin[0] - RI.rvp.vieworigin[0] ), 0.0f );
VectorSet( v_right, origin[1] - RI.vieworg[1], -( origin[0] - RI.vieworg[0] ), 0.0f );
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
VectorNormalize( v_right );
break;

View File

@@ -147,7 +147,7 @@ init current time for a given model
*/
static void R_StudioSetupTimings( void )
{
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( RI.drawWorld )
{
// synchronize with server time
g_studio.time = gp_cl->time;
@@ -353,7 +353,7 @@ pfnPlayerInfo
*/
player_info_t *pfnPlayerInfo( int index )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
index = -1;
return gEngfuncs.pfnPlayerInfo( index );
@@ -378,7 +378,7 @@ pfnGetPlayerState
*/
static entity_state_t *R_StudioGetPlayerState( int index )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
return &RI.currententity->curstate;
return gEngfuncs.pfnGetPlayerState( index );
@@ -420,7 +420,7 @@ pfnGetViewInfo
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
{
if( origin )
VectorCopy( RI.rvp.vieworigin, origin );
VectorCopy( RI.vieworg, origin );
if( forwardv )
VectorCopy( RI.vforward, forwardv );
if( rightv )
@@ -1352,7 +1352,7 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
if( !plight || !ent || !ent->model )
return;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
if( !RI.drawWorld || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
{
plight->shadelight = 0;
plight->ambientlight = 192;
@@ -2333,7 +2333,7 @@ static model_t *R_StudioSetupPlayerModel( int index )
state = &g_studio.player_models[index];
// g-cont: force for "dev-mode", non-local games and menu preview
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD )) && info->model[0] )
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !RI.drawWorld ) && info->model[0] )
{
if( Q_strcmp( state->name, info->model ))
{
@@ -2572,7 +2572,7 @@ R_StudioSetChromeOrigin
*/
static void R_StudioSetChromeOrigin( void )
{
VectorCopy( RI.rvp.vieworigin, g_studio.chrome_origin );
VectorCopy( RI.vieworg, g_studio.chrome_origin );
}
/*
@@ -2926,7 +2926,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( flags & STUDIO_RENDER )
{
// change body if it's a menu entity
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD )))
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !RI.drawWorld ))
{
// show highest resolution multiplayer model
RI.currententity->curstate.body = 255;
@@ -3087,7 +3087,7 @@ R_StudioDrawModelInternal
*/
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
{
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
if( !RI.drawWorld )
{
if( e->player )
R_StudioDrawPlayer( flags, &e->curstate );
@@ -3124,6 +3124,9 @@ R_DrawStudioModel
*/
void R_DrawStudioModel( cl_entity_t *e )
{
if( FBitSet( RI.params, RP_ENVVIEW ))
return;
R_StudioSetupTimings();
if( e->player )
@@ -3177,7 +3180,7 @@ void R_RunViewmodelEvents( void )
return;
// ignore in thirdperson, camera view or client is died
if( ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
RI.currententity = tr.viewent;
@@ -3227,7 +3230,7 @@ void R_DrawViewModel( void )
return;
// ignore in thirdperson, camera view or client is died
if( ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
tr.blend = CL_FxBlend( view ) / 255.0f;

View File

@@ -78,9 +78,9 @@ void R_SetUpWorldTransform( void )
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
}
aliasworldtransform[0][3] = -RI.rvp.vieworigin[0];
aliasworldtransform[1][3] = -RI.rvp.vieworigin[1];
aliasworldtransform[2][3] = -RI.rvp.vieworigin[2];
aliasworldtransform[0][3] = -RI.vieworg[0];
aliasworldtransform[1][3] = -RI.vieworg[1];
aliasworldtransform[2][3] = -RI.vieworg[2];
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];