mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-24 21:11:24 +00:00
Use improved game yaw resync logic
should never go out of sync with the game yaw again (not for more than a few frames anyway)
This commit is contained in:
parent
95b2303bad
commit
727103b565
6 changed files with 25 additions and 35 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -81,8 +81,6 @@ pad_a +open
|
|||
pad_y +jump
|
||||
rtrigger +attack
|
||||
ltrigger +altattack
|
||||
lshoulder weapprev
|
||||
rshoulder weapnext
|
||||
dpadleft invprev
|
||||
dpadright invnext
|
||||
dpaddown invuse
|
||||
|
|
Loading…
Reference in a new issue