From 01b67f3b35fab528b1695af4c73b65e43dbeede4 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 14 Oct 2020 19:14:31 +0100 Subject: [PATCH] Get FOV from VrApi for Quest 1 & 2 support --- .../jni/Doom3Quest/Doom3Quest_SurfaceView.c | 14 ++++++++++++-- .../neo/framework/UsercmdGen.cpp | 2 +- .../d3es-multithread-master/neo/game/Player.cpp | 2 +- .../neo/game/gamesys/SysCvar.cpp | 1 - .../neo/game/gamesys/SysCvar.h | 1 - .../neo/renderer/RenderSystem.h | 1 + .../neo/renderer/RenderSystem_init.cpp | 8 +++++++- .../neo/renderer/tr_local.h | 2 ++ 8 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c b/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c index 49ebb18..ed20a41 100644 --- a/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c +++ b/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c @@ -48,7 +48,7 @@ Copyright : Copyright 2015 Oculus VR, LLC. All Rights reserved. //Define all variables here that were externs in the VrCommon.h bool Doom3Quest_initialised; float playerYaw; -float vrFOV; +float vrFOV = 0.0f; bool vr_moveuseoffhand; float vr_snapturn_angle; bool vr_switchsticks; @@ -783,13 +783,14 @@ void ovrRenderer_Clear( ovrRenderer * renderer ) renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX; } +float Doom3Quest_GetFOV(); void ovrRenderer_Create( int width, int height, ovrRenderer * renderer, const ovrJava * java ) { renderer->NumBuffers = 1; // Multiview //Now using a symmetrical render target, based on the horizontal FOV - vrFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X); + Doom3Quest_GetFOV(); // Create the multi view frame buffer ovrFramebuffer_Create( &renderer->FrameBuffer, @@ -1048,6 +1049,15 @@ static ovrApp gAppState; static ovrJava java; static bool destroyed = false; +float Doom3Quest_GetFOV() +{ + if (vrFOV == 0.0f) { + vrFOV = vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X); + } + + return vrFOV; +} + static void ovrApp_HandleVrModeChanges( ovrApp * app ) { if ( app->Resumed != false && app->NativeWindow != NULL ) diff --git a/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp b/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp index 3c5fd62..5d264e9 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/framework/UsercmdGen.cpp @@ -19,7 +19,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Doom 3 Source Code. If not, see . -In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below. +In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the addres Doom3s below. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp index f19e074..2efa27e 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp @@ -7226,7 +7226,7 @@ Returns the base FOV float idPlayer::DefaultFov( void ) const { float fov; - fov = g_fov.GetFloat(); + fov = renderSystem->GetFOV(); if ( gameLocal.isMultiplayer ) { if ( fov < 90.0f ) { return 90.0f; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.cpp index a612477..90d62c4 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.cpp @@ -280,7 +280,6 @@ idCVar g_gun_y( "g_gunY", "0", CVAR_GAME | CVAR_FLOAT, "" ); idCVar g_gun_z( "g_gunZ", "0", CVAR_GAME | CVAR_FLOAT, "" ); idCVar g_viewNodalX( "g_viewNodalX", "0", CVAR_GAME | CVAR_FLOAT, "" ); idCVar g_viewNodalZ( "g_viewNodalZ", "0", CVAR_GAME | CVAR_FLOAT, "" ); -idCVar g_fov( "g_fov", "104", CVAR_GAME | CVAR_INTEGER | CVAR_NOCHEAT, "" ); idCVar g_skipViewEffects( "g_skipViewEffects", "0", CVAR_GAME | CVAR_BOOL, "skip damage and other view effects" ); idCVar g_mpWeaponAngleScale( "g_mpWeaponAngleScale", "0", CVAR_GAME | CVAR_FLOAT, "Control the weapon sway in MP" ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.h b/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.h index c78874b..35fc6f3 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/gamesys/SysCvar.h @@ -209,7 +209,6 @@ extern idCVar g_gun_y; extern idCVar g_gun_z; extern idCVar g_viewNodalX; extern idCVar g_viewNodalZ; -extern idCVar g_fov; extern idCVar g_testDeath; extern idCVar g_skipViewEffects; extern idCVar g_mpWeaponAngleScale; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h index 12e0cac..c30c82c 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.h @@ -152,6 +152,7 @@ public: virtual bool IsFullScreen( void ) const = 0; virtual int GetScreenWidth( void ) const = 0; virtual int GetScreenHeight( void ) const = 0; + virtual float GetFOV() const = 0; // allocate a renderWorld to be used for drawing virtual idRenderWorld * AllocRenderWorld( void ) = 0; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp index 8cca096..ad8f1d6 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem_init.cpp @@ -1791,4 +1791,10 @@ idRenderSystemLocal::GetScreenHeight */ int idRenderSystemLocal::GetScreenHeight( void ) const { return glConfig.vidHeight; -} \ No newline at end of file +} + +extern "C" Doom3Quest_GetFOV(); +float idRenderSystemLocal::GetFOV() const +{ + return Doom3Quest_GetFOV(); +} diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h index 489f128..f99c7eb 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h @@ -686,6 +686,8 @@ public: virtual bool IsFullScreen( void ) const; virtual int GetScreenWidth( void ) const; virtual int GetScreenHeight( void ) const; + virtual float GetFOV() const; + virtual idRenderWorld * AllocRenderWorld( void ); virtual void FreeRenderWorld( idRenderWorld *rw ); virtual void BeginLevelLoad( void );