Skip to content

Commit

Permalink
Add seated mode cvar
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Sep 1, 2023
1 parent ec026df commit 6684347
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
1 change: 1 addition & 0 deletions Sources/CryGame C++/Solution1/CryGame/VRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ void VRManager::RegisterCVars()
console->Register("vr_render_world_while_zoomed", &vr_render_world_while_zoomed, 1, VF_DUMPTODISK, "Keep rendering the world in VR while binoculars or weapon scopes are active - costs performance!");
console->Register("vr_binocular_size", &vr_binocular_size, 0.4f, VF_DUMPTODISK, "Width of the binocular overlay (in meters)");
console->Register("vr_scope_size", &vr_scope_size, 0.3f, VF_DUMPTODISK, "Width of the weapon scope overlay (in meters)");
console->Register("vr_seated_mode", &vr_seated_mode, 0, VF_DUMPTODISK, "If enabled, will fix VR camera at player head height and disable physical crouching");
vr_debug_override_rh_offset = console->CreateVariable("vr_debug_override_rh_offset", "0.0 -0.1 -0.018", VF_CHEAT);
vr_debug_override_lh_offset = console->CreateVariable("vr_debug_override_lh_offset", "0.0 -0.1 -0.018", VF_CHEAT);
vr_debug_override_rh_angles = console->CreateVariable("vr_debug_override_rh_angles", "0.0 0.0 0.0", VF_CHEAT);
Expand Down
1 change: 1 addition & 0 deletions Sources/CryGame C++/Solution1/CryGame/VRManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class VRManager
int vr_render_world_while_zoomed;
float vr_binocular_size;
float vr_scope_size;
int vr_seated_mode;
ICVar* vr_debug_override_rh_offset = nullptr;
ICVar* vr_debug_override_rh_angles = nullptr;
ICVar* vr_debug_override_lh_offset = nullptr;
Expand Down
23 changes: 4 additions & 19 deletions Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2534,32 +2534,17 @@ void CPlayer::ProcessRoomscaleMovement(CXEntityProcessingCmd& ProcessingCmd)

Vec3 CPlayer::GetVRBasePos() const
{
if (m_pVehicle || IsSwimming() || m_pGame->IsCutSceneActive() || !IsAlive() || !IsMyPlayer())
bool usePlayerCam = m_pVehicle || IsSwimming() || m_pGame->IsCutSceneActive() || !IsAlive() || !IsMyPlayer() || gVR->vr_seated_mode;
usePlayerCam = usePlayerCam || m_CurStance == eCrouch || m_CurStance == eProne || m_CurStance == eStealth;
if (usePlayerCam)
{
// use actual camera position as base
Vec3 pos = m_pEntity->GetCamera()->GetPos();
pos.z -= m_hmdRefHeight;
return pos;
}

Vec3 pos = m_pEntity->GetPos();

float offset = 0;
switch (m_CurStance)
{
case eCrouch:
offset = m_PlayerDimCrouch.heightHead - m_hmdRefHeight;
break;
case eProne:
offset = m_PlayerDimProne.heightHead - m_hmdRefHeight;
break;
case eStealth:
offset = m_PlayerDimStealth.heightHead - m_hmdRefHeight;
break;
}

pos.z += offset;
return pos;
return m_pEntity->GetPos();
}

void CPlayer::ModifyWeaponPosition(CWeaponClass* weapon, Vec3& weaponAngles, Vec3& weaponPosition)
Expand Down

0 comments on commit 6684347

Please sign in to comment.