diff --git a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c index 8447f12..695065e 100644 --- a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c +++ b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c @@ -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" ); diff --git a/Projects/Android/jni/src/Lambda1VR/VrCvars.h b/Projects/Android/jni/src/Lambda1VR/VrCvars.h index a71469f..e224ed5 100644 --- a/Projects/Android/jni/src/Lambda1VR/VrCvars.h +++ b/Projects/Android/jni/src/Lambda1VR/VrCvars.h @@ -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; \ No newline at end of file diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_studio.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_studio.c index f5ac28b..016d0e1 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_studio.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_studio.c @@ -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 );