mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-21 19:51:03 +00:00
Allow game to override pitch
This commit is contained in:
parent
727103b565
commit
5c6a0c84eb
3 changed files with 52 additions and 14 deletions
|
@ -78,6 +78,7 @@ 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, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, vr_allowPitchOverride, true, 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)
|
||||
|
|
|
@ -55,8 +55,10 @@
|
|||
#include "gamehud.h"
|
||||
|
||||
EXTERN_CVAR(Bool, cl_capfps)
|
||||
EXTERN_CVAR(Bool, vr_allowPitchOverride);
|
||||
|
||||
extern float vrYaw;
|
||||
extern float vrPitch;
|
||||
|
||||
PalEntry GlobalMapFog;
|
||||
float GlobalFogDensity = 350.f;
|
||||
|
@ -108,6 +110,7 @@ void CollectLights(FLevelLocals* Level)
|
|||
float RazeXR_GetFOV();
|
||||
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
|
||||
float *yaw, float *pitch, float *roll);
|
||||
void RazeXR_setUseScreenLayer(bool use);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -213,6 +216,15 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
|
|||
// Set up the view point.
|
||||
//
|
||||
//===========================================================================
|
||||
void lerpValue(float gameVal, float &vrVal)
|
||||
{
|
||||
float diff = gameVal - vrVal;
|
||||
if (diff < -360.f)
|
||||
diff += 360.f;
|
||||
if (diff > 360.f)
|
||||
diff -= 360.f;
|
||||
vrVal += (diff / 2.0f);
|
||||
}
|
||||
|
||||
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, const DRotator& angles, float fov = -1)
|
||||
{
|
||||
|
@ -220,10 +232,10 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s
|
|||
VR_GetMove(&dummy, &dummy, &dummy, &dummy, &dummy, &yaw, &pitch, &roll);
|
||||
|
||||
//Special handling for Duke's security cameras
|
||||
bool renderingSecurityCamera = isDuke() && (cam && cam->spr.cstat & CSTAT_SPRITE_INVISIBLE);
|
||||
bool renderingRemoteCamera = isDuke() && (cam && cam->spr.cstat & CSTAT_SPRITE_INVISIBLE);
|
||||
|
||||
//Only do the following if not rendering a camera tex
|
||||
if (!renderingSecurityCamera)
|
||||
if (!renderingRemoteCamera)
|
||||
{
|
||||
//Yaw
|
||||
float hmdYawDeltaDegrees;
|
||||
|
@ -233,6 +245,14 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s
|
|||
previousHmdYaw = yaw;
|
||||
}
|
||||
|
||||
//Pitch
|
||||
float hmdPitchDeltaDegrees;
|
||||
{
|
||||
static float previousHmdPitch = pitch;
|
||||
hmdPitchDeltaDegrees = pitch - previousHmdPitch;
|
||||
previousHmdPitch = pitch;
|
||||
}
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
// Special frame-yaw-resync code
|
||||
|
@ -240,17 +260,22 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s
|
|||
// 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);
|
||||
}
|
||||
lerpValue((float) (-90.f + angles.Yaw.Degrees()), vrYaw);
|
||||
|
||||
//And now apply the delta of hmd movement for this frame
|
||||
// And now apply the delta of hmd movement for this frame
|
||||
vrYaw -= hmdYawDeltaDegrees;
|
||||
|
||||
// And do the same for pitch so the game _can_ override the pitch if
|
||||
// the user allows it
|
||||
if (vr_allowPitchOverride)
|
||||
{
|
||||
lerpValue((float) (angles.Pitch.Degrees()), vrPitch);
|
||||
vrPitch += hmdPitchDeltaDegrees;
|
||||
}
|
||||
else
|
||||
{
|
||||
vrPitch = pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,16 +284,23 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s
|
|||
r_viewpoint.SectNums = nullptr;
|
||||
r_viewpoint.SectCount = sectnum;
|
||||
r_viewpoint.Pos = { position.X, -position.Y, -position.Z };
|
||||
if (renderingSecurityCamera)
|
||||
if (renderingRemoteCamera)
|
||||
{
|
||||
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angles.Yaw.Degrees());
|
||||
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg((float)angles.Pitch.Degrees());
|
||||
r_viewpoint.HWAngles.Roll = FAngle::fromDeg((float)angles.Roll.Degrees());
|
||||
|
||||
if (fov != -1)
|
||||
{
|
||||
RazeXR_setUseScreenLayer(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(vrYaw);
|
||||
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(vrPitch);
|
||||
r_viewpoint.HWAngles.Roll = FAngle::fromDeg(roll);
|
||||
}
|
||||
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(pitch);
|
||||
r_viewpoint.HWAngles.Roll = FAngle::fromDeg(roll);
|
||||
r_viewpoint.FieldOfView = FAngle::fromDeg((float)RazeXR_GetFOV());
|
||||
r_viewpoint.RotAngle = angles.Yaw.BAMs();
|
||||
double FocalTangent = tan(r_viewpoint.FieldOfView.Radians() / 2);
|
||||
|
|
|
@ -557,11 +557,16 @@ OptionMenu "VROptionsMenu" protected
|
|||
Slider "Height Adjust", "vr_height_adjust", 0.0, 1.0, 0.1
|
||||
StaticText ""
|
||||
Option "Positional Tracking", "vr_positional_tracking", "YesNo"
|
||||
Option "Allow Pitch Override*", "vr_allowPitchOverride", "YesNo"
|
||||
Option "6DoF Weapons", "vr_6dof_weapons", "YesNo"
|
||||
Slider "Weapon Pitch Adjust", "vr_weaponPitchAdjust", 0.0, 90.0, 5
|
||||
Slider "Weapon Yaw Adjust", "vr_weaponYawAdjust", -10.0, 10.0, 1
|
||||
Option "VR Crosshair", "vr_6dof_crosshair", "YesNo"
|
||||
|
||||
StaticText ""
|
||||
StaticText "*Allows the game to override the pitch the user is looking at"
|
||||
StaticText "in some scenarios"
|
||||
|
||||
StaticText ""
|
||||
StaticText "HUD"
|
||||
StaticText ""
|
||||
|
|
Loading…
Reference in a new issue