diff --git a/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c b/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c index 1ab90b5..cfcc2d2 100644 --- a/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c +++ b/Projects/Android/jni/QzDoom/QzDoom_SurfaceView.c @@ -93,8 +93,8 @@ PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR; //Let's go to the maximum! int CPU_LEVEL = 4; int GPU_LEVEL = 4; -int NUM_MULTI_SAMPLES = 4; -float SS_MULTIPLIER = 1.25f; +int NUM_MULTI_SAMPLES = 1; +float SS_MULTIPLIER = 1.0f; jclass clazz; diff --git a/Projects/Android/jni/QzDoom/VrCompositor.c b/Projects/Android/jni/QzDoom/VrCompositor.c index 85a8aa1..382eaa5 100644 --- a/Projects/Android/jni/QzDoom/VrCompositor.c +++ b/Projects/Android/jni/QzDoom/VrCompositor.c @@ -556,7 +556,7 @@ ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer, const float density = 4500.0f; const float rotateYaw = 0.0f; const float radius = 4.0f; - const ovrVector3f translation = { 0.0f, playerHeight, -2.5f }; + const ovrVector3f translation = { 0.0f, 0.0f, -2.5f }; ovrMatrix4f cylinderTransform = CylinderModelMatrix( textureWidth, textureHeight, translation, diff --git a/Projects/Android/jni/QzDoom/VrInputDefault.c b/Projects/Android/jni/QzDoom/VrInputDefault.c index 3336176..b199eb7 100644 --- a/Projects/Android/jni/QzDoom/VrInputDefault.c +++ b/Projects/Android/jni/QzDoom/VrInputDefault.c @@ -136,7 +136,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, offhandangles[YAW] += (doomYawDegrees - hmdorientation[YAW]); if (vr_walkdirection == 0) { - controllerYawHeading = -doomYawDegrees + offhandangles[YAW]; + controllerYawHeading = offhandangles[YAW] - hmdorientation[YAW]; } else { @@ -157,7 +157,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, vec2_t v; rotateAboutOrigin(-positionDeltaThisFrame[0] * vr_positional_factor, - positionDeltaThisFrame[2] * vr_positional_factor, - hmdorientation[YAW], v); + positionDeltaThisFrame[2] * vr_positional_factor, hmdorientation[YAW], v); positional_movementSideways = v[0]; positional_movementForward = v[1]; diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/stereo3d/gl_oculusquest.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/stereo3d/gl_oculusquest.cpp index 5444419..50a3ed0 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/stereo3d/gl_oculusquest.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/stereo3d/gl_oculusquest.cpp @@ -68,6 +68,7 @@ EXTERN_CVAR(Float, vr_snapTurn); EXTERN_CVAR(Float, vr_ipd); double P_XYMovement(AActor *mo, DVector2 scroll); +extern "C" void VR_GetMove( float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up, float *yaw, float *pitch, float *roll ); namespace s3d @@ -112,12 +113,31 @@ namespace s3d doomYawDegrees = yaw; outViewShift[0] = outViewShift[1] = outViewShift[2] = 0; + // Pitch and Roll are identical between OpenVR and Doom worlds. + // But yaw can differ, depending on starting state, and controller movement. + float doomYawDegrees = yaw; + float vrYawDegrees = hmdorientation[YAW]; + deltaYawDegrees = doomYawDegrees - vrYawDegrees; + while (deltaYawDegrees > 180) + deltaYawDegrees -= 360; + while (deltaYawDegrees < -180) + deltaYawDegrees += 360; + VSMatrix shiftMat; shiftMat.loadIdentity(); shiftMat.rotate(GLRenderer->mAngles.Roll.Degrees, 0, 0, 1); shiftMat.rotate(GLRenderer->mAngles.Pitch.Degrees, 1, 0, 0); - shiftMat.rotate(GLRenderer->mAngles.Yaw.Degrees, 0, 1, 0); + shiftMat.rotate(deltaYawDegrees, 0, 1, 0); + double pixelstretch = level.info ? level.info->pixelstretch : 1.2; + shiftMat.scale(pixelstretch, pixelstretch, 1.0); + // permute axes + float permute[] = { // Convert from OpenVR to Doom axis convention, including mirror inversion + -1, 0, 0, 0, // X-right in VR -> X-left in Doom + 0, 0, 1, 0, // Z-backward in VR -> Y-backward in Doom + 0, 1, 0, 0, // Y-up in VR -> Z-up in Doom + 0, 0, 0, 1}; + shiftMat.multMatrix(permute); double mult = eye == 0 ? -1.0 : 1.0; @@ -131,7 +151,7 @@ namespace s3d // We want to align those two heights here const player_t & player = players[consoleplayer]; double vh = player.viewheight; // Doom thinks this is where you are - double hh = (hmdPosition[2] - vr_floor_offset) * vr_vunits_per_meter; // HMD is actually here + double hh = (hmdPosition[1] - vr_floor_offset) * vr_vunits_per_meter; // HMD is actually here eyeOffset[2] += hh - vh; outViewShift[0] = eyeOffset[0]; @@ -370,8 +390,6 @@ namespace s3d return int(m); } - extern "C" void VR_GetMove( float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up, float *yaw, float *pitch, float *roll ); - /* virtual */ void OculusQuestMode::SetUp() const { diff --git a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/system/gl_framebuffer.cpp b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/system/gl_framebuffer.cpp index 77a22c7..b5b5a54 100644 --- a/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/system/gl_framebuffer.cpp +++ b/Projects/Android/jni/gzdoom-g3.3mgw_mobile/src/gl/system/gl_framebuffer.cpp @@ -222,10 +222,7 @@ extern int camtexcount; void OpenGLFrameBuffer::Swap() { - //glFinish(); - - - glFlush(); + glFinish(); /* bool swapbefore = gl_finishbeforeswap && camtexcount == 0; Finish.Reset(); diff --git a/assets/commandline.txt b/assets/commandline.txt index f08eaa7..31445bc 100644 --- a/assets/commandline.txt +++ b/assets/commandline.txt @@ -1 +1 @@ -qzdoom --supersampling 1.2 -iwad wads/DOOM.WAD \ No newline at end of file +qzdoom -iwad wads/DOOM.WAD \ No newline at end of file