From ffdb47fcb68983575d2440ee6cc289ae68f3cd26 Mon Sep 17 00:00:00 2001 From: Kung-vr Date: Thu, 31 Jan 2019 03:54:59 +0900 Subject: [PATCH] Clarified invalid quaternion checking Note: Considered NaN, however we use a placeholder invalid number rather than NaN because NaN can have unintuitive behavior when comparing as boolean. --- src/tabcontrollers/MoveCenterTabController.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index 596e996..0edecc8 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -898,7 +898,8 @@ void MoveCenterTabController::eventLoopTick( m_hmdQuaternion = utils::getQuaternion( hmdMatrixAbsolute ); // Get rotation change of hmd - // Checking if set to -1000.0 placeholder for invalid hmd pose. + // Checking for invalid quaternion using < because == isn't guaranteed + // for doubles comparison. if ( m_lastHmdQuaternion.w < k_quaternionUnderIsInvalidValueThreshold ) { m_lastHmdQuaternion = m_hmdQuaternion; @@ -931,7 +932,6 @@ void MoveCenterTabController::eventLoopTick( } else { - // set lastHmdQuaternion.w to placeholder -1000.0 for invalid m_lastHmdQuaternion.w = k_quaternionInvalidValue; } // END of hmd rotation stats tracking @@ -1081,7 +1081,8 @@ void MoveCenterTabController::eventLoopTick( if ( m_lastRotateHand == m_activeTurnHand ) { // Get rotation change of hand. - // Checking if m_lastHandQuaternion is invalid + // Checking for invalid quaternion using < because == isn't + // guaranteed for doubles comparison. if ( m_lastHandQuaternion.w < k_quaternionUnderIsInvalidValueThreshold ) {