From 34157de90a5a3bad6b1493b6ea93d6485e10c577 Mon Sep 17 00:00:00 2001 From: Stefano Date: Mon, 16 Sep 2024 14:43:51 +0200 Subject: [PATCH] Added flag to disable use of expressions --- src/devices/openxrheadset/OpenXrHeadset.cpp | 3 +++ src/devices/openxrheadset/OpenXrInterface.cpp | 15 +++++++++------ src/devices/openxrheadset/OpenXrInterface.h | 1 + .../openxrheadset/impl/OpenXrInterfaceImpl.h | 6 +++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/devices/openxrheadset/OpenXrHeadset.cpp b/src/devices/openxrheadset/OpenXrHeadset.cpp index 00538d5..d535121 100644 --- a/src/devices/openxrheadset/OpenXrHeadset.cpp +++ b/src/devices/openxrheadset/OpenXrHeadset.cpp @@ -259,6 +259,9 @@ bool yarp::dev::OpenXrHeadset::open(yarp::os::Searchable &cfg) bool noGaze = cfg.check("no_gaze") && (cfg.find("no_gaze").isNull() || cfg.find("no_gaze").asBool()); m_openXrInterfaceSettings.useGaze = !noGaze; + bool noExpressions = cfg.check("no_expressions") && (cfg.find("no_expressions").isNull() || cfg.find("no_expressions").asBool()); + m_openXrInterfaceSettings.useExpressions = !noExpressions; + m_getStickAsAxis = cfg.check("stick_as_axis", yarp::os::Value(false)).asBool(); m_rootFrame = cfg.check("tf_root_frame", yarp::os::Value("openxr_origin")).asString(); m_rootFrameRaw = m_rootFrame + "_raw"; diff --git a/src/devices/openxrheadset/OpenXrInterface.cpp b/src/devices/openxrheadset/OpenXrInterface.cpp index cb500f3..a209a06 100644 --- a/src/devices/openxrheadset/OpenXrInterface.cpp +++ b/src/devices/openxrheadset/OpenXrInterface.cpp @@ -41,6 +41,7 @@ bool OpenXrInterface::checkExtensions() bool depth_supported = false; bool debug_supported = false; bool gaze_supported = false; + bool htc_facial_tracking_supported = false; std::stringstream supported_extensions; supported_extensions << "Supported extensions: " <htc_facial_tracking_extension_supported = true; + htc_facial_tracking_supported = true; } if (strcmp(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME, ext_props[i].extensionName) == 0) { @@ -102,8 +103,9 @@ bool OpenXrInterface::checkExtensions() yCWarning(OPENXRHEADSET) << "Runtime does not support the HTC Vive Focus 3 controllers!"; } - if (!m_pimpl->htc_facial_tracking_extension_supported) { + if (!htc_facial_tracking_supported) { yCWarning(OPENXRHEADSET) << "Runtime does not support the HTC Vive Facial Tracking!"; + m_pimpl->use_expressions = false; } if (!gaze_supported) { @@ -154,7 +156,7 @@ bool OpenXrInterface::prepareXrInstance() { requestedExtensions.push_back(XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME); } - if (m_pimpl->htc_facial_tracking_extension_supported) + if (m_pimpl->use_expressions) { requestedExtensions.push_back(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME); } @@ -255,7 +257,7 @@ bool OpenXrInterface::prepareXrInstance() return false; } - if (m_pimpl->htc_facial_tracking_extension_supported) + if (m_pimpl->use_expressions) { result = xrGetInstanceProcAddr(m_pimpl->instance, "xrCreateFacialTrackerHTC", (PFN_xrVoidFunction*)&(m_pimpl->pfn_xrCreateFacialTrackerHTC)); @@ -375,7 +377,7 @@ void OpenXrInterface::checkSystemProperties() facial_tracking_props.supportEyeFacialTracking = XR_FALSE; facial_tracking_props.supportLipFacialTracking = XR_FALSE; - if (m_pimpl->htc_facial_tracking_extension_supported) + if (m_pimpl->use_expressions) { *next_chain = &facial_tracking_props; next_chain = &facial_tracking_props.next; @@ -409,7 +411,7 @@ void OpenXrInterface::checkSystemProperties() yCInfo(OPENXRHEADSET, "\tOrientation Tracking: %d", system_props.trackingProperties.orientationTracking); yCInfo(OPENXRHEADSET, "\tPosition Tracking : %d", system_props.trackingProperties.positionTracking); - if (m_pimpl->htc_facial_tracking_extension_supported) + if (m_pimpl->use_expressions) { yCInfo(OPENXRHEADSET, "Facial tracking properties for system %lu: Eye tracking %d, Lip tracking %d", system_props.systemId, facial_tracking_props.supportEyeFacialTracking, facial_tracking_props.supportLipFacialTracking); @@ -1635,6 +1637,7 @@ bool OpenXrInterface::initialize(const OpenXrInterfaceSettings &settings) m_pimpl->hideWindow = settings.hideWindow; m_pimpl->renderInPlaySpace = settings.renderInPlaySpace; m_pimpl->use_gaze = settings.useGaze; + m_pimpl->use_expressions = settings.useExpressions; #ifdef DEBUG_RENDERING_LOCATION m_pimpl->renderInPlaySpace = true; diff --git a/src/devices/openxrheadset/OpenXrInterface.h b/src/devices/openxrheadset/OpenXrInterface.h index a7a615b..dd9a4bb 100644 --- a/src/devices/openxrheadset/OpenXrInterface.h +++ b/src/devices/openxrheadset/OpenXrInterface.h @@ -73,6 +73,7 @@ struct OpenXrInterfaceSettings bool hideWindow{false}; bool renderInPlaySpace{false}; bool useGaze{ true }; + bool useExpressions{ true }; }; class OpenXrInterface diff --git a/src/devices/openxrheadset/impl/OpenXrInterfaceImpl.h b/src/devices/openxrheadset/impl/OpenXrInterfaceImpl.h index 412f8b1..a18153a 100644 --- a/src/devices/openxrheadset/impl/OpenXrInterfaceImpl.h +++ b/src/devices/openxrheadset/impl/OpenXrInterfaceImpl.h @@ -304,9 +304,6 @@ class OpenXrInterface::Implementation // flag to check if the HTC VIVE Focus3 controllers are supported by the runtime. bool focus3_supported = false; - //flag to check if the HTC facial tracking is supported by the runtime. - bool htc_facial_tracking_extension_supported = false; - //flag to check if facial tracking is supported by the headset. bool htc_eye_facial_tracking_supported = false; @@ -330,6 +327,9 @@ class OpenXrInterface::Implementation std::vector htc_eye_expressions; std::vector htc_lip_expressions; + // Flag to enable the use of expressions + bool use_expressions = true; + // Flag to enable the use of gaze bool use_gaze = true;