From 67e1d612148fccf74fd4977c0a3821d71683d9c0 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 31 Jul 2023 22:41:33 +0100 Subject: [PATCH] Fix for the zooming fov cross-eyed issue --- .../OpenJK/JKXR/android/JKXR_SurfaceView.cpp | 20 +++++++++---------- .../OpenJK/JKXR/windows/JKXR_SurfaceView.cpp | 17 +++++----------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Projects/Android/jni/OpenJK/JKXR/android/JKXR_SurfaceView.cpp b/Projects/Android/jni/OpenJK/JKXR/android/JKXR_SurfaceView.cpp index b143adb..d692e89 100644 --- a/Projects/Android/jni/OpenJK/JKXR/android/JKXR_SurfaceView.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/android/JKXR_SurfaceView.cpp @@ -21,11 +21,9 @@ extern "C" { #include -#ifdef JK2_MODE -#include "../OpenJK/codeJK2/game/weapons.h" -#else -#include "../OpenJK/code/game/weapons.h" -#include "../OpenJK/code/game/g_vehicles.h" +#include "game/weapons.h" +#ifndef JK2_MODE +#include "game/g_vehicles.h" #endif @@ -461,14 +459,14 @@ bool VR_GetVRProjection(int eye, float zNear, float zFar, float zZoomX, float zZ } XrFovf fov = gAppState.Views[eye].fov; - fov.angleLeft /= zZoomX; - fov.angleRight /= zZoomX; - fov.angleUp /= zZoomY; - fov.angleDown /= zZoomY; + fov.angleLeft = atanf((tanf(fov.angleLeft) / zZoomX)); + fov.angleRight = atanf((tanf(fov.angleRight) / zZoomX)); + fov.angleUp = atanf((tanf(fov.angleUp) / zZoomY)); + fov.angleDown = atanf((tanf(fov.angleDown) / zZoomY)); XrMatrix4x4f_CreateProjectionFov( - (XrMatrix4x4f*)projection, GRAPHICS_OPENGL, - fov, zNear, zFar); + (XrMatrix4x4f*)projection, GRAPHICS_OPENGL, + fov, zNear, zFar); return true; } diff --git a/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp b/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp index c32cbe3..cb3c687 100644 --- a/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp @@ -280,18 +280,10 @@ void VR_Init() } vr.menu_right_handed = vr_control_scheme->integer == 0; - - Cvar_Get ("openXRHMD", gAppState.OpenXRHMD, CVAR_ARCHIVE); } int VR_SetRefreshRate(int refreshRate) { -// if (strstr(gAppState.OpenXRHMD, "meta") != NULL) -// { -// OXR(gAppState.pfnRequestDisplayRefreshRate(gAppState.Session, (float) refreshRate)); -// return refreshRate; -// } - return 0; } @@ -324,10 +316,11 @@ bool VR_GetVRProjection(int eye, float zNear, float zFar, float zZoomX, float zZ } XrFovf fov = gAppState.Views[eye].fov; - fov.angleLeft /= zZoomX; - fov.angleRight /= zZoomX; - fov.angleUp /= zZoomY; - fov.angleDown /= zZoomY; + + fov.angleLeft = atanf((tanf(fov.angleLeft) / zZoomX)); + fov.angleRight = atanf((tanf(fov.angleRight) / zZoomX)); + fov.angleUp = atanf((tanf(fov.angleUp) / zZoomY)); + fov.angleDown = atanf((tanf(fov.angleDown) / zZoomY)); XrMatrix4x4f_CreateProjectionFov( (XrMatrix4x4f*)projection, GRAPHICS_OPENGL,