From bf2c3cf9ddbc8ac0b7a95cca5a52b795d526413f Mon Sep 17 00:00:00 2001 From: Holger Frydrych Date: Sat, 2 Sep 2023 23:08:26 +0200 Subject: [PATCH] Fix cutscene camera; hide player hands in cutscenes; smooth camera Z position on stairs --- .../Solution1/CryGame/VRManager.cpp | 4 +++- .../CryGame C++/Solution1/CryGame/XPlayer.cpp | 20 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp b/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp index 3558dbb..2874de7 100644 --- a/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp @@ -444,8 +444,10 @@ void VRManager::ModifyViewCamera(int eye, CCamera& cam) Ang3 angles = cam.GetAngles(); Vec3 position = cam.GetPos(); + position.z -= m_referenceHeight; - if (CPlayer* player = m_pGame->GetLocalPlayer()) + CPlayer* player = m_pGame->GetLocalPlayer(); + if (player && !m_pGame->IsCutSceneActive()) { position = player->GetVRBasePos(); } diff --git a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp index 10514d2..82a9183 100644 --- a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp @@ -2554,7 +2554,9 @@ void CPlayer::ProcessRoomscaleMovement(CXEntityProcessingCmd& ProcessingCmd) Vec3 fwd = worldOffset.GetNormalized(); Vec3 left = -fwd.Cross(normal); fwd = left.Cross(normal); - worldOffset = fwd * worldOffset.len(); + Vec3 fwd2D = fwd; + fwd2D.z = 0; + worldOffset = fwd * worldOffset.len() / (max(fwd2D.len(), 0.01f)); } Vec3 desiredPos = playerPos + worldOffset; @@ -2582,9 +2584,11 @@ Vec3 CPlayer::GetVRBasePos() const } Vec3 pos = m_pEntity->GetPos(); + float refHeight = m_PlayerDimNormal.heightEye; if (m_CurStance == eProne) { + refHeight = m_PlayerDimProne.heightEye; if (m_curPhysicalStance == eCrouch) { pos.z -= (m_PlayerDimCrouch.heightEye - m_PlayerDimProne.heightEye); @@ -2596,12 +2600,23 @@ Vec3 CPlayer::GetVRBasePos() const } else if (m_CurStance == eCrouch) { + refHeight = m_PlayerDimCrouch.heightEye; if (m_curPhysicalStance == eNone) { pos.z -= (m_hmdRefHeight - m_PlayerDimCrouch.heightEye); } } + pe_status_living status; + m_pEntity->GetPhysics()->GetStatus(&status); + if (status.timeSinceStanceChange > 3.f) + { + // if we are not in a stance change, apply camera height offset + // this smoothes movement over stairs and other steps + float camOffset = m_pEntity->GetCamera()->GetCamOffset().z; + pos.z += camOffset - refHeight; + } + return pos; } @@ -5151,7 +5166,8 @@ void CPlayer::OnDraw(const SRendParams & _RendParams) int nRecursionLevel = (int)m_pGame->GetSystem()->GetIRenderer()->EF_Query(EFQ_RecurseLevel) - 1; - if (m_bFirstPerson && !nRecursionLevel && !GetVehicle() && !m_pMountedWeapon && gVR->vr_show_empty_hands && !m_pGame->AreBinocularsActive()) + if (m_bFirstPerson && !nRecursionLevel && !GetVehicle() && !m_pMountedWeapon && gVR->vr_show_empty_hands + && !m_pGame->AreBinocularsActive() && !m_pGame->IsCutSceneActive()) { bool hideOffHand = GetSelectedWeapon() && (m_twoHandWeaponMode || m_stats.reloading); if (!hideOffHand)