浏览代码

Allow gamepad to rotate openvr view. Also Fix issue with movemanager openvr rotation not being set correctly.

James Urquhart 9 年之前
父节点
当前提交
660bd8d347

+ 9 - 1
Engine/source/platform/input/openVR/openVRProvider.cpp

@@ -229,6 +229,7 @@ U32 OpenVRProvider::OVR_AXISTRIGGER[vr::k_unMaxTrackedDeviceCount] = { 0 };
 EulerF OpenVRProvider::smHMDRotOffset(0);
 F32 OpenVRProvider::smHMDmvYaw = 0;
 F32 OpenVRProvider::smHMDmvPitch = 0;
+bool OpenVRProvider::smRotateYawWithMoveActions = false;
 
 static String GetTrackedDeviceString(vr::IVRSystem *pHmd, vr::TrackedDeviceIndex_t unDevice, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError *peError = NULL)
 {
@@ -397,6 +398,8 @@ void OpenVRProvider::staticInit()
 
    Con::addVariable("$OpenVR::HMDmvYaw", TypeF32, &smHMDmvYaw);
    Con::addVariable("$OpenVR::HMDmvPitch", TypeF32, &smHMDmvPitch);
+
+   Con::addVariable("$OpenVR::HMDRotateYawWithMoveActions", TypeBool, &smRotateYawWithMoveActions);
 }
 
 bool OpenVRProvider::enable()
@@ -571,6 +574,11 @@ bool OpenVRProvider::process()
    if (!vr::VRCompositor())
 	   return true;
 
+   if (smRotateYawWithMoveActions)
+   {
+	   smHMDmvYaw += MoveManager::mRightAction - MoveManager::mLeftAction + MoveManager::mXAxis_L;
+   }
+
    // Update HMD rotation offset
    smHMDRotOffset.z += smHMDmvYaw;
    smHMDRotOffset.x += smHMDmvPitch;
@@ -969,7 +977,7 @@ void OpenVRProvider::updateTrackedPoses()
             // we will then be on a really weird rotation axis.
             QuatF(localRot).setMatrix(&rotOffset);
             rotOffset.inverse();
-            mHMDRenderState.mHMDPose = rotOffset * mHMDRenderState.mHMDPose;
+            mHMDRenderState.mHMDPose = mat = rotOffset * mHMDRenderState.mHMDPose;
 
             // jamesu - store the last rotation for temp debugging
             MatrixF torqueMat(1);

+ 1 - 0
Engine/source/platform/input/openVR/openVRProvider.h

@@ -283,6 +283,7 @@ public:
    static EulerF smHMDRotOffset;
    static F32 smHMDmvYaw;
    static F32 smHMDmvPitch;
+   static bool smRotateYawWithMoveActions;
    /// }
 
 public: