Skip to content

Commit

Permalink
Fix warpy look on Quest 2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrBeef committed Oct 13, 2020
1 parent d015ba9 commit 299ceb4
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Projects/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.questzdoom"
android:versionCode="20"
android:versionName="1.1.2" android:installLocation="auto" >
android:versionCode="21"
android:versionName="1.1.3" android:installLocation="auto" >

<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
Expand Down
13 changes: 12 additions & 1 deletion Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++ )
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
//
//==========================================================================

extern "C" float QzDoom_GetFOV();

void D_Display ()
{
bool wipe;
Expand Down Expand Up @@ -707,7 +709,7 @@ void D_Display ()

if (viewactive)
{
DAngle fov = 104.f;
DAngle fov = QzDoom_GetFOV();
AActor *cam = players[consoleplayer].camera;
if (cam)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_mobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/p_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ int viewwindowy;
int viewwidth;
int viewheight;

extern "C" float QzDoom_GetFOV();

FRenderViewpoint::FRenderViewpoint()
{
player = nullptr;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
*/
}

//==========================================================================
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/r_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 299ceb4

Please sign in to comment.