Change to culling logic to fix issue with inverted weapons/hands

This commit is contained in:
Simon 2023-11-30 23:33:11 +00:00
parent ffecbc8be4
commit f66fe62907
3 changed files with 11 additions and 32 deletions

View file

@ -127,7 +127,7 @@ void GL_SelectTexture( int unit )
** GL_Cull
*/
void GL_Cull( int cullType ) {
if ( glState.faceCulling == cullType ) {
if ( glState.faceCulling == cullType && !backEnd.overrideCullFace) {
return;
}
glState.faceCulling = cullType;
@ -135,9 +135,10 @@ void GL_Cull( int cullType ) {
return;
}
if ( cullType == CT_TWO_SIDED )
if ( cullType == CT_TWO_SIDED || backEnd.overrideCullFace)
{
qglDisable( GL_CULL_FACE );
glState.faceCulling = CT_TWO_SIDED;
}
else
{
@ -648,7 +649,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
int entityNum, oldEntityNum;
int dlighted, oldDlighted;
int depthRange, oldDepthRange;
int isVRViewModel, oldIsVRViewModel;
int i;
drawSurf_t *drawSurf;
unsigned int oldSort;
@ -674,14 +674,11 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldShader = NULL;
oldFogNum = -1;
oldDepthRange = qfalse;
isVRViewModel = qfalse;
oldIsVRViewModel = qfalse;
oldDlighted = qfalse;
oldSort = (unsigned int) -1;
depthRange = qfalse;
GLint oldFaceCullMode;
GLboolean oldFaceCullEnabled;
backEnd.overrideCullFace = qfalse;
backEnd.pc.c_surfaces += numDrawSurfs;
@ -758,6 +755,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
}
}
if (backEnd.currentEntity->e.renderfx & RF_VRVIEWMODEL) {
backEnd.overrideCullFace = qtrue;
}
if (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted
|| ( entityNum != oldEntityNum && !shader->entityMergable ) )
{
@ -774,6 +775,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldShader = shader;
oldFogNum = fogNum;
oldDlighted = dlighted;
backEnd.overrideCullFace = qfalse;
}
//
@ -781,7 +783,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
//
if ( entityNum != oldEntityNum ) {
depthRange = qfalse;
isVRViewModel = qfalse;
if ( entityNum != REFENTITYNUM_WORLD ) {
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
@ -803,10 +804,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
// hack the depth range to prevent view model from poking into walls
depthRange = qtrue;
}
if (backEnd.currentEntity->e.renderfx & RF_VRVIEWMODEL) {
isVRViewModel = qtrue;
}
} else {
backEnd.currentEntity = &tr.worldEntity;
backEnd.refdef.floatTime = originalTime;
@ -838,25 +835,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldDepthRange = depthRange;
}
if (isVRViewModel != oldIsVRViewModel) {
if (isVRViewModel) {
qglGetBooleanv(GL_CULL_FACE, &oldFaceCullEnabled);
qglGetIntegerv(GL_CULL_FACE_MODE, &oldFaceCullMode);
//Draw all faces on weapons
qglDisable(GL_CULL_FACE);
} else{
if (!oldFaceCullEnabled)
{
qglDisable(GL_CULL_FACE);
} else{
qglEnable(GL_CULL_FACE);
}
qglCullFace( oldFaceCullMode );
}
oldIsVRViewModel = isVRViewModel;
}
oldEntityNum = entityNum;
}

View file

@ -936,6 +936,7 @@ typedef struct {
orientationr_t ori;
backEndCounters_t pc;
qboolean isHyperspace;
qboolean overrideCullFace; //If true then forcibly set face drawing to both sides - used for VR weapon/hand models
trRefEntity_t *currentEntity;
qboolean skyRenderedThisView; // flag for drawing sun

View file

@ -2069,7 +2069,7 @@ void RB_StageIteratorGeneric( void )
//
// set face culling appropriately
//
GL_Cull( input->shader->cullType );
GL_Cull(input->shader->cullType);
// set polygon offset if necessary
if ( input->shader->polygonOffset )