Fix adjustment to weapon scopes for asymmetric fov HMDs

This commit is contained in:
Simon 2023-07-31 22:57:24 +01:00
parent c01babfc1d
commit afaf887a47
5 changed files with 12 additions and 8 deletions

View file

@ -38,7 +38,8 @@ typedef struct {
bool third_person;
float fov_x;
float fov_y;
float off_center_fov;
float off_center_fov_x;
float off_center_fov_y;
float tempWeaponVelocity;

View file

@ -1875,8 +1875,8 @@ void TBXR_prepareEyeBuffer(int eye )
//Seems odd, but used to move the HUD elements to be central on the player's view
//HMDs with a symmetric fov (like the PICO) will have 0 in this value, but the Meta Quest
//will have an asymmetric fov and the HUD would be very misaligned as a result
vr.off_center_fov = -(gAppState.Views[eye].fov.angleLeft + gAppState.Views[eye].fov.angleRight) / 2.0f;
}
vr.off_center_fov_x = -(gAppState.Views[eye].fov.angleLeft + gAppState.Views[eye].fov.angleRight) / 2.0f;
vr.off_center_fov_y = -(gAppState.Views[eye].fov.angleUp + gAppState.Views[eye].fov.angleDown) / 2.0f;}
void TBXR_finishEyeBuffer(int eye )
{

View file

@ -1099,7 +1099,8 @@ void TBXR_prepareEyeBuffer(int eye )
//Seems odd, but used to move the HUD elements to be central on the player's view
//HMDs with a symmetric fov (like the PICO) will have 0 in this value, but the Meta Quest
//will have an asymmetric fov and the HUD would be very misaligned as a result
vr.off_center_fov = -(gAppState.Views[eye].fov.angleLeft + gAppState.Views[eye].fov.angleRight) / 2.0f;
vr.off_center_fov_x = -(gAppState.Views[eye].fov.angleLeft + gAppState.Views[eye].fov.angleRight) / 2.0f;
vr.off_center_fov_y = -(gAppState.Views[eye].fov.angleUp + gAppState.Views[eye].fov.angleDown) / 2.0f;
}
void WIN_SwapWindow();

View file

@ -39,7 +39,8 @@ void CG_AdjustFrom640(float* x, float* y, float* w, float* h) {
}
//We need to add an offset due to the effect of the compositor projection for asymmetric FOVs
xoffset += vr->off_center_fov * 640;
xoffset += vr->off_center_fov_x * 640;
float yoffset = vr->off_center_fov_y * 480;
*x *= screenXScale;
*y *= screenYScale;
@ -51,7 +52,7 @@ void CG_AdjustFrom640(float* x, float* y, float* w, float* h) {
}
*x += (640 - (640 * screenXScale)) / 2.0f + xoffset;
*y += (480 - (480 * screenYScale)) / 2.0f - ((cg.drawingHUD != CG_HUD_ZOOM) ? cg_hudYOffset.value : 0);
*y += (480 - (480 * screenYScale)) / 2.0f - ((cg.drawingHUD != CG_HUD_ZOOM) ? cg_hudYOffset.value : 0) - yoffset;
}
}

View file

@ -38,7 +38,8 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
}
//We need to add an offset due to the effect of the compositor projection for asymmetric FOVs
xoffset += vr->off_center_fov * 640;
xoffset += vr->off_center_fov_x * 640;
float yoffset = vr->off_center_fov_y * 480;
*x *= screenXScale;
*y *= screenYScale;
@ -50,7 +51,7 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
}
*x += (640 - (640 * screenXScale)) / 2.0f + xoffset;
*y += (480 - (480 * screenYScale)) / 2.0f - ((cg.drawingHUD != CG_HUD_ZOOM) ? cg_hudYOffset.value : 0);
*y += (480 - (480 * screenYScale)) / 2.0f - ((cg.drawingHUD != CG_HUD_ZOOM) ? cg_hudYOffset.value : 0) - yoffset;
}
}