Fix rendering of ingame GUIs with r_lockSurfaces 1

This commit is contained in:
Daniel Gibson 2021-06-12 07:00:57 +02:00
parent dcb933efb5
commit d17fa6b2b6
3 changed files with 16 additions and 16 deletions

View file

@ -209,8 +209,14 @@ EmitToCurrentView
void idGuiModel::EmitToCurrentView( float modelMatrix[16], bool depthHack ) {
float modelViewMatrix[16];
myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.modelViewMatrix,
modelViewMatrix );
const float* worldMVM = tr.viewDef->worldSpace.modelViewMatrix;
// DG: for r_lockSurfaces use the real world modelViewMatrix
// so GUIs don't float around
if(r_lockSurfaces.GetBool() && tr.viewDef == tr.primaryView) {
worldMVM = tr.lockSurfacesRealViewDef.worldSpace.modelViewMatrix;
}
myGlMultMatrix( modelMatrix, worldMVM, modelViewMatrix );
for ( int i = 0 ; i < surfaces.Num() ; i++ ) {
EmitSurface( &surfaces[i], modelMatrix, modelViewMatrix, depthHack );

View file

@ -758,6 +758,8 @@ void idRenderWorldLocal::RenderScene( const renderView_t *renderView ) {
if ( r_lockSurfaces.GetBool() ) {
tr.lockSurfacesRealViewDef = *parms;
// call this here already so idGuiModel::EmitToCurrentView() can use it
R_SetViewMatrix(&tr.lockSurfacesRealViewDef);
/*
viewDef_t* lockedParms = &tr.lockSurfacesViewDef;
parms->renderView = lockedParms->renderView;

View file

@ -861,12 +861,10 @@ void RB_DrawView( const void *data ) {
// now it must be reverted to the real render view so the scene gets rendered
// from the actual current players point of view
if(r_lockSurfaces.GetBool() && tr.primaryView == cmd->viewDef) {
//viewDef = &tr.lockSurfacesRealViewDef;
//const viewDef_t origParms = *backEnd.viewDef;
viewDef_t* parms = cmd->viewDef;
const viewDef_t origParms = *parms;
*parms = tr.lockSurfacesRealViewDef; // actual current player/camera position - XXX: really? what about projection matrix?
*parms = tr.lockSurfacesRealViewDef; // actual current player/camera position
parms->renderWorld = origParms.renderWorld;
parms->floatTime = origParms.floatTime;
parms->drawSurfs = origParms.drawSurfs;
@ -876,22 +874,16 @@ void RB_DrawView( const void *data ) {
parms->viewEntitys = origParms.viewEntitys;
parms->connectedAreas = origParms.connectedAreas;
// TODO: is this really the proper one? maybe should've been set before when origParms.projectionMatrix was set?
//memcpy(parms->projectionMatrix, origParms.projectionMatrix, sizeof(origParms.projectionMatrix));
//memcpy(parms->worldSpace.modelViewMatrix, origParms.worldSpace.modelViewMatrix, sizeof(origParms.worldSpace.modelViewMatrix));
R_SetupProjection(parms);
// TODO: R_SetupViewFrustum() ?
R_SetViewMatrix(parms);
// projection etc are usually set in R_RenderView(), hasn't happened for the "real" viewdef yet
// R_SetViewMatrix(parms); - already done in idRenderWorldLocal::RenderScene() so idGuiModel::EmitToCurrentView() can use it
// R_SetupViewFrustum( parms ); TODO unsure if necessary
R_SetupProjection( parms );
// implicit parms->worldSpace = origParms.worldSpace;
// update the view origin and axis, and all the entity matricies
for( viewEntity_t* vModel = tr.lockSurfacesCmd.viewDef->viewEntitys ; vModel ; vModel = vModel->next ) {
for( viewEntity_t* vModel = parms->viewEntitys ; vModel ; vModel = vModel->next ) {
myGlMultMatrix( vModel->modelMatrix,
parms->worldSpace.modelViewMatrix,
vModel->modelViewMatrix );
}
}
backEnd.viewDef = cmd->viewDef;