From 2a534877da54e990b961ab748607ba5a13779d06 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sat, 8 Aug 2020 12:24:24 +0200 Subject: [PATCH] Head/hand directed movement option --- apps/openmw/mwvr/vrsession.cpp | 26 +++++++++++++++----------- apps/openmw/mwvr/vrsession.hpp | 1 + files/settings-default.cfg | 3 +++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwvr/vrsession.cpp b/apps/openmw/mwvr/vrsession.cpp index 9ca1fc046..92f8a3b46 100644 --- a/apps/openmw/mwvr/vrsession.cpp +++ b/apps/openmw/mwvr/vrsession.cpp @@ -41,6 +41,7 @@ namespace MWVR VRSession::VRSession() : mXrSyncPhase{FramePhase::Cull} { + mHandDirectedMovement = Settings::Manager::getBool("hand directed movement", "VR"); auto syncPhase = Settings::Manager::getString("openxr sync phase", "VR"); syncPhase = Misc::StringUtils::lowerCase(syncPhase); if (syncPhase == "update") @@ -306,21 +307,24 @@ namespace MWVR { if (!getFrame(FramePhase::Update)) beginPhase(FramePhase::Update); - auto frameMeta = getFrame(FramePhase::Update).get(); + if (mHandDirectedMovement) + { + auto frameMeta = getFrame(FramePhase::Update).get(); - float headYaw = 0.f; - float headPitch = 0.f; - float headsWillRoll = 0.f; + float headYaw = 0.f; + float headPitch = 0.f; + float headsWillRoll = 0.f; - float handYaw = 0.f; - float handPitch = 0.f; - float handRoll = 0.f; + float handYaw = 0.f; + float handPitch = 0.f; + float handRoll = 0.f; - getEulerAngles(frameMeta->mPredictedPoses.head.orientation, headYaw, headPitch, headsWillRoll); - getEulerAngles(frameMeta->mPredictedPoses.hands[(int)Side::LEFT_SIDE].orientation, handYaw, handPitch, handRoll); + getEulerAngles(frameMeta->mPredictedPoses.head.orientation, headYaw, headPitch, headsWillRoll); + getEulerAngles(frameMeta->mPredictedPoses.hands[(int)Side::LEFT_SIDE].orientation, handYaw, handPitch, handRoll); - yaw = handYaw - headYaw; - pitch = handPitch - headPitch; + yaw = handYaw - headYaw; + pitch = handPitch - headPitch; + } } } diff --git a/apps/openmw/mwvr/vrsession.hpp b/apps/openmw/mwvr/vrsession.hpp index 8b259d891..b60b8dbfb 100644 --- a/apps/openmw/mwvr/vrsession.hpp +++ b/apps/openmw/mwvr/vrsession.hpp @@ -83,6 +83,7 @@ namespace MWVR std::condition_variable mCondition{}; FramePhase mXrSyncPhase{ FramePhase::Cull }; + bool mHandDirectedMovement{ false }; bool mUseSteadyClock{ false }; long long mFrames{ 0 }; long long mLastRenderedFrame{ 0 }; diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 47676b2ae..eb4352fb2 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -942,3 +942,6 @@ log all openxr calls = false # If false, openmw will quit with an exception if an openxr call fails for any reason continue on errors = true + +# If true, movement direction is taken from the left hand tracker, instead of your head. +hand directed movement = false \ No newline at end of file