diff --git a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 40247b7f4..b4381e547 100644 --- a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -47,6 +47,7 @@ extern vec3_t hmdPosition; extern vec3_t hmdOrigin; extern vec3_t hmdorientation; extern vec3_t weaponangles; +extern vec3_t rawcontrollerangles; // angles unadjusted by weapon adjustment cvars float RazeXR_GetFOV(); void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up, @@ -76,7 +77,7 @@ CVAR(Bool, vr_move_use_offhand, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, vr_teleport, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, vr_weaponScale, 1.02f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, vr_weaponPitchAdjust, 20.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Float, vr_weaponYawAdjust, 5.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, vr_weaponYawAdjust, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, vr_snapTurn, 45.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, vr_move_speed, 19, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Float, vr_run_multiplier, 1.5, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -241,10 +242,10 @@ void VRMode::AdjustViewport(DFrameBuffer *screen) const screen->mScreenViewport.left = (int)(screen->mScreenViewport.left * mHorizontalViewportScale); } -extern float gameYaw; +extern float vrYaw; float getViewpointYaw() { - return gameYaw; + return vrYaw; } VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const @@ -351,14 +352,14 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const // Right-handed new_projection.rotate(weaponangles[YAW] - hmdorientation[YAW], 0, 1, 0); new_projection.rotate(weaponangles[PITCH], 1, 0, 0); - new_projection.rotate(weaponangles[ROLL], 0, 0, 1); + new_projection.rotate(rawcontrollerangles[ROLL], 0, 0, 1); } else { // Left-handed new_projection.rotate(180.0f + weaponangles[YAW] - hmdorientation[YAW], 0, 1, 0); new_projection.rotate(-weaponangles[PITCH], 1, 0, 0); - new_projection.rotate(-weaponangles[ROLL], 0, 0, 1); + new_projection.rotate(-rawcontrollerangles[ROLL], 0, 0, 1); } float weapon_scale = 0.6f; diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 69a9043cc..c4fbcb5e4 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -108,7 +108,6 @@ void resetTurnHeldAmt() void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up, float *yaw, float *pitch, float *roll); -extern int resyncVRYawWithGame; //--------------------------------------------------------------------------- // @@ -357,12 +356,6 @@ void PlayerAngles::doViewPitch(const bool canslopetilt, const bool climbing) void PlayerAngles::doViewYaw(InputPacket* const input) { - if (ViewAngles.Yaw.Degrees() != 0.0f || - ViewAngles.Roll.Degrees() != 0.0f) - { - resyncVRYawWithGame = 1; - } - // Process angle return to zeros. scaletozero(ViewAngles.Yaw, YAW_LOOKRETURN); scaletozero(ViewAngles.Roll, YAW_LOOKRETURN); diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index 3dfa64861..6028bcef4 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -56,8 +56,7 @@ EXTERN_CVAR(Bool, cl_capfps) -extern int resyncVRYawWithGame; -extern float gameYaw; +extern float vrYaw; PalEntry GlobalMapFog; float GlobalFogDensity = 350.f; @@ -236,17 +235,24 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s if (gamestate == GS_LEVEL) { - gameYaw -= hmdYawDeltaDegrees; - } + // Special frame-yaw-resync code + // Basically, if the game code changes the player's yaw, then we need to gradually resync + // our "vrYaw" back to match it, doing the full amount on a frame causes it to glitch + // but smoothly transitioning to it means the user doesn't notice and we should never be out + // of sync with the game's yaw for very long + { + float diff = (float) (-90.f + angles.Yaw.Degrees()) - vrYaw; + if (diff < -360.f) + diff += 360.f; + if (diff > 360.f) + diff -= 360.f; + vrYaw += (diff / 2.0f); + } - if (gamestate == GS_LEVEL && resyncVRYawWithGame) - { - if (resyncVRYawWithGame > 0) - gameYaw = (float) (-90.f + angles.Yaw.Degrees()); - - resyncVRYawWithGame--; + //And now apply the delta of hmd movement for this frame + vrYaw -= hmdYawDeltaDegrees; } - } + } FRenderViewpoint r_viewpoint{}; r_viewpoint.CameraActor = cam; @@ -259,7 +265,7 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s } else { - r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(gameYaw); + r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(vrYaw); } r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(pitch); r_viewpoint.HWAngles.Roll = FAngle::fromDeg(roll); diff --git a/source/core/version.h b/source/core/version.h index b750daa43..090f13e98 100644 --- a/source/core/version.h +++ b/source/core/version.h @@ -44,7 +44,7 @@ const char *GetVersionString(); #define VERSIONSTR "1.7pre" -#define RAZEXR_VERSIONSTR "RazeXR 0.2.4" +#define RAZEXR_VERSIONSTR "RazeXR 0.2.5" // The version as seen in the Windows resource #define RC_FILEVERSION 1,6,9999,0 diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 0ca5e20aa..3ffcfbf41 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -39,8 +39,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "misc.h" #include "weapon.h" -extern int resyncVRYawWithGame; - BEGIN_SW_NS DVector2 DoTrack(SECTOR_OBJECT* sop, short locktics); @@ -1519,12 +1517,6 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, const DVector2& move) // Last known angle is now adjusted by the delta angle pp->RevolveAng = deltaangle(pp->RevolveDeltaAng, pp->actor->spr.Angles.Yaw); - - //A VR thing.. - if (pp->RevolveAng.Degrees() != 0.0) - { - resyncVRYawWithGame = 1; - } } // increment Players delta angle diff --git a/wadsrc/static/engine/commonbinds.txt b/wadsrc/static/engine/commonbinds.txt index 25a30ff11..d6e89049b 100644 --- a/wadsrc/static/engine/commonbinds.txt +++ b/wadsrc/static/engine/commonbinds.txt @@ -81,8 +81,6 @@ pad_a +open pad_y +jump rtrigger +attack ltrigger +altattack -lshoulder weapprev -rshoulder weapnext dpadleft invprev dpadright invnext dpaddown invuse