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

This commit is contained in:
James Urquhart 2016-05-26 23:50:27 +01:00
parent e6c89b1f24
commit 660bd8d347
2 changed files with 10 additions and 1 deletions

View file

@ -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);

View file

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