Fix gimbal-lock when controller pointed up or down

Compare old and new pose via a relative quaternion rather than relative yaw, then calculate the resulting yaw-difference from the quaternion in one go.
This commit is contained in:
Kung-vr
2019-01-17 02:32:08 +09:00
parent 0c0a616691
commit 47920bfa74
4 changed files with 71 additions and 18 deletions
+3 -3
View File
@@ -67,9 +67,9 @@ private:
bool m_lockYToggle = false;
bool m_lockZToggle = false;
std::chrono::system_clock::time_point lastMoveButtonClick[2];
// Set to -10.0 when last hand is invalid.
double lastHandYaw = -10.0;
double handYaw;
// Set lastHandQuaternion.w to -1000.0 when last hand is invalid.
vr::HmdQuaternion_t lastHandQuaternion = { -1000.0, 0.0, 0.0, 0.0 };
vr::HmdQuaternion_t handQuaternion;
unsigned settingsUpdateCounter = 0;