From 299ceb4e2f3e627de3af466b82f3198a29bef953 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 13 Oct 2020 22:58:43 +0100 Subject: [PATCH] Fix warpy look on Quest 2 --- Projects/Android/AndroidManifest.xml | 4 ++-- Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c | 13 ++++++++++++- .../jni/gzdoom-g3.3mgw_mobile/src/d_main.cpp | 4 +++- .../src/gl/scene/gl_scene.cpp | 4 ++-- .../jni/gzdoom-g3.3mgw_mobile/src/p_mobj.cpp | 5 +++-- .../jni/gzdoom-g3.3mgw_mobile/src/p_user.cpp | 7 ------- .../src/polyrenderer/poly_renderer.cpp | 2 +- .../src/polyrenderer/scene/poly_cull.cpp | 2 +- .../jni/gzdoom-g3.3mgw_mobile/src/r_sky.cpp | 4 ++-- .../jni/gzdoom-g3.3mgw_mobile/src/r_utility.cpp | 16 +++++++++++++--- .../jni/gzdoom-g3.3mgw_mobile/src/r_utility.h | 5 +++-- .../src/swrenderer/r_swrenderer.cpp | 2 +- .../src/swrenderer/things/r_model.cpp | 2 +- .../src/swrenderer/viewport/r_viewport.cpp | 2 +- .../jni/gzdoom-g3.3mgw_mobile/src/version.h | 2 +- 15 files changed, 46 insertions(+), 28 deletions(-) diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index ecb979f..9d44b3b 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="21" + android:versionName="1.1.3" android:installLocation="auto" > diff --git a/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c b/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c index 1544d6e..f930bc5 100644 --- a/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c +++ b/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c @@ -698,13 +698,14 @@ void ovrRenderer_Clear( ovrRenderer * renderer ) renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX; } +float QzDoom_GetFOV(); void ovrRenderer_Create( int width, int height, ovrRenderer * renderer, const ovrJava * java ) { renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX; //Now using a symmetrical render target, based on the horizontal FOV - vrFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X); + QzDoom_GetFOV(); // Create the render Textures. for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ ) @@ -1306,6 +1307,16 @@ static ovrApp gAppState; static ovrJava java; static bool destroyed = false; + +float QzDoom_GetFOV() +{ + if (vrFOV == 0.0f) { + vrFOV = vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X); + } + + return vrFOV; +} + void QzDoom_prepareEyeBuffer(int eye ) { ovrRenderer *renderer = QzDoom_useScreenLayer() ? &gAppState.Scene.CylinderRenderer : &gAppState.Renderer; diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/d_main.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/d_main.cpp index f2d3842..2ab7fec 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/d_main.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/d_main.cpp @@ -679,6 +679,8 @@ CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // //========================================================================== +extern "C" float QzDoom_GetFOV(); + void D_Display () { bool wipe; @@ -707,7 +709,7 @@ void D_Display () if (viewactive) { - DAngle fov = 104.f; + DAngle fov = QzDoom_GetFOV(); AActor *cam = players[consoleplayer].camera; if (cam) { diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/scene/gl_scene.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/scene/gl_scene.cpp index 09c5533..880d535 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/scene/gl_scene.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/scene/gl_scene.cpp @@ -995,7 +995,7 @@ void FGLRenderer::RenderView (player_t* player) mLightCount = !!level.lights; mShadowMap.Update(); - sector_t * viewsector = drawer.RenderViewpoint(player->camera, NULL, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, true, true); + sector_t * viewsector = drawer.RenderViewpoint(player->camera, NULL, r_viewpoint.FieldOfView().Degrees, ratio, fovratio, true, true); All.Unclock(); } @@ -1026,7 +1026,7 @@ void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width, GLRenderer->mLightCount = !!level.lights; sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, - r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false); + r_viewpoint.FieldOfView().Degrees, 1.6f, 1.6f, true, false); glDisable(GL_STENCIL_TEST); gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_mobj.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_mobj.cpp index aef787c..862d48e 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_mobj.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_mobj.cpp @@ -4926,7 +4926,8 @@ DEFINE_ACTION_FUNCTION(AActor, AdjustFloorClip) // EXTERN_CVAR (Bool, chasedemo) EXTERN_CVAR(Bool, sv_singleplayerrespawn) -EXTERN_CVAR(Float, fov) + +extern "C" float QzDoom_GetFOV(); extern bool demonew; @@ -5068,7 +5069,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) mobj->sprite = Skins[p->userinfo.GetSkin()].sprite; } - p->DesiredFOV = p->FOV = fov; + p->DesiredFOV = p->FOV = QzDoom_GetFOV(); p->camera = p->mo; p->playerstate = PST_LIVE; p->refire = 0; diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_user.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_user.cpp index 36ca452..493d5d9 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_user.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_user.cpp @@ -125,13 +125,6 @@ CUSTOM_CVAR(Float, cl_predict_lerpthreshold, 2.00f, CVAR_ARCHIVE | CVAR_GLOBALCO ColorSetList ColorSets; PainFlashList PainFlashes; -// [Nash] FOV cvar setting -CUSTOM_CVAR(Float, fov, 104.f, CVAR_ARCHIVE | CVAR_USERINFO | CVAR_NOINITCALL) -{ - player_t *p = &players[consoleplayer]; - p->SetFOV(fov); -} - struct PredictPos { int gametic; diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/poly_renderer.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/poly_renderer.cpp index b0450ad..c518efc 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/poly_renderer.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/poly_renderer.cpp @@ -236,7 +236,7 @@ PolyPortalViewpoint PolyRenderer::SetupPerspectiveMatrix(bool mirror) float ratio = Viewwindow.WidescreenRatio; float fovratio = (Viewwindow.WidescreenRatio >= 1.3f) ? 1.333333f : ratio; - float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(Viewpoint.FieldOfView.Radians() / 2) / fovratio)).Degrees); + float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(Viewpoint.FieldOfView().Radians() / 2) / fovratio)).Degrees); PolyPortalViewpoint portalViewpoint; diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/scene/poly_cull.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/scene/poly_cull.cpp index 6668e2f..08e11e5 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/scene/poly_cull.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/polyrenderer/scene/poly_cull.cpp @@ -365,7 +365,7 @@ void PolyCull::MarkViewFrustum() if (tilt > 46.0) // If the pitch is larger than this you can look all around return; - double floatangle = 2.0 + (45.0 + ((tilt / 1.9)))*viewpoint.FieldOfView.Degrees*48.0 / AspectMultiplier(viewwindow.WidescreenRatio) / 90.0; + double floatangle = 2.0 + (45.0 + ((tilt / 1.9)))*viewpoint.FieldOfView().Degrees*48.0 / AspectMultiplier(viewwindow.WidescreenRatio) / 90.0; angle_t a1 = DAngle(floatangle).BAMs(); if (a1 < ANGLE_180) { diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_sky.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_sky.cpp index c412955..5dbd8b8 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_sky.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_sky.cpp @@ -140,8 +140,8 @@ void R_InitSkyMap () skyiscale = float(r_Yaspect / freelookviewheight); skyscale = freelookviewheight / r_Yaspect; - skyiscale *= float(r_viewpoint.FieldOfView.Degrees / 90.); - skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees); + skyiscale *= float(r_viewpoint.FieldOfView().Degrees / 90.); + skyscale *= float(90. / r_viewpoint.FieldOfView().Degrees); } if (skystretch) diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.cpp index 5802eb5..b33619f 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.cpp @@ -111,6 +111,8 @@ int viewwindowy; int viewwidth; int viewheight; +extern "C" float QzDoom_GetFOV(); + FRenderViewpoint::FRenderViewpoint() { player = nullptr; @@ -125,13 +127,20 @@ FRenderViewpoint::FRenderViewpoint() TanSin = 0.0; camera = nullptr; sector = nullptr; - FieldOfView = 104.; // Angles in the SCREENWIDTH wide window TicFrac = 0.0; FrameTime = 0; extralight = 0; showviewer = false; } +DAngle FRenderViewpoint::FieldOfView() const +{ + //Get for VR + DAngle fov = QzDoom_GetFOV(); + return fov; +} + + FRenderViewpoint r_viewpoint; FViewWindow r_viewwindow; @@ -166,13 +175,14 @@ DEFINE_GLOBAL(LocalViewPitch); void R_SetFOV (FRenderViewpoint &viewpoint, DAngle fov) { - if (fov < 5.) fov = 5.; +/* if (fov < 5.) fov = 5.; else if (fov > 170.) fov = 170.; if (fov != viewpoint.FieldOfView) { viewpoint.FieldOfView = fov; setsizeneeded = true; } + */ } //========================================================================== @@ -242,7 +252,7 @@ void R_SetWindow (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, int wind } - DAngle fov = viewpoint.FieldOfView; + DAngle fov = viewpoint.FieldOfView(); // For widescreen displays, increase the FOV so that the middle part of the // screen that would be visible on a 4:3 display has the requested FOV. diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.h b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.h index 99f27f7..c341916 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.h +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.h @@ -16,7 +16,9 @@ struct FRenderViewpoint { FRenderViewpoint(); - player_t *player; // For which player is this viewpoint being renderered? (can be null for camera textures) + DAngle FieldOfView() const; // current field of view + + player_t *player; // For which player is this viewpoint being renderered? (can be null for camera textures) DVector3 Pos; // Camera position DVector3 CenterEyePos; // Camera position without view shift DVector3 ActorPos; // Camera actor's position @@ -29,7 +31,6 @@ struct FRenderViewpoint AActor *camera; // camera actor sector_t *sector; // [RH] keep track of sector viewing from - DAngle FieldOfView; // current field of view double TicFrac; // fraction of tic for interpolation uint32_t FrameTime; // current frame's time in tics. diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/r_swrenderer.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/r_swrenderer.cpp index 9f842d3..8521553 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/r_swrenderer.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/r_swrenderer.cpp @@ -288,7 +288,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin // These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette. CameraLight savedCameraLight = *CameraLight::Instance(); - DAngle savedfov = cameraViewpoint.FieldOfView; + DAngle savedfov = cameraViewpoint.FieldOfView(); R_SetFOV (cameraViewpoint, fov); if (r_polyrenderer) diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/things/r_model.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/things/r_model.cpp index 68283fa..8bafdc5 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/things/r_model.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/things/r_model.cpp @@ -291,7 +291,7 @@ namespace swrenderer float adjustedViewAngle = (float)(Viewpoint.Angles.Yaw - 90).Radians(); float ratio = Viewwindow.WidescreenRatio; float fovratio = (Viewwindow.WidescreenRatio >= 1.3f) ? 1.333333f : ratio; - float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(Viewpoint.FieldOfView.Radians() / 2) / fovratio)).Degrees); + float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(Viewpoint.FieldOfView().Radians() / 2) / fovratio)).Degrees); Mat4f altWorldToView = Mat4f::Rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * Mat4f::Rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/viewport/r_viewport.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/viewport/r_viewport.cpp index b9b7fe1..556d9e1 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/viewport/r_viewport.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/swrenderer/viewport/r_viewport.cpp @@ -199,7 +199,7 @@ namespace swrenderer FocalLengthY = FocalLengthX * YaspectMul; // This is 1/FocalTangent before the widescreen extension of FOV. - viewingrangerecip = FLOAT2FIXED(1. / tan(viewpoint.FieldOfView.Radians() / 2)); + viewingrangerecip = FLOAT2FIXED(1. / tan(viewpoint.FieldOfView().Radians() / 2)); // Now generate xtoviewangle for sky texture mapping. // [RH] Do not generate viewangletox, because texture mapping is no diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/version.h b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/version.h index 2731807..51bd44e 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/version.h +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/version.h @@ -41,7 +41,7 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "DrBeef's QuestZDoom-1.1.2 (LZDoom 3.85)" +#define VERSIONSTR "DrBeef's QuestZDoom-1.1.3 (LZDoom 3.85)" // The version as seen in the Windows resource #define RC_FILEVERSION 3,85,0