xrNoHandTracking option, tweak offsets for non-vive controllers

This commit is contained in:
Ada 2025-05-02 17:02:22 +10:00
parent ec94000432
commit a2dd909ce2
4 changed files with 30 additions and 10 deletions

View file

@ -286,10 +286,14 @@ int main(int argc, const char* argv[]) {
"getProtocolVersionData", "getProtocolVersionData",
"Debug option. Returns the network protocol detailed data in JSON." "Debug option. Returns the network protocol detailed data in JSON."
); );
QCommandLineOption useExperimentalXR( QCommandLineOption useExperimentalXROption(
"useExperimentalXR", "useExperimentalXR",
"Enables the experimental OpenXR plugin and disables the OpenVR plugin. Some features available in OpenVR aren't yet available in OpenXR." "Enables the experimental OpenXR plugin and disables the OpenVR plugin. Some features available in OpenVR aren't yet available in OpenXR."
); );
QCommandLineOption xrNoHandTrackingOption(
"xrNoHandTracking",
"Debug option. Disables OpenXR hand tracking, even if it's supported by the runtime."
);
// "--qmljsdebugger", which appears in output from "--help-all". // "--qmljsdebugger", which appears in output from "--help-all".
// Those below don't seem to be optional. // Those below don't seem to be optional.
@ -339,7 +343,8 @@ int main(int argc, const char* argv[]) {
parser.addOption(getPluginsOption); parser.addOption(getPluginsOption);
parser.addOption(getProtocolVersionHashOption); parser.addOption(getProtocolVersionHashOption);
parser.addOption(getProtocolVersionDataOption); parser.addOption(getProtocolVersionDataOption);
parser.addOption(useExperimentalXR); parser.addOption(useExperimentalXROption);
parser.addOption(xrNoHandTrackingOption);
QString applicationPath; QString applicationPath;

View file

@ -243,6 +243,11 @@ bool OpenXrContext::initSystem() {
next = reinterpret_cast<const XrExtensionProperties*>(next->next); next = reinterpret_cast<const XrExtensionProperties*>(next->next);
} }
// don't start up hand tracking stuff if it's force disabled
if (qApp->arguments().contains("--xrNoHandTracking")) {
_handTrackingSupported = false;
}
return true; return true;
} }

View file

@ -81,9 +81,9 @@ public:
bool _handTrackingSupported = false; bool _handTrackingSupported = false;
PFN_xrCreateHandTrackerEXT xrCreateHandTrackerEXT; PFN_xrCreateHandTrackerEXT xrCreateHandTrackerEXT = nullptr;
PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT; PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT = nullptr;
PFN_xrDestroyHandTrackerEXT xrDestroyHandTrackerEXT; PFN_xrDestroyHandTrackerEXT xrDestroyHandTrackerEXT = nullptr;
private: private:
XrSessionState _lastSessionState = XR_SESSION_STATE_UNKNOWN; XrSessionState _lastSessionState = XR_SESSION_STATE_UNKNOWN;

View file

@ -541,7 +541,7 @@ bool OpenXrInputPlugin::InputDevice::initActions() {
{"/interaction_profiles/valve/index_controller", { {"/interaction_profiles/valve/index_controller", {
{"left_primary_click", hand_left + "/a/click"}, {"left_primary_click", hand_left + "/a/click"},
{"left_secondary_click", hand_left + "/b/click"}, {"left_secondary_click", hand_left + "/b/click"},
{"left_squeeze_value", hand_left + "/squeeze/value"}, {"left_squeeze_value", hand_left + "/squeeze/force"},
{"left_trigger_value", hand_left + "/trigger/value"}, {"left_trigger_value", hand_left + "/trigger/value"},
{"left_trigger_click", hand_left + "/trigger/click"}, {"left_trigger_click", hand_left + "/trigger/click"},
{"left_thumbstick", hand_left + "/thumbstick"}, {"left_thumbstick", hand_left + "/thumbstick"},
@ -552,7 +552,7 @@ bool OpenXrInputPlugin::InputDevice::initActions() {
{"right_primary_click", hand_right + "/a/click"}, {"right_primary_click", hand_right + "/a/click"},
{"right_secondary_click", hand_right + "/b/click"}, {"right_secondary_click", hand_right + "/b/click"},
{"right_squeeze_value", hand_right + "/squeeze/value"}, {"right_squeeze_value", hand_right + "/squeeze/force"},
{"right_trigger_value", hand_right + "/trigger/value"}, {"right_trigger_value", hand_right + "/trigger/value"},
{"right_trigger_click", hand_right + "/trigger/click"}, {"right_trigger_click", hand_right + "/trigger/click"},
{"right_thumbstick", hand_right + "/thumbstick"}, {"right_thumbstick", hand_right + "/thumbstick"},
@ -662,9 +662,19 @@ void OpenXrInputPlugin::InputDevice::update(float deltaTime, const controller::I
glm::mat4 handOffset = i == 0 ? glm::toMat4(leftRotationOffset) : glm::toMat4(rightRotationOffset); glm::mat4 handOffset = i == 0 ? glm::toMat4(leftRotationOffset) : glm::toMat4(rightRotationOffset);
glm::mat4 posOffset(1.0f); glm::mat4 posOffset(1.0f);
posOffset *= glm::translate(glm::vec3(handOffset[0]) * (i == 0 ? 0.1f : -0.1f));
posOffset *= glm::translate(glm::vec3(handOffset[1]) * -0.16f); // vive controllers have bugged poses that aren't in the grip or aim position,
posOffset *= glm::translate(glm::vec3(handOffset[2]) * -0.02f); // they're always at the top near the tracking ring
if (_context->_stickEmulation) {
posOffset *= glm::translate(glm::vec3(handOffset[0]) * (i == 0 ? 0.1f : -0.1f));
posOffset *= glm::translate(glm::vec3(handOffset[1]) * -0.16f);
posOffset *= glm::translate(glm::vec3(handOffset[2]) * -0.02f);
} else {
posOffset *= glm::translate(glm::vec3(handOffset[0]) * (i == 0 ? -0.07f : 0.07f));
posOffset *= glm::translate(glm::vec3(handOffset[1]) * -0.10f);
posOffset *= glm::translate(glm::vec3(handOffset[2]) * -0.01f);
}
_poseStateMap[i == 0 ? controller::LEFT_HAND : controller::RIGHT_HAND] = _poseStateMap[i == 0 ? controller::LEFT_HAND : controller::RIGHT_HAND] =
pose.postTransform(posOffset).postTransform(handOffset).transform(sensorToAvatar); pose.postTransform(posOffset).postTransform(handOffset).transform(sensorToAvatar);
} }