ref: gl: replace RI.{vieworg,viewangles,pvsorigin} by ref_viewpass_t fields

This commit is contained in:
Alibek Omarov
2026-04-13 13:38:11 +05:00
parent 5955d31997
commit 68875267de
9 changed files with 33 additions and 40 deletions

View File

@@ -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.vieworg;
if( !vieworg ) vieworg = RI.rvp.vieworigin;
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.vieworg, vDirToBeam );
VectorSubtract( vStartPos, RI.rvp.vieworigin, 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.vieworg, pbeam->source, localDir );
VectorSubtract( RI.rvp.vieworigin, pbeam->source, localDir );
flDot = DotProduct( delta, localDir );
VectorScale( delta, flDot, vecProjection );
VectorSubtract( localDir, vecProjection, tmp );

View File

@@ -141,9 +141,6 @@ typedef struct
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.vieworg, org, vecLen );
VectorSubtract( RI.rvp.vieworigin, 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.vieworg, org, vecLen );
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
dist2 = DotProduct( vecLen, vecLen );
}
else dist2 = 1000000000;
@@ -353,11 +353,11 @@ R_SetupFrustum
void R_SetupFrustum( void )
{
// build the transformation matrix for the given view angles
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
AngleVectors( RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup );
if( !r_lockfrustum.value )
{
VectorCopy( RI.vieworg, RI.cullorigin );
VectorCopy( RI.rvp.vieworigin, RI.cullorigin );
VectorCopy( RI.vforward, RI.cull_vforward );
VectorCopy( RI.vright, RI.cull_vright );
VectorCopy( RI.vup, RI.cull_vup );
@@ -421,17 +421,17 @@ static void R_SetupModelviewMatrix( matrix4x4 m )
Matrix4x4_CreateModelview( m );
if( tr.rotation & 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 );
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 );
}
else
{
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_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.vieworg[0], -RI.vieworg[1], -RI.vieworg[2] );
Matrix4x4_ConcatTranslate( m, -RI.rvp.vieworigin[0], -RI.rvp.vieworigin[1], -RI.rvp.vieworigin[2] );
}
/*
@@ -511,7 +511,7 @@ R_FindViewLeaf
void R_FindViewLeaf( void )
{
RI.oldviewleaf = RI.viewleaf;
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes );
}
/*
@@ -522,7 +522,7 @@ R_SetupFrame
static void R_SetupFrame( void )
{
// setup viewplane dist
RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward );
RI.viewplanedist = DotProduct( RI.rvp.vieworigin, RI.vforward );
// NOTE: this request is the fps-killer on some NVidia drivers
glState.isFogEnabled = pglIsEnabled( GL_FOG );
@@ -720,7 +720,7 @@ static void R_CheckFog( void )
return;
}
ent = gEngfuncs.CL_GetWaterEntity( RI.vieworg );
ent = gEngfuncs.CL_GetWaterEntity( RI.rvp.vieworigin );
if( ent && ent->model && ent->model->type == mod_brush && ent->curstate.skin < 0 )
cnt = ent->curstate.skin;
else cnt = RI.viewleaf->contents;
@@ -1096,10 +1096,6 @@ void R_SetupRefParams( const ref_viewpass_t *rvp )
SetBits( RI.params, RP_ENVVIEW );
RI.drawOrtho = false;
}
VectorCopy( rvp->vieworigin, RI.vieworg );
VectorCopy( rvp->viewangles, RI.viewangles );
VectorCopy( rvp->vieworigin, RI.pvsorigin );
}
/*
@@ -1278,7 +1274,7 @@ int CL_FxBlend( cl_entity_t *e )
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, RI.vieworg, tmp );
VectorSubtract( tmp, RI.rvp.vieworigin, 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.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];
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];
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.vieworg[2] )
if( warp->polys->verts[0][2] >= RI.rvp.vieworigin[2] )
waveHeight = -RI.currententity->curstate.scale;
else waveHeight = RI.currententity->curstate.scale;
@@ -3758,15 +3758,15 @@ void R_MarkLeaves( void )
RI.viewleaf = NULL;
}
VectorCopy( RI.pvsorigin, test );
VectorCopy( RI.rvp.vieworigin, test );
if( RI.viewleaf != NULL )
{
// merge two leafs that can be a crossed-line contents
if( RI.viewleaf->contents == CONTENTS_EMPTY )
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
VectorSet( test, RI.rvp.vieworigin[0], RI.rvp.vieworigin[1], RI.rvp.vieworigin[2] - 16.0f );
else
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
VectorSet( test, RI.rvp.vieworigin[0], RI.rvp.vieworigin[1], RI.rvp.vieworigin[2] + 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
@@ -3787,7 +3787,7 @@ void R_MarkLeaves( void )
if( r_novis.value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
gEngfuncs.R_FatPVS( RI.pvsorigin, r_pvs_radius->value, RI.visbytes, false, novis );
gEngfuncs.R_FatPVS( RI.rvp.vieworigin, r_pvs_radius->value, RI.visbytes, false, 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.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
int angleframe = (int)(Q_rint(( RI.rvp.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.vieworg, glowDist );
VectorSubtract( origin, RI.rvp.vieworigin, glowDist );
dist = VectorLength( glowDist );
if( RP_NORMALPASS( ))
{
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
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;
@@ -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.vieworg[1], -(origin[0] - RI.vieworg[0]), 0.0f );
VectorSet( v_right, origin[1] - RI.rvp.vieworigin[1], -(origin[0] - RI.rvp.vieworigin[0]), 0.0f );
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
VectorNormalize( v_right );
break;

View File

@@ -432,7 +432,7 @@ pfnGetViewInfo
*/
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
{
if( origin ) VectorCopy( RI.vieworg, origin );
if( origin ) VectorCopy( RI.rvp.vieworigin, origin );
if( forwardv ) VectorCopy( RI.vforward, forwardv );
if( rightv ) VectorCopy( RI.vright, rightv );
if( upv ) VectorCopy( RI.vup, upv );
@@ -2914,7 +2914,7 @@ R_StudioSetChromeOrigin
*/
static void R_StudioSetChromeOrigin( void )
{
VectorCopy( RI.vieworg, g_studio.chrome_origin );
VectorCopy( RI.rvp.vieworigin, g_studio.chrome_origin );
}
/*

View File

@@ -421,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.vieworg, dir );
VectorSubtract( v, RI.rvp.vieworigin, dir );
dir[2] *= 3.0f; // flatten the sphere
length = VectorLength( dir );