Replace magic numbers, fix bindings localization
Replace magic numbers with constants and centralize settings update counters. Rename actions manifest localization from "en" to "en_US" (Thanks Ykeara)
This commit is contained in:
@@ -117,19 +117,7 @@ void AccessibilityTabController::eventLoopTick(
|
||||
return;
|
||||
}
|
||||
|
||||
// 151 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 151 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AudioTabController: 89
|
||||
// ChaperoneTabController: 101
|
||||
// MoveCenterTabController: 149
|
||||
// ReviveTabController: 139
|
||||
// SettingsTabController: 157
|
||||
// SteamVRTabController: 97
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 151 )
|
||||
if ( settingsUpdateCounter >= parent->k_accessibilitySettingsUpdateCounter )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
|
||||
@@ -169,19 +169,7 @@ void AudioTabController::eventLoopTick()
|
||||
return;
|
||||
}
|
||||
|
||||
// 89 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 89 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// ChaperoneTabController: 101
|
||||
// MoveCenterTabController: 149
|
||||
// ReviveTabController: 139
|
||||
// SettingsTabController: 157
|
||||
// SteamVRTabController: 97
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 89 )
|
||||
if ( settingsUpdateCounter >= parent->k_audioSettingsUpdateCounter )
|
||||
{
|
||||
if ( m_micProximitySensorCanMute )
|
||||
{
|
||||
|
||||
@@ -649,19 +649,7 @@ void ChaperoneTabController::eventLoopTick(
|
||||
}
|
||||
}
|
||||
|
||||
// 101 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 101 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// AudioTabController: 89
|
||||
// MoveCenterTabController: 149
|
||||
// ReviveTabController: 139
|
||||
// SettingsTabController: 157
|
||||
// SteamVRTabController: 97
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 101 )
|
||||
if ( settingsUpdateCounter >= parent->k_chaperoneSettingsUpdateCounter )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
|
||||
@@ -148,7 +148,7 @@ void MoveCenterTabController::setRotation( int value, bool notify )
|
||||
{
|
||||
if ( m_rotation != value )
|
||||
{
|
||||
double angle = ( value - m_rotation ) * M_PI / 18000.0;
|
||||
double angle = ( value - m_rotation ) * k_centidegreesToRadians;
|
||||
|
||||
// Revert now because we don't commit in RotateUniverseCenter and
|
||||
// AddOffsetToUniverseCenter. We do this so rotation and offset can
|
||||
@@ -173,7 +173,7 @@ void MoveCenterTabController::setRotation( int value, bool notify )
|
||||
= { oldHmdPos.m[0][3], oldHmdPos.m[1][3], oldHmdPos.m[2][3] };
|
||||
|
||||
// Convert oldHmdXyz into un-rotated coordinates.
|
||||
double oldAngle = -m_rotation * M_PI / 18000.0;
|
||||
double oldAngle = -m_rotation * k_centidegreesToRadians;
|
||||
rotateCoordinates( oldHmdXyz, oldAngle );
|
||||
|
||||
// Set newHmdXyz to have additional rotation from incoming angle change.
|
||||
@@ -201,7 +201,7 @@ void MoveCenterTabController::setRotation( int value, bool notify )
|
||||
// We use rotated coordinates here because we have already applied
|
||||
// RotateUniverseCenter. This will be the final offset ready to apply,
|
||||
// so it must match the current universe axis rotation.
|
||||
double finalAngle = m_rotation * M_PI / 18000.0;
|
||||
double finalAngle = m_rotation * k_centidegreesToRadians;
|
||||
double finalHmdRotDiff[3] = { hmdRotDiff[0], 0, hmdRotDiff[2] };
|
||||
rotateCoordinates( finalHmdRotDiff, finalAngle );
|
||||
|
||||
@@ -259,7 +259,7 @@ void MoveCenterTabController::setAdjustChaperone( bool value, bool notify )
|
||||
m_adjustChaperone = value;
|
||||
if ( m_trackingUniverse == vr::TrackingUniverseStanding )
|
||||
{
|
||||
double angle = m_rotation * M_PI / 18000.0;
|
||||
double angle = m_rotation * k_centidegreesToRadians;
|
||||
double offsetdir = m_adjustChaperone ? -1.0 : 1.0;
|
||||
double offset[3] = { offsetdir * m_offsetX,
|
||||
offsetdir * m_offsetY,
|
||||
@@ -406,7 +406,7 @@ void MoveCenterTabController::modOffsetX( float value, bool notify )
|
||||
// TODO ? possible issue with locking position this way
|
||||
if ( !m_lockXToggle )
|
||||
{
|
||||
double angle = m_rotation * M_PI / 18000.0;
|
||||
double angle = m_rotation * k_centidegreesToRadians;
|
||||
double offset[3] = { value, 0, 0 };
|
||||
rotateCoordinates( offset, angle );
|
||||
float offsetFloat[3] = { static_cast<float>( offset[0] ),
|
||||
@@ -445,7 +445,7 @@ void MoveCenterTabController::modOffsetZ( float value, bool notify )
|
||||
{
|
||||
if ( !m_lockZToggle )
|
||||
{
|
||||
double angle = m_rotation * M_PI / 18000.0;
|
||||
double angle = m_rotation * k_centidegreesToRadians;
|
||||
double offset[3] = { 0, 0, value };
|
||||
rotateCoordinates( offset, angle );
|
||||
float offsetFloat[3] = { static_cast<float>( offset[0] ),
|
||||
@@ -468,7 +468,7 @@ void MoveCenterTabController::reset()
|
||||
vr::VRChaperoneSetup()->RevertWorkingCopy();
|
||||
parent->RotateUniverseCenter(
|
||||
vr::TrackingUniverseOrigin( m_trackingUniverse ),
|
||||
static_cast<float>( -m_rotation * M_PI / 18000.0 ),
|
||||
static_cast<float>( -m_rotation * k_centidegreesToRadians ),
|
||||
m_adjustChaperone,
|
||||
false );
|
||||
float offset[3] = { -m_offsetX, -m_offsetY, -m_offsetZ };
|
||||
@@ -862,19 +862,7 @@ void MoveCenterTabController::eventLoopTick(
|
||||
vr::ETrackingUniverseOrigin universe,
|
||||
vr::TrackedDevicePose_t* devicePoses )
|
||||
{
|
||||
// 149 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 149 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// AudioTabController: 89
|
||||
// ChaperoneTabController: 101
|
||||
// ReviveTabController: 139
|
||||
// SettingsTabController: 157
|
||||
// SteamVRTabController: 97
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 149 )
|
||||
if ( settingsUpdateCounter >= parent->k_moveCenterSettingsUpdateCounter )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
@@ -887,7 +875,7 @@ void MoveCenterTabController::eventLoopTick(
|
||||
settingsUpdateCounter++;
|
||||
}
|
||||
|
||||
double angle = m_rotation * M_PI / 18000.0;
|
||||
double angle = m_rotation * k_centidegreesToRadians;
|
||||
|
||||
// START of hmd rotation stats tracking:
|
||||
// Check if hmd is tracking ok and do everything
|
||||
@@ -907,13 +895,13 @@ void MoveCenterTabController::eventLoopTick(
|
||||
utils::matMul33( hmdMatrixAbsolute, hmdMatrixRotMat, hmdMatrix );
|
||||
|
||||
// Convert pose matrix to quaternion
|
||||
hmdQuaternion = utils::getQuaternion( hmdMatrixAbsolute );
|
||||
m_hmdQuaternion = utils::getQuaternion( hmdMatrixAbsolute );
|
||||
|
||||
// Get rotation change of hmd
|
||||
// Checking if set to -1000.0 placeholder for invalid hmd pose.
|
||||
if ( lastHmdQuaternion.w < -900.0 )
|
||||
if ( m_lastHmdQuaternion.w < -900.0 )
|
||||
{
|
||||
lastHmdQuaternion = hmdQuaternion;
|
||||
m_lastHmdQuaternion = m_hmdQuaternion;
|
||||
}
|
||||
|
||||
else
|
||||
@@ -921,8 +909,8 @@ void MoveCenterTabController::eventLoopTick(
|
||||
// Construct a quaternion representing difference between old
|
||||
// hmd pose and new hmd pose.
|
||||
vr::HmdQuaternion_t hmdDiffQuaternion = utils::multiplyQuaternion(
|
||||
hmdQuaternion,
|
||||
utils::quaternionConjugate( lastHmdQuaternion ) );
|
||||
m_hmdQuaternion,
|
||||
utils::quaternionConjugate( m_lastHmdQuaternion ) );
|
||||
|
||||
// Calculate yaw from quaternion.
|
||||
double hmdYawDiff = atan2(
|
||||
@@ -936,7 +924,7 @@ void MoveCenterTabController::eventLoopTick(
|
||||
|
||||
// Apply yaw difference to m_hmdYawTotal.
|
||||
m_hmdYawTotal += hmdYawDiff;
|
||||
lastHmdQuaternion = hmdQuaternion;
|
||||
m_lastHmdQuaternion = m_hmdQuaternion;
|
||||
}
|
||||
|
||||
// end check if hmdpose is ok
|
||||
@@ -944,7 +932,7 @@ void MoveCenterTabController::eventLoopTick(
|
||||
else
|
||||
{
|
||||
// set lastHmdQuaternion.w to placeholder -1000.0 for invalid
|
||||
lastHmdQuaternion.w = -1000.0;
|
||||
m_lastHmdQuaternion.w = -1000.0;
|
||||
} // END of hmd rotation stats tracking
|
||||
|
||||
/*
|
||||
@@ -1077,7 +1065,7 @@ void MoveCenterTabController::eventLoopTick(
|
||||
{
|
||||
// Set lastHandQuaternion.w to placeholder value for invalid
|
||||
// (-1000.0)
|
||||
lastHandQuaternion.w = -1000.0;
|
||||
m_lastHandQuaternion.w = -1000.0;
|
||||
}
|
||||
m_lastRotateHand = m_activeTurnHand;
|
||||
}
|
||||
@@ -1108,15 +1096,15 @@ void MoveCenterTabController::eventLoopTick(
|
||||
utils::matMul33( handMatrixAbsolute, handMatrixRotMat, handMatrix );
|
||||
|
||||
// Convert pose matrix to quaternion
|
||||
handQuaternion = utils::getQuaternion( handMatrixAbsolute );
|
||||
m_handQuaternion = utils::getQuaternion( handMatrixAbsolute );
|
||||
|
||||
if ( m_lastRotateHand == m_activeTurnHand )
|
||||
{
|
||||
// Get rotation change of hand.
|
||||
// Checking if set to -1000.0 placeholder for invalid hand.
|
||||
if ( lastHandQuaternion.w < -900.0 )
|
||||
if ( m_lastHandQuaternion.w < -900.0 )
|
||||
{
|
||||
lastHandQuaternion = handQuaternion;
|
||||
m_lastHandQuaternion = m_handQuaternion;
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1125,8 +1113,9 @@ void MoveCenterTabController::eventLoopTick(
|
||||
// between old hand and new hand.
|
||||
vr::HmdQuaternion_t handDiffQuaternion
|
||||
= utils::multiplyQuaternion(
|
||||
handQuaternion,
|
||||
utils::quaternionConjugate( lastHandQuaternion ) );
|
||||
m_handQuaternion,
|
||||
utils::quaternionConjugate(
|
||||
m_lastHandQuaternion ) );
|
||||
|
||||
// Calculate yaw from quaternion.
|
||||
double handYawDiff = atan2(
|
||||
@@ -1141,9 +1130,10 @@ void MoveCenterTabController::eventLoopTick(
|
||||
* handDiffQuaternion.x ) );
|
||||
|
||||
int newRotationAngleDeg = static_cast<int>(
|
||||
round( handYawDiff * 18000.0 / M_PI ) + m_rotation );
|
||||
round( handYawDiff * k_radiansToCentidegrees )
|
||||
+ m_rotation );
|
||||
|
||||
// Keep angle within -18000 ~ 18000
|
||||
// Keep angle within -18000 ~ 18000 centidegrees
|
||||
if ( newRotationAngleDeg > 18000 )
|
||||
{
|
||||
newRotationAngleDeg -= 36000;
|
||||
@@ -1156,7 +1146,7 @@ void MoveCenterTabController::eventLoopTick(
|
||||
setRotation( newRotationAngleDeg );
|
||||
}
|
||||
}
|
||||
lastHandQuaternion = handQuaternion;
|
||||
m_lastHandQuaternion = m_handQuaternion;
|
||||
m_lastRotateHand = m_activeTurnHand;
|
||||
}
|
||||
} // END of hand rotation
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <openvr.h>
|
||||
#include <chrono>
|
||||
#include <qmath.h>
|
||||
|
||||
class QQuickWindow;
|
||||
// application namespace
|
||||
@@ -65,11 +66,11 @@ private:
|
||||
bool m_lockZToggle = false;
|
||||
std::chrono::system_clock::time_point lastMoveButtonClick[2];
|
||||
// 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;
|
||||
vr::HmdQuaternion_t m_lastHandQuaternion = { -1000.0, 0.0, 0.0, 0.0 };
|
||||
vr::HmdQuaternion_t m_handQuaternion;
|
||||
// Set lastHmdQuaternion.w to -1000.0 when last hmd pose is invalid.
|
||||
vr::HmdQuaternion_t lastHmdQuaternion = { -1000.0, 0.0, 0.0, 0.0 };
|
||||
vr::HmdQuaternion_t hmdQuaternion;
|
||||
vr::HmdQuaternion_t m_lastHmdQuaternion = { -1000.0, 0.0, 0.0, 0.0 };
|
||||
vr::HmdQuaternion_t m_hmdQuaternion;
|
||||
double m_hmdYawTotal = 0.0;
|
||||
vr::ETrackedControllerRole m_activeDragHand
|
||||
= vr::TrackedControllerRole_Invalid;
|
||||
@@ -87,10 +88,9 @@ private:
|
||||
bool m_rightHandTurnPressed = false;
|
||||
bool m_overrideLeftHandTurnPressed = false;
|
||||
bool m_overrideRightHandTurnPressed = false;
|
||||
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
|
||||
// vr::ETrackedControllerRole getMoveShortcutHand();
|
||||
static constexpr double k_centidegreesToRadians = M_PI / 18000.0;
|
||||
static constexpr double k_radiansToCentidegrees = 18000.0 / M_PI;
|
||||
|
||||
public:
|
||||
void initStage1();
|
||||
|
||||
@@ -309,19 +309,7 @@ void ReviveTabController::eventLoopTick()
|
||||
if ( m_isOverlayInstalled
|
||||
|| parent->m_settingsTabController.forceRevivePage() )
|
||||
{
|
||||
// 139 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 139 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// AudioTabController: 89
|
||||
// ChaperoneTabController: 101
|
||||
// MoveCenterTabController: 149
|
||||
// SettingsTabController: 157
|
||||
// SteamVRTabController: 97
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 139 )
|
||||
if ( settingsUpdateCounter >= parent->k_reviveSettingsUpdateCounter )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
|
||||
@@ -28,19 +28,7 @@ void SettingsTabController::initStage2( OverlayController* var_parent,
|
||||
|
||||
void SettingsTabController::eventLoopTick()
|
||||
{
|
||||
// 157 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 157 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// AudioTabController: 89
|
||||
// ChaperoneTabController: 101
|
||||
// MoveCenterTabController: 149
|
||||
// ReviveTabController: 139
|
||||
// SteamVRTabController: 97
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 157 )
|
||||
if ( settingsUpdateCounter >= parent->k_settingsTabSettingsUpdateCounter )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
|
||||
@@ -22,19 +22,7 @@ void SteamVRTabController::initStage2( OverlayController* var_parent,
|
||||
|
||||
void SteamVRTabController::eventLoopTick()
|
||||
{
|
||||
// 97 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 97 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// AudioTabController: 89
|
||||
// ChaperoneTabController: 101
|
||||
// MoveCenterTabController: 149
|
||||
// ReviveTabController: 139
|
||||
// SettingsTabController: 157
|
||||
// UtilitiesTabController: 19
|
||||
if ( settingsUpdateCounter >= 97 )
|
||||
if ( settingsUpdateCounter >= parent->k_steamVrSettingsUpdateCounter )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
|
||||
@@ -321,19 +321,7 @@ vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index )
|
||||
|
||||
void UtilitiesTabController::eventLoopTick()
|
||||
{
|
||||
// 19 was chosen because it's a prime number (to reduce overlap of
|
||||
// simultaneous settings updates).
|
||||
// Actual rate of updates is 19 * vsync (~11ms)
|
||||
// Values chosen based on update speed priority
|
||||
// Values in other tabs are as follows (avoid using same values):
|
||||
// AccessibiltyTabController: 151
|
||||
// AudioTabController: 89
|
||||
// ChaperoneTabController: 101
|
||||
// MoveCenterTabController: 149
|
||||
// ReviveTabController: 139
|
||||
// SettingsTabController: 157
|
||||
// SteamVRTabController: 97
|
||||
if ( settingsUpdateCounter >= 19 )
|
||||
if ( settingsUpdateCounter >= parent->k_utilitiesSettingsUpdateCounter )
|
||||
{
|
||||
vr::VROverlayHandle_t pOverlayHandle;
|
||||
auto error = vr::VROverlay()->FindOverlay( steamDesktopOverlaykey,
|
||||
|
||||
Reference in New Issue
Block a user