This commit is contained in:
Grant Bagwell committed 2019-10-01 16:17:24 +02:00
commit 331a936f1d
3 files changed
+17 -8

No files matched your search

@@ -1329,6 +1329,7 @@ void VR_Init()
vr_height_adjust = Cvar_Get( "vr_height_adjust", "0.0", CVAR_ARCHIVE, "Additional height adjustment for in-game player (in metres)" );
vr_flashlight_model = Cvar_Get( "vr_flashlight_model", "1", CVAR_ARCHIVE, "Set to 0 to prevent drawing the flashlight model" );
vr_mirror_weapons = Cvar_Get( "vr_mirror_weapons", "0", CVAR_ARCHIVE, "Set to 1 to mirror the weapon models (for left handed use)" );
vr_weapon_backface_culling = Cvar_Get( "vr_weapon_backface_culling", "0", CVAR_ARCHIVE, "Use to enable whether back face culling is used on weapon viewmodel" );
//Not to be changed by users, as it will be overwritten anyway
vr_stereo_side = Cvar_Get( "vr_stereo_side", "0", CVAR_READ_ONLY, "Eye being drawn" );
@@ -16,6 +16,7 @@ convar_t *vr_enable_crouching;
convar_t *vr_height_adjust;
convar_t *vr_flashlight_model;
convar_t *vr_mirror_weapons;
convar_t *vr_weapon_backface_culling;
//Used and updated continuously during rendering
convar_t *vr_stereo_side;
@@ -3723,6 +3723,8 @@ R_DrawViewModel
*/
extern convar_t *vr_mirror_weapons;
extern convar_t *vr_weapon_backface_culling;
void R_DrawViewModel( void )
{
if( RI.refdef.onlyClientDraw || r_drawviewmodel->integer == 0 )
@@ -3752,8 +3754,9 @@ void R_DrawViewModel( void )
// hack the depth range to prevent view model from poking into walls
pglDepthRange( gldepthmin, gldepthmin + 0.3f * ( gldepthmax - gldepthmin ));
// backface culling for mirrored weapons
g_iBackFaceCull = vr_mirror_weapons->integer == 1;//R_LeftHand(); // GL_FrontFace is called in SetupStudioRenderer
// face culling for mirrored weapons - not base on handedness
g_iBackFaceCull = vr_mirror_weapons->value == 1;
RI.currententity->curstate.scale = 1.0f;
RI.currententity->curstate.frame = 0;
RI.currententity->curstate.framerate = 1.0f;
@@ -3762,14 +3765,18 @@ void R_DrawViewModel( void )
RI.currententity->curstate.animtime = cl.weaponstarttime;
RI.currententity->curstate.sequence = cl.weaponseq;
//If we aren't mirroring weapons, turn off culling for the viewmodel
if (!g_iBackFaceCull)
pglDisable(GL_CULL_FACE);
//Optional culling for the viewmodel
if (vr_weapon_backface_culling->value == 0) {
clgame.ds.cullMode = GL_NONE;
pglDisable(GL_CULL_FACE);
}
pStudioDraw->StudioDrawModel( STUDIO_RENDER | STUDIO_VIEWMODEL );
if (!g_iBackFaceCull)
pglEnable(GL_CULL_FACE);
if (vr_weapon_backface_culling->value == 0) {
clgame.ds.cullMode = GL_FRONT;
pglEnable(GL_CULL_FACE);
}
// restore depth range
pglDepthRange( gldepthmin, gldepthmax );