Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+70
-121
@@ -28,16 +28,20 @@
|
||||
#include "utils/files.h"
|
||||
#include "vk/check.h"
|
||||
#include "wifi_lock.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/actionset.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr/htc_exts.h"
|
||||
#include "xr/htc_face_tracker.h"
|
||||
#include "xr/meta_body_tracking_fidelity.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <algorithm>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/url/parse.hpp>
|
||||
#include <chrono>
|
||||
#include <ctype.h>
|
||||
#include <exception>
|
||||
#include <magic_enum.hpp>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
@@ -134,7 +138,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/facebook/touch_controller_pro",
|
||||
.required_extensions = {"XR_FB_touch_controller_pro"},
|
||||
.required_extensions = {XR_FB_TOUCH_CONTROLLER_PRO_EXTENSION_NAME},
|
||||
.max_version = XR_MAKE_VERSION(1, 1, 0),
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
@@ -247,7 +251,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/meta/touch_controller_plus",
|
||||
.required_extensions = {"XR_META_touch_controller_plus"},
|
||||
.required_extensions = {XR_META_TOUCH_CONTROLLER_PLUS_EXTENSION_NAME},
|
||||
.max_version = XR_MAKE_VERSION(1, 1, 0),
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
@@ -348,7 +352,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/bytedance/pico_neo3_controller",
|
||||
.required_extensions = {"XR_BD_controller_interaction"},
|
||||
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -391,7 +395,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/bytedance/pico4_controller",
|
||||
.required_extensions = {"XR_BD_controller_interaction"},
|
||||
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -434,7 +438,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/bytedance/pico4s_controller",
|
||||
.required_extensions = {"XR_BD_controller_interaction"},
|
||||
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -477,7 +481,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/htc/vive_focus3_controller",
|
||||
.required_extensions = {"XR_HTC_vive_focus3_controller_interaction"},
|
||||
.required_extensions = {XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -519,7 +523,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/ext/hand_interaction_ext",
|
||||
.required_extensions = {"XR_EXT_hand_interaction"},
|
||||
.required_extensions = {XR_EXT_HAND_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/input/aim/pose",
|
||||
"/user/hand/left/input/grip/pose",
|
||||
@@ -548,11 +552,14 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/htc/vive_xr_tracker",
|
||||
.required_extensions = {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"},
|
||||
.required_extensions = {
|
||||
XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME,
|
||||
XR_HTC_PATH_ENUMERATION_EXTENSION_NAME,
|
||||
},
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/ext/eye_gaze_interaction",
|
||||
.required_extensions = {"XR_EXT_eye_gaze_interaction"},
|
||||
.required_extensions = {XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/eyes_ext/input/gaze_ext/pose",
|
||||
},
|
||||
@@ -717,15 +724,13 @@ void application::initialize_vulkan()
|
||||
spdlog::info("Using Vulkan validation layer");
|
||||
layers.push_back("VK_LAYER_KHRONOS_validation");
|
||||
}
|
||||
bool debug_report_found = false;
|
||||
bool debug_utils_found = false;
|
||||
#endif
|
||||
|
||||
std::vector<const char *> instance_extensions{};
|
||||
std::unordered_set<std::string_view> optional_device_extensions{};
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool debug_report_found = false;
|
||||
bool debug_utils_found = false;
|
||||
#endif
|
||||
spdlog::info("Available Vulkan instance extensions:");
|
||||
std::vector<std::pair<std::string, int>> extensions;
|
||||
for (vk::ExtensionProperties & i: vk_context.enumerateInstanceExtensionProperties(nullptr))
|
||||
@@ -734,26 +739,23 @@ void application::initialize_vulkan()
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!strcmp(i.extensionName, VK_EXT_DEBUG_REPORT_EXTENSION_NAME))
|
||||
{
|
||||
debug_report_found = true;
|
||||
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME))
|
||||
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) and
|
||||
guess_model() != model::oculus_quest) // Quest 1 lies, the extension won't load
|
||||
{
|
||||
debug_utils_found = true;
|
||||
instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::ranges::sort(extensions);
|
||||
for (const auto & [extension_name, spec_version]: extensions)
|
||||
spdlog::info(" {} (version {})", extension_name, spec_version);
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (debug_utils_found && debug_report_found)
|
||||
{
|
||||
// debug_extensions_found = true;
|
||||
// spdlog::info("Using debug extensions");
|
||||
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||
// instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
vk_device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
|
||||
|
||||
@@ -958,8 +960,6 @@ void application::initialize_actions()
|
||||
{
|
||||
spdlog::debug("Initializing actions");
|
||||
|
||||
auto * htc_body = std::get_if<xr::htc_body_tracker>(&body_tracker);
|
||||
|
||||
// Build an action set with all possible input sources
|
||||
std::vector<XrActionSet> action_sets;
|
||||
xr_actionset = xr::actionset(xr_instance, "all_actions", "All actions");
|
||||
@@ -973,7 +973,9 @@ void application::initialize_actions()
|
||||
std::vector<std::string> sources;
|
||||
for (auto & profile: interaction_profiles)
|
||||
{
|
||||
profile.available = utils::contains_all(xr_extensions, profile.required_extensions) and profile.min_version <= api_version and profile.max_version > api_version;
|
||||
profile.available = std::ranges::all_of(profile.required_extensions, [&](auto & ext) { return xr_instance.has_extension(ext); }) and
|
||||
profile.min_version <= api_version and
|
||||
profile.max_version > api_version;
|
||||
|
||||
if (profile.profile_name.ends_with("khr/simple_controller"))
|
||||
{
|
||||
@@ -1014,15 +1016,15 @@ void application::initialize_actions()
|
||||
}
|
||||
if (add_palms)
|
||||
{
|
||||
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or utils::contains(xr_extensions, XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or xr_instance.has_extension(XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose"))
|
||||
{
|
||||
spdlog::info("Adding grip_surface/pose for interaction profile {}", profile.profile_name);
|
||||
profile.input_sources.push_back("/user/hand/left/input/grip_surface/pose");
|
||||
profile.input_sources.push_back("/user/hand/right/input/grip_surface/pose");
|
||||
}
|
||||
else if (utils::contains(xr_extensions, XR_EXT_PALM_POSE_EXTENSION_NAME) //
|
||||
else if (xr_instance.has_extension(XR_EXT_PALM_POSE_EXTENSION_NAME) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
and not utils::contains(profile.input_sources, "/user/hand/left/input/palm_ext/pose"))
|
||||
{
|
||||
@@ -1033,14 +1035,15 @@ void application::initialize_actions()
|
||||
}
|
||||
|
||||
// Dynamically add VIVE XR Trackers to the profile if available
|
||||
if (htc_body && utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME))
|
||||
if (utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME) and
|
||||
xr_instance.has_extension(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME))
|
||||
{
|
||||
for (const auto & user_path: htc_body->get_paths())
|
||||
XrPath tracker_profile = xr_instance.string_to_path("/interaction_profiles/htc/vive_xr_tracker");
|
||||
for (const auto & user_path: xr_instance.enumerate_paths_for_interaction_profile(tracker_profile))
|
||||
{
|
||||
for (const auto & input_path: htc_body->get_paths(user_path))
|
||||
{
|
||||
profile.input_sources.push_back(path_to_string(user_path) + path_to_string(input_path));
|
||||
}
|
||||
generic_trackers.emplace_back(user_path, nullptr);
|
||||
for (const auto & input_path: xr_instance.enumerate_paths_for_interaction_profile(tracker_profile, user_path))
|
||||
profile.input_sources.push_back(xr_instance.path_to_string(user_path) + xr_instance.path_to_string(input_path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,8 +1091,14 @@ void application::initialize_actions()
|
||||
spaces[size_t(xr::spaces::poke_right)] = xr_session.create_action_space(a);
|
||||
else if (name == "/user/eyes_ext/input/gaze_ext/pose")
|
||||
spaces[size_t(xr::spaces::eye_gaze)] = xr_session.create_action_space(a);
|
||||
else if (name.contains("/input/entity_htc/pose") && htc_body)
|
||||
htc_body->add(xr_session.create_action_space(a));
|
||||
else if (name.contains("/input/entity_htc/pose"))
|
||||
{
|
||||
for (auto & [path, action]: generic_trackers)
|
||||
{
|
||||
if (name.starts_with(xr_instance.path_to_string(path)))
|
||||
action = xr_session.create_action_space(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build an action set for each scene
|
||||
@@ -1126,7 +1135,7 @@ void application::initialize_actions()
|
||||
|
||||
xr_bindings.push_back(XrActionSuggestedBinding{
|
||||
.action = a,
|
||||
.binding = string_to_path(k.input_source)});
|
||||
.binding = xr_instance.string_to_path(k.input_source)});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1143,7 +1152,7 @@ void application::initialize_actions()
|
||||
|
||||
for (const auto & name: profile.input_sources)
|
||||
{
|
||||
xr_bindings.push_back({actions_by_name[name], string_to_path(name)});
|
||||
xr_bindings.push_back({actions_by_name[name], xr_instance.string_to_path(name)});
|
||||
}
|
||||
|
||||
try
|
||||
@@ -1163,7 +1172,7 @@ void application::initialize()
|
||||
{
|
||||
// LogLayersAndExtensions
|
||||
assert(!xr_instance);
|
||||
xr_extensions.clear();
|
||||
std::vector<std::string> xr_extensions;
|
||||
|
||||
// Required extensions
|
||||
xr_extensions.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME);
|
||||
@@ -1236,21 +1245,16 @@ void application::initialize()
|
||||
spdlog::info(" Orientation tracking: {}", (bool)properties.trackingProperties.orientationTracking);
|
||||
spdlog::info(" Position tracking: {}", (bool)properties.trackingProperties.positionTracking);
|
||||
|
||||
if (utils::contains(xr_extensions, XR_EXT_HAND_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemHandTrackingPropertiesEXT hand_tracking_properties = xr_system_id.hand_tracking_properties();
|
||||
spdlog::info(" Hand tracking support: {}", (bool)hand_tracking_properties.supportsHandTracking);
|
||||
hand_tracking_supported = hand_tracking_properties.supportsHandTracking;
|
||||
}
|
||||
spdlog::info(" Hand tracking support: {}", xr_system_id.hand_tracking_supported());
|
||||
|
||||
if (utils::contains(xr_extensions, XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))
|
||||
if (xr_instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_properties = xr_system_id.eye_gaze_interaction_properties();
|
||||
spdlog::info(" Eye gaze support: {}", (bool)eye_gaze_properties.supportsEyeGazeInteraction);
|
||||
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
|
||||
}
|
||||
|
||||
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
|
||||
if (xr_instance.has_extension(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
|
||||
{
|
||||
spdlog::info(" OpenXR post-processing extension support: true");
|
||||
openxr_post_processing_supported = true;
|
||||
@@ -1258,93 +1262,45 @@ void application::initialize()
|
||||
|
||||
switch (xr_system_id.passthrough_supported())
|
||||
{
|
||||
case xr::system::passthrough_type::no_passthrough:
|
||||
case xr::passthrough_type::none:
|
||||
spdlog::info(" Passthrough: not supported");
|
||||
break;
|
||||
case xr::system::passthrough_type::bw:
|
||||
case xr::passthrough_type::bw:
|
||||
spdlog::info(" Passthrough: black and white");
|
||||
break;
|
||||
case xr::system::passthrough_type::color:
|
||||
case xr::passthrough_type::color:
|
||||
spdlog::info(" Passthrough: color");
|
||||
break;
|
||||
}
|
||||
|
||||
spdlog::info(" Face tracker: {}", magic_enum::enum_name(xr_system_id.face_tracker_supported()));
|
||||
spdlog::info(" Body tracker: {}", magic_enum::enum_name(xr_system_id.body_tracker_supported()));
|
||||
|
||||
// Log view configurations and blend modes
|
||||
log_views();
|
||||
|
||||
initialize_vulkan();
|
||||
|
||||
xr_session = xr::session(xr_instance, xr_system_id, vk_instance, vk_physical_device, vk_device, vk_queue_family_index);
|
||||
|
||||
{
|
||||
auto spaces = xr_session.get_reference_spaces();
|
||||
spdlog::info("{} reference spaces", spaces.size());
|
||||
for (XrReferenceSpaceType i: spaces)
|
||||
spdlog::info(" {}", xr::to_string(i));
|
||||
}
|
||||
xr_session = xr::session(xr_instance, xr_system_id, vk_instance, vk_physical_device, vk_device, vk_queue, vk_queue_family_index);
|
||||
|
||||
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
|
||||
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
|
||||
|
||||
config.emplace(xr_system_id);
|
||||
|
||||
if (hand_tracking_supported)
|
||||
// HTC face tracker fails if created later
|
||||
// we can destroy it right away, it actually stores static handles
|
||||
if (xr_system_id.face_tracker_supported() == xr::face_tracker_type::htc)
|
||||
{
|
||||
left_hand = xr_session.create_hand_tracker(XR_HAND_LEFT_EXT);
|
||||
right_hand = xr_session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||
auto props = xr_system_id.htc_face_tracking_properties();
|
||||
xr::htc_face_tracker(xr_instance, xr_session, props.supportEyeFacialTracking, props.supportLipFacialTracking);
|
||||
}
|
||||
|
||||
if (utils::contains(xr_extensions, XR_FB_FACE_TRACKING2_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemFaceTrackingProperties2FB fb_face2_properties = xr_system_id.fb_face_tracking2_properties();
|
||||
spdlog::info(" FB face tracking support: {}", (bool)fb_face2_properties.supportsVisualFaceTracking);
|
||||
if (fb_face2_properties.supportsVisualFaceTracking)
|
||||
face_tracker.emplace<xr::fb_face_tracker2>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(face_tracker) && utils::contains(xr_extensions, XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemFacialTrackingPropertiesHTC htc_face_properties = xr_system_id.htc_face_tracking_properties();
|
||||
spdlog::info(" HTC eye tracking support: {}", (bool)htc_face_properties.supportEyeFacialTracking);
|
||||
spdlog::info(" HTC lip tracking support: {}", (bool)htc_face_properties.supportLipFacialTracking);
|
||||
if (htc_face_properties.supportEyeFacialTracking || htc_face_properties.supportLipFacialTracking)
|
||||
face_tracker.emplace<xr::htc_face_tracker>(xr_instance, xr_session, htc_face_properties.supportEyeFacialTracking, htc_face_properties.supportLipFacialTracking);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(face_tracker) && eye_gaze_supported)
|
||||
{
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
spdlog::info(" PICO face tracking support: true");
|
||||
face_tracker.emplace<xr::pico_face_tracker>(xr_instance, xr_session);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (utils::contains_all(xr_extensions, std::array{XR_FB_BODY_TRACKING_EXTENSION_NAME, XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME, XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME}))
|
||||
{
|
||||
XrSystemBodyTrackingPropertiesFB fb_body_properties = xr_system_id.fb_body_tracking_properties();
|
||||
spdlog::info(" FB body tracking support: {}", (bool)fb_body_properties.supportsBodyTracking);
|
||||
if (fb_body_properties.supportsBodyTracking)
|
||||
body_tracker.emplace<xr::fb_body_tracker>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(body_tracker) && utils::contains_all(xr_extensions, std::array{XR_HTC_PATH_ENUMERATION_EXTENSION_NAME, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME}))
|
||||
{
|
||||
spdlog::info(" HTC body tracking support: true");
|
||||
body_tracker.emplace<xr::htc_body_tracker>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(body_tracker) && utils::contains(xr_extensions, XR_BD_BODY_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemBodyTrackingPropertiesBD bd_body_properties = xr_system_id.bd_body_tracking_properties();
|
||||
spdlog::info(" PICO body tracking support: {}", (bool)bd_body_properties.supportsBodyTracking);
|
||||
if (bd_body_properties.supportsBodyTracking)
|
||||
body_tracker.emplace<xr::pico_body_tracker>(xr_instance, xr_session);
|
||||
auto spaces = xr_session.get_reference_spaces();
|
||||
spdlog::info("{} reference spaces", spaces.size());
|
||||
for (XrReferenceSpaceType i: spaces)
|
||||
spdlog::info(" {}", xr::to_string(i));
|
||||
}
|
||||
|
||||
vk::CommandPoolCreateInfo cmdpool_create_info;
|
||||
@@ -1881,13 +1837,6 @@ void application::poll_events()
|
||||
exit_requested = true;
|
||||
}
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: {
|
||||
if (auto * htc_body = std::get_if<xr::htc_body_tracker>(&body_tracker))
|
||||
{
|
||||
htc_body->update_active();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING:
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
|
||||
|
||||
+13
-82
@@ -28,14 +28,11 @@
|
||||
#include "utils/thread_safe.h"
|
||||
#include "vk/vk_allocator.h"
|
||||
#include "wifi_lock.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include "xr/fb_face_tracker2.h"
|
||||
#include "xr/hand_tracker.h"
|
||||
#include "xr/htc_body_tracker.h"
|
||||
#include "xr/htc_face_tracker.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#include "xr/pico_face_tracker.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/actionset.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/swapchain.h"
|
||||
#include "xr/system.h"
|
||||
#include <atomic>
|
||||
#include <boost/locale/generator.hpp>
|
||||
#include <boost/locale/gnu_gettext.hpp>
|
||||
@@ -126,12 +123,7 @@ class application : public singleton<application>
|
||||
xr::actionset xr_actionset;
|
||||
std::vector<std::tuple<XrAction, XrActionType, std::string>> actions;
|
||||
|
||||
bool hand_tracking_supported = false;
|
||||
xr::hand_tracker left_hand;
|
||||
xr::hand_tracker right_hand;
|
||||
|
||||
std::variant<std::monostate, xr::fb_face_tracker2, xr::htc_face_tracker, xr::pico_face_tracker> face_tracker;
|
||||
std::variant<std::monostate, xr::fb_body_tracker, xr::htc_body_tracker, xr::pico_body_tracker> body_tracker;
|
||||
std::vector<std::pair<XrPath, xr::space>> generic_trackers;
|
||||
|
||||
bool eye_gaze_supported = false;
|
||||
|
||||
@@ -141,7 +133,6 @@ class application : public singleton<application>
|
||||
bool session_focused = false;
|
||||
bool session_visible = false;
|
||||
bool debug_extensions_found = false;
|
||||
std::vector<std::string> xr_extensions;
|
||||
std::vector<const char *> vk_device_extensions;
|
||||
std::atomic<bool> exit_requested = false;
|
||||
std::filesystem::path config_path;
|
||||
@@ -271,16 +262,6 @@ public:
|
||||
return std::make_pair(position, orientation);
|
||||
}
|
||||
|
||||
static XrPath string_to_path(const std::string & s)
|
||||
{
|
||||
return instance().xr_instance.string_to_path(s);
|
||||
}
|
||||
|
||||
static std::string path_to_string(XrPath p)
|
||||
{
|
||||
return instance().xr_instance.path_to_string(p);
|
||||
}
|
||||
|
||||
void run();
|
||||
|
||||
static void push_scene(std::shared_ptr<scene>);
|
||||
@@ -351,16 +332,6 @@ public:
|
||||
// #endif
|
||||
}
|
||||
|
||||
static XrTime now()
|
||||
{
|
||||
return instance().xr_instance.now();
|
||||
}
|
||||
|
||||
static uint32_t queue_family_index()
|
||||
{
|
||||
return instance().vk_queue_family_index;
|
||||
}
|
||||
|
||||
static thread_safe<vk::raii::Queue> & get_queue()
|
||||
{
|
||||
return instance().vk_queue;
|
||||
@@ -376,26 +347,21 @@ public:
|
||||
return intent;
|
||||
}
|
||||
|
||||
static vk::raii::PhysicalDevice & get_physical_device()
|
||||
{
|
||||
return instance().vk_physical_device;
|
||||
}
|
||||
|
||||
static const vk::PhysicalDeviceProperties & get_physical_device_properties()
|
||||
{
|
||||
return instance().physical_device_properties;
|
||||
}
|
||||
|
||||
static vk::raii::Device & get_device()
|
||||
{
|
||||
return instance().vk_device;
|
||||
}
|
||||
|
||||
static vk::raii::Instance & get_vulkan_instance()
|
||||
{
|
||||
return instance().vk_instance;
|
||||
}
|
||||
|
||||
static xr::system & get_system()
|
||||
{
|
||||
return instance().xr_system_id;
|
||||
}
|
||||
|
||||
static vk::raii::PipelineCache & get_pipeline_cache()
|
||||
{
|
||||
return instance().pipeline_cache;
|
||||
@@ -416,21 +382,6 @@ public:
|
||||
return instance().last_scene_cpu_time;
|
||||
}
|
||||
|
||||
static bool get_hand_tracking_supported()
|
||||
{
|
||||
return instance().hand_tracking_supported;
|
||||
}
|
||||
|
||||
static bool get_face_tracking_supported()
|
||||
{
|
||||
return !std::holds_alternative<std::monostate>(instance().face_tracker);
|
||||
}
|
||||
|
||||
static bool get_body_tracking_supported()
|
||||
{
|
||||
return !std::holds_alternative<std::monostate>(instance().body_tracker);
|
||||
}
|
||||
|
||||
static bool get_eye_gaze_supported()
|
||||
{
|
||||
return instance().eye_gaze_supported;
|
||||
@@ -441,29 +392,9 @@ public:
|
||||
return instance().openxr_post_processing_supported;
|
||||
}
|
||||
|
||||
static xr::hand_tracker & get_left_hand()
|
||||
static auto & get_generic_trackers()
|
||||
{
|
||||
return instance().left_hand;
|
||||
}
|
||||
|
||||
static xr::hand_tracker & get_right_hand()
|
||||
{
|
||||
return instance().right_hand;
|
||||
}
|
||||
|
||||
static auto & get_face_tracker()
|
||||
{
|
||||
return instance().face_tracker;
|
||||
}
|
||||
|
||||
static auto & get_body_tracker()
|
||||
{
|
||||
return instance().body_tracker;
|
||||
}
|
||||
|
||||
static const std::vector<std::string> & get_xr_extensions()
|
||||
{
|
||||
return instance().xr_extensions;
|
||||
return instance().generic_trackers;
|
||||
}
|
||||
|
||||
static const std::vector<const char *> & get_vk_device_extensions()
|
||||
|
||||
+11
-47
@@ -82,6 +82,8 @@ bool configuration::check_feature(feature f) const
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
auto & system = application::get_system();
|
||||
|
||||
auto it = features.find(f);
|
||||
if (it == features.end())
|
||||
return false;
|
||||
@@ -94,7 +96,7 @@ bool configuration::check_feature(feature f) const
|
||||
case feature::microphone:
|
||||
break;
|
||||
case feature::hand_tracking:
|
||||
if (not application::get_hand_tracking_supported())
|
||||
if (not system.hand_tracking_supported())
|
||||
return false;
|
||||
break;
|
||||
case feature::eye_gaze:
|
||||
@@ -102,50 +104,12 @@ bool configuration::check_feature(feature f) const
|
||||
return false;
|
||||
break;
|
||||
case feature::face_tracking:
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
if (not std::holds_alternative<xr::htc_face_tracker>(application::get_face_tracker()))
|
||||
return false;
|
||||
break;
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
if (not std::holds_alternative<xr::pico_face_tracker>(application::get_face_tracker()))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
if (not std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker()))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (system.face_tracker_supported() == xr::face_tracker_type::none)
|
||||
return false;
|
||||
break;
|
||||
case feature::body_tracking:
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::meta_quest_3:
|
||||
case model::meta_quest_3s:
|
||||
if (not std::holds_alternative<xr::fb_body_tracker>(application::get_body_tracker()))
|
||||
return false;
|
||||
break;
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_xr_elite:
|
||||
case model::htc_vive_focus_vision:
|
||||
if (not std::holds_alternative<xr::htc_body_tracker>(application::get_body_tracker()))
|
||||
return false;
|
||||
break;
|
||||
case model::pico_neo_3:
|
||||
case model::pico_4:
|
||||
case model::pico_4s:
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
if (not std::holds_alternative<xr::pico_body_tracker>(application::get_body_tracker()))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (system.body_tracker_supported() == xr::body_tracker_type::none)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -181,8 +145,8 @@ void configuration::set_feature(feature f, bool state)
|
||||
|
||||
configuration::configuration(xr::system & system)
|
||||
{
|
||||
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
|
||||
features[feature::hand_tracking] = application::get_hand_tracking_supported();
|
||||
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
|
||||
features[feature::hand_tracking] = system.hand_tracking_supported();
|
||||
try
|
||||
{
|
||||
simdjson::dom::parser parser;
|
||||
@@ -243,7 +207,7 @@ configuration::configuration(xr::system & system)
|
||||
features[i] = val.get_bool();
|
||||
}
|
||||
|
||||
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
|
||||
if (system.passthrough_supported() == xr::passthrough_type::none)
|
||||
passthrough_enabled = false;
|
||||
|
||||
if (auto val = root["override_foveation_enable"]; val.is_bool())
|
||||
@@ -269,7 +233,7 @@ configuration::configuration(xr::system & system)
|
||||
resolution_scale = 1.4;
|
||||
sgsr = {};
|
||||
openxr_post_processing = {};
|
||||
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
|
||||
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "shard_accumulator.h"
|
||||
#include "application.h"
|
||||
#include "scenes/stream.h"
|
||||
#include "scenes/stream.h" // IWYU pragma: keep
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "xr/instance.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
@@ -63,10 +63,10 @@ static bool is_complete(const shard_set & shards)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<uint16_t> shard_set::insert(data_shard && shard)
|
||||
std::optional<uint16_t> shard_set::insert(data_shard && shard, xr::instance & instance)
|
||||
{
|
||||
if (empty())
|
||||
feedback.received_first_packet = application::now();
|
||||
feedback.received_first_packet = instance.now();
|
||||
|
||||
auto idx = shard.shard_idx;
|
||||
if (idx >= data.size())
|
||||
@@ -121,12 +121,12 @@ void shard_accumulator::push_shard(video_stream_data_shard && shard)
|
||||
}
|
||||
else if (frame_diff == 0)
|
||||
{
|
||||
auto shard_idx = current.insert(std::move(shard));
|
||||
auto shard_idx = current.insert(std::move(shard), instance);
|
||||
try_submit_frame(shard_idx);
|
||||
}
|
||||
else if (frame_diff == 1)
|
||||
{
|
||||
next.insert(std::move(shard));
|
||||
next.insert(std::move(shard), instance);
|
||||
if (is_complete(next))
|
||||
{
|
||||
debug_why_not_sent(current);
|
||||
@@ -191,7 +191,7 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
|
||||
if (not frame_complete)
|
||||
return;
|
||||
|
||||
current.feedback.received_last_packet = application::now();
|
||||
current.feedback.received_last_packet = instance.now();
|
||||
current.feedback.sent_to_decoder = current.feedback.received_last_packet;
|
||||
data_shard::timing_info_t timing_info = data_shards.back()->timing_info.value_or(data_shard::timing_info_t{});
|
||||
current.feedback.encode_begin = timing_info.encode_begin;
|
||||
@@ -216,7 +216,7 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
|
||||
void shard_accumulator::send_feedback(wivrn::from_headset::feedback & feedback)
|
||||
{
|
||||
if (not feedback.received_last_packet)
|
||||
feedback.received_first_packet = application::now();
|
||||
feedback.received_first_packet = instance.now();
|
||||
auto scene = weak_scene.lock();
|
||||
if (scene)
|
||||
scene->send_feedback(feedback);
|
||||
|
||||
@@ -34,6 +34,11 @@ using decoder_impl = ::wivrn::ffmpeg::decoder;
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace xr
|
||||
{
|
||||
class instance;
|
||||
}
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
@@ -50,7 +55,7 @@ public:
|
||||
void reset(uint64_t frame_index);
|
||||
bool empty() const;
|
||||
|
||||
std::optional<uint16_t> insert(data_shard &&);
|
||||
std::optional<uint16_t> insert(data_shard &&, xr::instance & instance);
|
||||
|
||||
wivrn::from_headset::feedback feedback{};
|
||||
|
||||
@@ -70,11 +75,13 @@ private:
|
||||
shard_set current;
|
||||
shard_set next;
|
||||
std::weak_ptr<scenes::stream> weak_scene;
|
||||
xr::instance & instance;
|
||||
|
||||
public:
|
||||
explicit shard_accumulator(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
xr::instance & instance,
|
||||
const wivrn::to_headset::video_stream_description::item & description,
|
||||
float fps,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
@@ -82,7 +89,8 @@ public:
|
||||
decoder(std::make_shared<decoder_impl>(device, physical_device, description, fps, stream_index, scene, this)),
|
||||
current(stream_index),
|
||||
next(stream_index),
|
||||
weak_scene(scene)
|
||||
weak_scene(scene),
|
||||
instance(instance)
|
||||
{
|
||||
next.reset(1);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "application.h"
|
||||
#include "utils/alignment.h"
|
||||
#include "vk/allocation.h"
|
||||
#include <fastgltf/tools.hpp>
|
||||
@@ -115,10 +114,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
buffer_allocation copy_to_gpu()
|
||||
buffer_allocation copy_to_gpu(vk::raii::Device & device)
|
||||
{
|
||||
buffer_allocation gpu_buffer{
|
||||
application::get_device(),
|
||||
device,
|
||||
vk::BufferCreateInfo{
|
||||
.size = bytes.size(),
|
||||
.usage = usage},
|
||||
|
||||
@@ -345,9 +345,9 @@ imgui_context::imgui_context(
|
||||
|
||||
ImGui_ImplVulkan_InitInfo init_info = {
|
||||
.Instance = *application::get_vulkan_instance(),
|
||||
.PhysicalDevice = *application::get_physical_device(),
|
||||
.Device = *application::get_device(),
|
||||
.QueueFamily = application::queue_family_index(),
|
||||
.PhysicalDevice = *physical_device,
|
||||
.Device = *device,
|
||||
.QueueFamily = queue_family_index,
|
||||
.Queue = *queue.get_unsafe(),
|
||||
.RenderPass = *renderpass,
|
||||
.MinImageCount = 2,
|
||||
@@ -718,7 +718,7 @@ void imgui_context::new_frame(XrTime display_time)
|
||||
ImPlot::SetCurrentContext(plot_context);
|
||||
|
||||
if (last_display_time)
|
||||
io.DeltaTime = std::min((display_time - last_display_time) * 1e-9f, 0.0166f);
|
||||
io.DeltaTime = std::clamp((display_time - last_display_time) * 1e-9f, 0.001f, 0.0166f);
|
||||
last_display_time = display_time;
|
||||
|
||||
// Uses the window list from last frame
|
||||
|
||||
@@ -785,7 +785,7 @@ entt::registry scene_loader::operator()(const std::filesystem::path & gltf_path)
|
||||
|
||||
// Copy the staging buffer to the GPU
|
||||
spdlog::debug("Uploading scene data ({} bytes) to GPU memory", staging_buffer.size());
|
||||
auto buffer = std::make_shared<buffer_allocation>(staging_buffer.copy_to_gpu());
|
||||
auto buffer = std::make_shared<buffer_allocation>(staging_buffer.copy_to_gpu(device));
|
||||
|
||||
for (auto & i: materials)
|
||||
i->buffer = buffer;
|
||||
|
||||
+1
-3
@@ -51,8 +51,6 @@ scene::scene(key, const meta & current_meta, std::span<const vk::Format> support
|
||||
queue_family_index(application::instance().vk_queue_family_index),
|
||||
current_meta(current_meta)
|
||||
{
|
||||
passthrough_supported = system.passthrough_supported();
|
||||
|
||||
swapchain_format = vk::Format::eUndefined;
|
||||
spdlog::info("Supported swapchain formats:");
|
||||
|
||||
@@ -443,7 +441,7 @@ std::pair<entt::entity, components::node &> scene::load_gltf(const std::filesyst
|
||||
node.layer_mask = layer_mask;
|
||||
|
||||
assert(renderer);
|
||||
scene_loader loader(device, physical_device, queue, application::queue_family_index(), renderer->get_default_material());
|
||||
scene_loader loader(device, physical_device, queue, queue_family_index, renderer->get_default_material());
|
||||
|
||||
loader.add_prefab(world, loader(path), entity);
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ public:
|
||||
protected:
|
||||
vk::Format swapchain_format;
|
||||
vk::Format depth_format;
|
||||
xr::system::passthrough_type passthrough_supported;
|
||||
bool composition_layer_depth_test_supported;
|
||||
bool composition_layer_color_scale_bias_supported;
|
||||
|
||||
|
||||
+17
-22
@@ -649,10 +649,10 @@ void scenes::lobby::render(const XrFrameState & frame_state)
|
||||
if (!new_gui_position and head_position)
|
||||
new_gui_position = check_recenter_action(frame_state.predictedDisplayTime, head_position->first);
|
||||
|
||||
if (application::get_hand_tracking_supported())
|
||||
if (left_hand and right_hand)
|
||||
{
|
||||
auto left = application::get_left_hand().locate(world_space, frame_state.predictedDisplayTime);
|
||||
auto right = application::get_right_hand().locate(world_space, frame_state.predictedDisplayTime);
|
||||
auto left = left_hand->locate(world_space, frame_state.predictedDisplayTime);
|
||||
auto right = right_hand->locate(world_space, frame_state.predictedDisplayTime);
|
||||
|
||||
hand_model::apply(world, left, right);
|
||||
|
||||
@@ -798,7 +798,7 @@ void scenes::lobby::on_focused()
|
||||
// assert(std::ranges::all_of(views, [height](const XrViewConfigurationView & view) { return view.recommendedImageRectHeight == height; }));
|
||||
|
||||
renderer.emplace(device, physical_device, queue, commandpool);
|
||||
loader.emplace(device, physical_device, queue, application::queue_family_index(), renderer->get_default_material());
|
||||
loader.emplace(device, physical_device, queue, queue_family_index, renderer->get_default_material());
|
||||
|
||||
lobby_entity = load_gltf("ground.gltf", layer_lobby).first;
|
||||
|
||||
@@ -835,12 +835,6 @@ void scenes::lobby::on_focused()
|
||||
xyz_axes_right_controller = load_gltf("xyz-arrows.glb", layer_controllers).first;
|
||||
#endif
|
||||
|
||||
if (application::get_hand_tracking_supported())
|
||||
{
|
||||
hand_model::add_hand(*this, XR_HAND_LEFT_EXT, "left-hand.glb", layer_controllers);
|
||||
hand_model::add_hand(*this, XR_HAND_RIGHT_EXT, "right-hand.glb", layer_controllers);
|
||||
}
|
||||
|
||||
recenter_left_action = get_action("recenter_left").first;
|
||||
recenter_right_action = get_action("recenter_right").first;
|
||||
|
||||
@@ -862,21 +856,19 @@ void scenes::lobby::on_focused()
|
||||
.haptic_output = get_action("right_haptic").first,
|
||||
},
|
||||
};
|
||||
if (auto & hand = application::get_left_hand())
|
||||
|
||||
if (system.hand_tracking_supported())
|
||||
{
|
||||
imgui_inputs.push_back(
|
||||
{
|
||||
.hand = &hand,
|
||||
});
|
||||
}
|
||||
if (auto & hand = application::get_right_hand())
|
||||
{
|
||||
imgui_inputs.push_back(
|
||||
{
|
||||
.hand = &hand,
|
||||
});
|
||||
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
|
||||
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||
hand_model::add_hand(*this, XR_HAND_LEFT_EXT, "left-hand.glb", layer_controllers);
|
||||
hand_model::add_hand(*this, XR_HAND_RIGHT_EXT, "right-hand.glb", layer_controllers);
|
||||
imgui_inputs.push_back({.hand = &*left_hand});
|
||||
imgui_inputs.push_back({.hand = &*right_hand});
|
||||
}
|
||||
|
||||
face_tracker = xr::make_face_tracker(instance, system, session);
|
||||
|
||||
// 0.4mm / pixel
|
||||
std::vector<imgui_context::viewport> vps{
|
||||
{
|
||||
@@ -977,6 +969,9 @@ void scenes::lobby::on_unfocused()
|
||||
world.clear(); // Must be cleared before the renderer so that the descriptor sets are freed before their pools
|
||||
|
||||
input.reset();
|
||||
left_hand.reset();
|
||||
right_hand.reset();
|
||||
face_tracker.emplace<std::monostate>();
|
||||
|
||||
loader.reset();
|
||||
renderer.reset();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_discover.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/face_tracker.h"
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
@@ -66,6 +67,11 @@ class lobby : public scene_impl<lobby>
|
||||
|
||||
std::optional<imgui_context> imgui_ctx;
|
||||
|
||||
std::optional<xr::hand_tracker> left_hand;
|
||||
std::optional<xr::hand_tracker> right_hand;
|
||||
|
||||
xr::face_tracker face_tracker;
|
||||
|
||||
std::string selected_item;
|
||||
std::unique_ptr<asset> license;
|
||||
|
||||
|
||||
+30
-25
@@ -34,6 +34,7 @@
|
||||
#include "utils/overloaded.h"
|
||||
#include "utils/ranges.h"
|
||||
#include "version.h"
|
||||
#include "xr/body_tracker.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
@@ -889,7 +890,7 @@ void scenes::lobby::gui_settings()
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
{
|
||||
ImGui::BeginDisabled(not application::get_hand_tracking_supported());
|
||||
ImGui::BeginDisabled(not system.hand_tracking_supported());
|
||||
bool enabled = config.check_feature(feature::hand_tracking);
|
||||
if (ImGui::Checkbox(_S("Enable hand tracking"), &enabled))
|
||||
{
|
||||
@@ -913,7 +914,7 @@ void scenes::lobby::gui_settings()
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
{
|
||||
ImGui::BeginDisabled(not application::get_face_tracking_supported());
|
||||
ImGui::BeginDisabled(std::holds_alternative<std::monostate>(face_tracker));
|
||||
bool enabled = config.check_feature(feature::face_tracking);
|
||||
if (ImGui::Checkbox(_S("Enable face tracking"), &enabled))
|
||||
{
|
||||
@@ -925,8 +926,9 @@ void scenes::lobby::gui_settings()
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
|
||||
auto body_tracker = system.body_tracker_supported();
|
||||
{
|
||||
ImGui::BeginDisabled(not application::get_body_tracking_supported());
|
||||
ImGui::BeginDisabled(body_tracker == xr::body_tracker_type::none);
|
||||
bool enabled = config.check_feature(feature::body_tracking);
|
||||
if (ImGui::Checkbox(_S("Enable body tracking"), &enabled))
|
||||
{
|
||||
@@ -941,19 +943,14 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::visit(utils::overloaded{
|
||||
[](auto &) {},
|
||||
[this](xr::fb_body_tracker &) {
|
||||
imgui_ctx->tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
|
||||
},
|
||||
},
|
||||
application::get_body_tracker());
|
||||
if (body_tracker == xr::body_tracker_type::fb)
|
||||
imgui_ctx->tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
|
||||
}
|
||||
}
|
||||
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
if (std::holds_alternative<xr::fb_body_tracker>(application::get_body_tracker()))
|
||||
if (body_tracker == xr::body_tracker_type::fb)
|
||||
{
|
||||
ImGui::BeginDisabled(not config.check_feature(feature::body_tracking));
|
||||
ImGui::Indent();
|
||||
@@ -979,7 +976,7 @@ void scenes::lobby::gui_settings()
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::BeginDisabled(passthrough_supported == xr::system::passthrough_type::no_passthrough);
|
||||
ImGui::BeginDisabled(system.passthrough_supported() == xr::passthrough_type::none);
|
||||
if (ImGui::Checkbox(_S("Enable video passthrough in lobby"), &config.passthrough_enabled))
|
||||
{
|
||||
setup_passthrough();
|
||||
@@ -1311,12 +1308,12 @@ void scenes::lobby::gui_first_run()
|
||||
item{
|
||||
.f = feature::face_tracking,
|
||||
.text = _S("Enable face tracking?"),
|
||||
.supported = application::get_face_tracking_supported(),
|
||||
.supported = not std::holds_alternative<std::monostate>(face_tracker),
|
||||
},
|
||||
item{
|
||||
.f = feature::body_tracking,
|
||||
.text = _S("Enable body tracking?"),
|
||||
.supported = application::get_body_tracking_supported(),
|
||||
.supported = system.body_tracker_supported() != xr::body_tracker_type::none,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1646,11 +1643,22 @@ static auto face_weights()
|
||||
return res;
|
||||
}
|
||||
|
||||
static const char * get_face_icon(XrTime predicted_display_time)
|
||||
static const char * get_face_icon(XrTime predicted_display_time, xr::face_tracker & face_tracker)
|
||||
{
|
||||
static const auto w = face_weights();
|
||||
wivrn::from_headset::tracking::fb_face2 expression;
|
||||
std::get<xr::fb_face_tracker2>(application::get_face_tracker()).get_weights(predicted_display_time, expression);
|
||||
const char * result = nullptr;
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](xr::htc_face_tracker &) { result = ICON_FA_FACE_SMILE_WINK; },
|
||||
[&](auto & ft) {
|
||||
ft.get_weights(predicted_display_time, expression);
|
||||
},
|
||||
},
|
||||
face_tracker);
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (not expression.is_valid)
|
||||
return ICON_FA_FACE_MEH;
|
||||
@@ -1693,7 +1701,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
.icon_disabled = ICON_FA_MICROPHONE_SLASH,
|
||||
});
|
||||
|
||||
if (application::get_hand_tracking_supported())
|
||||
if (system.hand_tracking_supported())
|
||||
{
|
||||
items.push_back({
|
||||
.f = feature::hand_tracking,
|
||||
@@ -1714,21 +1722,18 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
});
|
||||
}
|
||||
|
||||
if (application::get_face_tracking_supported())
|
||||
if (not std::holds_alternative<std::monostate>(face_tracker))
|
||||
{
|
||||
const char * icon_enabled = std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker())
|
||||
? get_face_icon(predicted_display_time)
|
||||
: ICON_FA_FACE_KISS_WINK_HEART;
|
||||
items.push_back({
|
||||
.f = feature::face_tracking,
|
||||
.tooltip_enabled = _("Face tracking is enabled"),
|
||||
.tooltip_disabled = _("Face tracking is disabled"),
|
||||
.icon_enabled = icon_enabled,
|
||||
.icon_enabled = get_face_icon(predicted_display_time, face_tracker),
|
||||
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
|
||||
});
|
||||
}
|
||||
|
||||
if (application::get_body_tracking_supported())
|
||||
if (system.body_tracker_supported() != xr::body_tracker_type::none)
|
||||
{
|
||||
items.push_back({
|
||||
.f = feature::body_tracking,
|
||||
@@ -1802,7 +1807,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
if (*status.charge > 0.995)
|
||||
icon_nr = 5;
|
||||
else
|
||||
icon_nr = application::now() / 500'000'000 % 5;
|
||||
icon_nr = instance.now() / 500'000'000 % 5;
|
||||
}
|
||||
else
|
||||
icon_nr = std::round((*status.charge) * 4);
|
||||
@@ -2031,7 +2036,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
|
||||
if (not is_gui_visible(*imgui_ctx, predicted_display_time))
|
||||
{
|
||||
if (application::get_hand_tracking_supported())
|
||||
if (system.hand_tracking_supported())
|
||||
display_recentering_tip(*imgui_ctx, _("Press the grip button or put your palm up\nto move the main window"));
|
||||
else
|
||||
display_recentering_tip(*imgui_ctx, _("Press the grip button to move the main window"));
|
||||
|
||||
+39
-36
@@ -17,11 +17,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "constants.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include "xr/body_tracker.h"
|
||||
#include "xr/face_tracker.h"
|
||||
#include "xr/fb_face_tracker2.h"
|
||||
#include "xr/htc_body_tracker.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#include "xr/space.h"
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
@@ -256,39 +254,42 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
|
||||
if (config.check_feature(feature::face_tracking))
|
||||
{
|
||||
info.face_tracking = std::visit(utils::overloaded{
|
||||
[](std::monostate &) {
|
||||
return from_headset::face_type::none;
|
||||
},
|
||||
[](xr::fb_face_tracker2 &) {
|
||||
return from_headset::face_type::fb2;
|
||||
},
|
||||
[](xr::htc_face_tracker &) {
|
||||
return from_headset::face_type::htc;
|
||||
},
|
||||
[](xr::pico_face_tracker &) {
|
||||
return from_headset::face_type::fb2;
|
||||
},
|
||||
},
|
||||
application::get_face_tracker());
|
||||
switch (self->system.face_tracker_supported())
|
||||
{
|
||||
case xr::face_tracker_type::none:
|
||||
info.face_tracking = from_headset::face_type::none;
|
||||
break;
|
||||
case xr::face_tracker_type::fb:
|
||||
case xr::face_tracker_type::pico:
|
||||
info.face_tracking = from_headset::face_type::fb2;
|
||||
break;
|
||||
case xr::face_tracker_type::htc:
|
||||
info.face_tracking = from_headset::face_type::htc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
info.num_generic_trackers = 0;
|
||||
if (config.check_feature(feature::body_tracking))
|
||||
{
|
||||
info.num_generic_trackers = std::visit(utils::overloaded{
|
||||
[&](std::monostate &) {
|
||||
return size_t(0);
|
||||
},
|
||||
[&](auto & b) {
|
||||
return b.count();
|
||||
},
|
||||
},
|
||||
application::get_body_tracker());
|
||||
switch (self->system.body_tracker_supported())
|
||||
{
|
||||
case xr::body_tracker_type::none:
|
||||
break;
|
||||
case xr::body_tracker_type::fb:
|
||||
info.num_generic_trackers = xr::fb_body_tracker::get_whitelisted_joints(config.fb_lower_body, config.fb_hip).size();
|
||||
break;
|
||||
case xr::body_tracker_type::htc:
|
||||
info.num_generic_trackers = application::get_generic_trackers().size();
|
||||
break;
|
||||
case xr::body_tracker_type::pico:
|
||||
info.num_generic_trackers = xr::pico_body_tracker::joint_whitelist.size();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
|
||||
info.passthrough = self->system.passthrough_supported() != xr::system::passthrough_type::no_passthrough;
|
||||
info.passthrough = self->system.passthrough_supported() != xr::passthrough_type::none;
|
||||
info.system_name = std::string(self->system.properties().systemName);
|
||||
|
||||
audio::get_audio_description(info);
|
||||
@@ -359,7 +360,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
{
|
||||
self->haptics_actions.emplace(id, haptics_action{
|
||||
.action = action.first,
|
||||
.path = application::string_to_path(path),
|
||||
.path = self->instance.string_to_path(path),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -390,7 +391,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
|
||||
void scenes::stream::on_focused()
|
||||
{
|
||||
gui_status_last_change = application::now();
|
||||
gui_status_last_change = instance.now();
|
||||
|
||||
auto views = system.view_configuration_views(viewconfig);
|
||||
// stream_view = override_view(views[0], guess_model());
|
||||
@@ -398,7 +399,7 @@ void scenes::stream::on_focused()
|
||||
height = views[0].recommendedImageRectHeight;
|
||||
|
||||
renderer.emplace(device, physical_device, queue, commandpool);
|
||||
loader.emplace(device, physical_device, queue, application::queue_family_index(), renderer->get_default_material());
|
||||
loader.emplace(device, physical_device, queue, queue_family_index, renderer->get_default_material());
|
||||
|
||||
std::string profile = controller_name();
|
||||
input.emplace(
|
||||
@@ -493,6 +494,8 @@ void scenes::stream::on_unfocused()
|
||||
loader.reset();
|
||||
renderer.reset();
|
||||
clear_swapchains();
|
||||
left_hand.reset();
|
||||
right_hand.reset();
|
||||
|
||||
imgui_ctx.reset();
|
||||
swapchain_imgui = xr::swapchain();
|
||||
@@ -523,7 +526,7 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
|
||||
{
|
||||
if (decoder != decoders[stream].decoder.get())
|
||||
return;
|
||||
handle->feedback.received_from_decoder = application::now();
|
||||
handle->feedback.received_from_decoder = instance.now();
|
||||
std::swap(handle, decoders[stream].latest_frames[handle->feedback.frame_index % decoders[stream].latest_frames.size()]);
|
||||
}
|
||||
|
||||
@@ -532,7 +535,7 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
|
||||
}))
|
||||
{
|
||||
state_ = state::streaming;
|
||||
spdlog::info("Stream scene ready at t={}", application::now());
|
||||
spdlog::info("Stream scene ready at t={}", instance.now());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,7 +930,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
if (not blit_handle or not *i.blit_pipeline)
|
||||
continue;
|
||||
|
||||
blit_handle->feedback.blitted = application::now();
|
||||
blit_handle->feedback.blitted = instance.now();
|
||||
if (blit_handle->feedback.blitted - blit_handle->feedback.received_from_decoder > 1'000'000'000)
|
||||
state_ = stream::state::stalled;
|
||||
++blit_handle->feedback.times_displayed;
|
||||
@@ -1362,7 +1365,7 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
||||
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
|
||||
|
||||
decoders.push_back(accumulator_images{
|
||||
.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, description.fps, shared_from_this(), stream_index),
|
||||
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, item, description.fps, shared_from_this(), stream_index),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ private:
|
||||
std::thread network_thread;
|
||||
thread_safe<to_headset::tracking_control> tracking_control{};
|
||||
std::array<std::atomic<interaction_profile>, 2> interaction_profiles; // left and right hand
|
||||
std::atomic<bool> interaction_profile_changed = false;
|
||||
std::atomic<bool> recenter_requested = false;
|
||||
std::atomic<XrDuration> display_time_phase = 0;
|
||||
std::atomic<XrDuration> display_time_period = 0;
|
||||
@@ -129,6 +130,8 @@ private:
|
||||
|
||||
std::optional<audio> audio_handle;
|
||||
|
||||
std::optional<xr::hand_tracker> left_hand;
|
||||
std::optional<xr::hand_tracker> right_hand;
|
||||
std::optional<input_profile> input;
|
||||
static inline const uint32_t layer_controllers = 1 << 0;
|
||||
static inline const uint32_t layer_rays = 1 << 1;
|
||||
|
||||
@@ -645,6 +645,19 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
break;
|
||||
}
|
||||
imgui_ctx->set_controllers_enabled(interactable);
|
||||
if (interactable)
|
||||
{
|
||||
if (system.hand_tracking_supported())
|
||||
{
|
||||
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
|
||||
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
left_hand.reset();
|
||||
right_hand.reset();
|
||||
}
|
||||
|
||||
if (gui_status != last_gui_status)
|
||||
{
|
||||
@@ -876,10 +889,10 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
bool hide_left_controller = false;
|
||||
bool hide_right_controller = false;
|
||||
|
||||
if (application::get_hand_tracking_supported())
|
||||
if (left_hand and right_hand)
|
||||
{
|
||||
auto left = application::get_left_hand().locate(world_space, predicted_display_time);
|
||||
auto right = application::get_right_hand().locate(world_space, predicted_display_time);
|
||||
auto left = left_hand->locate(world_space, predicted_display_time);
|
||||
auto right = right_hand->locate(world_space, predicted_display_time);
|
||||
|
||||
if (left and xr::hand_tracker::check_flags(*left, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
|
||||
hide_left_controller = true;
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
#include "stream.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/body_tracker.h"
|
||||
#include "xr/face_tracker.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <magic_enum.hpp>
|
||||
#include <ranges>
|
||||
#include <spdlog/spdlog.h>
|
||||
@@ -377,7 +380,6 @@ void scenes::stream::tracking()
|
||||
std::vector<from_headset::tracking> tracking;
|
||||
std::vector<from_headset::tracking> tracking_pool; // pre-allocated objects
|
||||
std::vector<from_headset::hand_tracking> hands;
|
||||
std::array<bool, 2> should_skip_simple_controllers{};
|
||||
std::vector<from_headset::body_tracking> body;
|
||||
std::vector<XrView> views;
|
||||
|
||||
@@ -385,31 +387,14 @@ void scenes::stream::tracking()
|
||||
std::vector<serialization_packet> packets;
|
||||
|
||||
const bool hand_tracking = config.check_feature(feature::hand_tracking);
|
||||
std::optional<xr::hand_tracker> left_hand;
|
||||
std::optional<xr::hand_tracker> right_hand;
|
||||
|
||||
const bool face_tracking = config.check_feature(feature::face_tracking);
|
||||
auto & face_tracker = application::get_face_tracker();
|
||||
if (face_tracking)
|
||||
{
|
||||
// We can't start the face tracking on application initialisation like we do for
|
||||
// other face trackers due to a Pico runtime bug where face tracking freezes when
|
||||
// the headset is taken off or the application is quit.
|
||||
if (auto * face_pico = std::get_if<xr::pico_face_tracker>(&face_tracker))
|
||||
face_pico->start();
|
||||
}
|
||||
xr::face_tracker face_tracker;
|
||||
|
||||
const bool body_tracking = config.check_feature(feature::body_tracking);
|
||||
auto & body_tracker = application::get_body_tracker();
|
||||
if (body_tracking)
|
||||
{
|
||||
if (auto * body_fb = std::get_if<xr::fb_body_tracker>(&body_tracker))
|
||||
{
|
||||
// TODO maybe handle reconnection better, if the settings are changed since
|
||||
// last connection to running server, the tracker count will mismatch and
|
||||
// stuff might break
|
||||
body_fb->stop();
|
||||
body_fb->start(config.fb_lower_body, config.fb_hip);
|
||||
}
|
||||
}
|
||||
xr::body_tracker body_tracker;
|
||||
|
||||
locate_spaces_functor locate_spaces{instance, world_space};
|
||||
|
||||
@@ -434,6 +419,49 @@ void scenes::stream::tracking()
|
||||
int samples = 0;
|
||||
|
||||
auto control = *tracking_control.lock();
|
||||
bool interaction_profile_changed = this->interaction_profile_changed.exchange(false);
|
||||
|
||||
if (control.enabled[size_t(tid::left_hand)])
|
||||
{
|
||||
if (not left_hand and system.hand_tracking_supported())
|
||||
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
|
||||
}
|
||||
else
|
||||
left_hand.reset();
|
||||
|
||||
if (control.enabled[size_t(tid::right_hand)])
|
||||
{
|
||||
if (not right_hand and system.hand_tracking_supported())
|
||||
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||
}
|
||||
else
|
||||
right_hand.reset();
|
||||
|
||||
if (face_tracking and control.enabled[size_t(tid::face)])
|
||||
{
|
||||
if (std::holds_alternative<std::monostate>(face_tracker))
|
||||
face_tracker = xr::make_face_tracker(instance, system, session);
|
||||
}
|
||||
else
|
||||
face_tracker.emplace<std::monostate>();
|
||||
|
||||
if (body_tracking and control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
if (std::holds_alternative<std::monostate>(body_tracker))
|
||||
body_tracker = xr::make_body_tracker(
|
||||
instance,
|
||||
system,
|
||||
session,
|
||||
application::get_generic_trackers(),
|
||||
config.fb_lower_body,
|
||||
config.fb_hip);
|
||||
}
|
||||
else
|
||||
body_tracker.emplace<std::monostate>();
|
||||
|
||||
if (interaction_profile_changed)
|
||||
if (auto htc = std::get_if<xr::htc_body_tracker>(&body_tracker))
|
||||
htc->update_active();
|
||||
|
||||
XrDuration prediction = std::clamp<XrDuration>(control.max_offset.count(), 0, 80'000'000);
|
||||
auto period = std::max<XrDuration>(display_time_period.load(), 1'000'000);
|
||||
@@ -465,9 +493,9 @@ void scenes::stream::tracking()
|
||||
(Δt == 0 or Δt >= prediction - 2 * period))
|
||||
{
|
||||
last_hand_sample = t0;
|
||||
if (control.enabled[size_t(tid::left_hand)])
|
||||
if (left_hand)
|
||||
{
|
||||
auto joints = locate_hands(application::get_left_hand(), world_space, t0 + Δt);
|
||||
auto joints = locate_hands(*left_hand, world_space, t0 + Δt);
|
||||
hands.emplace_back(
|
||||
t0,
|
||||
t0 + Δt,
|
||||
@@ -475,9 +503,9 @@ void scenes::stream::tracking()
|
||||
joints);
|
||||
}
|
||||
|
||||
if (control.enabled[size_t(tid::right_hand)])
|
||||
if (right_hand)
|
||||
{
|
||||
auto joints = locate_hands(application::get_right_hand(), world_space, t0 + Δt);
|
||||
auto joints = locate_hands(*right_hand, world_space, t0 + Δt);
|
||||
hands.emplace_back(
|
||||
t0,
|
||||
t0 + Δt,
|
||||
@@ -494,37 +522,33 @@ void scenes::stream::tracking()
|
||||
}
|
||||
locate_spaces.resolve(session, t0 + Δt, packet.device_poses);
|
||||
|
||||
if (body_tracking)
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](auto & b) {
|
||||
if (t0 >= last_body_sample + period and
|
||||
(Δt == 0 or Δt >= prediction - 2 * period))
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](auto & b) {
|
||||
if (t0 >= last_body_sample + period and
|
||||
(Δt == 0 or Δt >= prediction - 2 * period))
|
||||
{
|
||||
last_body_sample = t0;
|
||||
if (control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
last_body_sample = t0;
|
||||
if (control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
body.push_back(from_headset::body_tracking{
|
||||
.production_timestamp = t0,
|
||||
.timestamp = t0 + Δt,
|
||||
.poses = b.locate_spaces(t0 + Δt, world_space),
|
||||
});
|
||||
}
|
||||
body.push_back(from_headset::body_tracking{
|
||||
.production_timestamp = t0,
|
||||
.timestamp = t0 + Δt,
|
||||
.poses = b.locate_spaces(t0 + Δt, world_space),
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
body_tracker);
|
||||
}
|
||||
},
|
||||
},
|
||||
body_tracker);
|
||||
|
||||
if (face_tracking && control.enabled[size_t(tid::face)])
|
||||
{
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](auto & ft) {
|
||||
ft.get_weights(t0 + Δt, packet.face.emplace<typename std::remove_reference_t<decltype(ft)>::packet_type>());
|
||||
},
|
||||
},
|
||||
face_tracker);
|
||||
}
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](auto & ft) {
|
||||
ft.get_weights(t0 + Δt, packet.face.emplace<typename std::remove_reference_t<decltype(ft)>::packet_type>());
|
||||
},
|
||||
},
|
||||
face_tracker);
|
||||
}
|
||||
catch (const std::system_error & e)
|
||||
{
|
||||
@@ -625,9 +649,6 @@ void scenes::stream::tracking()
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
if (auto * face_pico = std::get_if<xr::pico_face_tracker>(&face_tracker))
|
||||
face_pico->stop();
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::tracking_control && packet)
|
||||
@@ -659,6 +680,7 @@ static device_id derived_from(device_id target)
|
||||
|
||||
void scenes::stream::on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &)
|
||||
{
|
||||
interaction_profile_changed = true;
|
||||
std::array path = {
|
||||
"/user/hand/left",
|
||||
"/user/hand/right",
|
||||
|
||||
+49
-5
@@ -19,37 +19,81 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
template <typename T, XrResult deleter(T)>
|
||||
|
||||
template <typename T, auto Deleter = nullptr>
|
||||
class handle
|
||||
{
|
||||
public:
|
||||
// true if the deleter is provided when constructing the object
|
||||
// typically if it's from an OpenXR extension
|
||||
static constexpr bool runtime_deleter = Deleter == nullptr;
|
||||
|
||||
protected:
|
||||
static const inline T null_value = 0;
|
||||
|
||||
T id = null_value;
|
||||
[[no_unique_address]] std::conditional_t<runtime_deleter, XrResult (*)(T), std::monostate> deleter;
|
||||
|
||||
public:
|
||||
handle() {}
|
||||
template <typename = void>
|
||||
requires(not runtime_deleter)
|
||||
handle()
|
||||
{}
|
||||
|
||||
template <typename = void>
|
||||
requires(not runtime_deleter)
|
||||
handle(T id) :
|
||||
id(id) {}
|
||||
id(id)
|
||||
{}
|
||||
|
||||
template <typename = void>
|
||||
requires(runtime_deleter)
|
||||
handle(XrResult (*deleter)(T)) :
|
||||
deleter(deleter)
|
||||
{
|
||||
assert(deleter);
|
||||
}
|
||||
|
||||
template <typename = void>
|
||||
requires(runtime_deleter)
|
||||
handle(T id, XrResult (*deleter)(T)) :
|
||||
id(id), deleter(deleter)
|
||||
{
|
||||
assert(deleter);
|
||||
}
|
||||
|
||||
~handle()
|
||||
{
|
||||
if (id != null_value)
|
||||
deleter(id);
|
||||
{
|
||||
XrResult res = XR_SUCCESS;
|
||||
if constexpr (runtime_deleter)
|
||||
res = deleter(id);
|
||||
else
|
||||
res = Deleter(id);
|
||||
if (not XR_SUCCEEDED(res))
|
||||
spdlog::warn("Failed to destroy {}", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
handle(handle && other) noexcept :
|
||||
id(other.id)
|
||||
id(other.id), deleter(other.deleter)
|
||||
{
|
||||
other.id = null_value;
|
||||
}
|
||||
|
||||
handle & operator=(handle && other) noexcept
|
||||
{
|
||||
if constexpr (runtime_deleter)
|
||||
std::swap(deleter, other.deleter);
|
||||
std::swap(id, other.id);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "body_tracker.h"
|
||||
|
||||
#include "xr/htc_exts.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/system.h"
|
||||
|
||||
xr::body_tracker_type xr::body_tracker_supported(xr::instance & instance, xr::system & system)
|
||||
{
|
||||
if (instance.has_extension(XR_FB_BODY_TRACKING_EXTENSION_NAME) and
|
||||
instance.has_extension(XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME) and
|
||||
instance.has_extension(XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME))
|
||||
{
|
||||
auto fb_body_properties = system.fb_body_tracking_properties();
|
||||
if (fb_body_properties.supportsBodyTracking)
|
||||
return body_tracker_type::fb;
|
||||
}
|
||||
|
||||
if (instance.has_extension(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME) and
|
||||
instance.has_extension(XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME))
|
||||
return body_tracker_type::htc;
|
||||
|
||||
if (instance.has_extension(XR_BD_BODY_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
auto bd_body_properties = system.bd_body_tracking_properties();
|
||||
if (bd_body_properties.supportsBodyTracking)
|
||||
return body_tracker_type::pico;
|
||||
}
|
||||
|
||||
return xr::body_tracker_type::none;
|
||||
}
|
||||
|
||||
xr::body_tracker xr::make_body_tracker(xr::instance & instance, xr::system & system, xr::session & session, std::vector<std::pair<XrPath, xr::space>> & generic_trackers, bool full_body, bool hips)
|
||||
{
|
||||
if (instance.has_extension(XR_FB_BODY_TRACKING_EXTENSION_NAME) and
|
||||
instance.has_extension(XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME) and
|
||||
instance.has_extension(XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME))
|
||||
{
|
||||
auto fb_body_properties = system.fb_body_tracking_properties();
|
||||
if (fb_body_properties.supportsBodyTracking)
|
||||
return xr::body_tracker(std::in_place_type_t<xr::fb_body_tracker>(),
|
||||
instance,
|
||||
session,
|
||||
full_body,
|
||||
hips);
|
||||
}
|
||||
|
||||
if (not generic_trackers.empty())
|
||||
return xr::body_tracker(std::in_place_type_t<xr::htc_body_tracker>(),
|
||||
session,
|
||||
generic_trackers);
|
||||
|
||||
if (instance.has_extension(XR_BD_BODY_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
auto bd_body_properties = system.bd_body_tracking_properties();
|
||||
if (bd_body_properties.supportsBodyTracking)
|
||||
return xr::body_tracker(std::in_place_type_t<xr::pico_body_tracker>(),
|
||||
instance,
|
||||
session);
|
||||
}
|
||||
|
||||
return std::monostate();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "fb_body_tracker.h"
|
||||
#include "htc_body_tracker.h"
|
||||
#include "pico_body_tracker.h"
|
||||
#include "xr/system.h"
|
||||
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr
|
||||
{
|
||||
|
||||
class instance;
|
||||
class session;
|
||||
|
||||
using body_tracker = std::variant<std::monostate, xr::fb_body_tracker, xr::htc_body_tracker, xr::pico_body_tracker>;
|
||||
|
||||
body_tracker make_body_tracker(xr::instance &, xr::system &, xr::session &, std::vector<std::pair<XrPath, xr::space>> & generic_trackers, bool full_body, bool hips);
|
||||
|
||||
body_tracker_type body_tracker_supported(xr::instance &, xr::system &);
|
||||
|
||||
} // namespace xr
|
||||
@@ -17,8 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "xr.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <system_error>
|
||||
|
||||
namespace
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "face_tracker.h"
|
||||
|
||||
#include "hardware.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/system.h"
|
||||
|
||||
xr::face_tracker_type xr::face_tracker_supported(xr::instance & instance, xr::system & system)
|
||||
{
|
||||
if (instance.has_extension(XR_FB_FACE_TRACKING2_EXTENSION_NAME))
|
||||
{
|
||||
auto properties = system.fb_face_tracking2_properties();
|
||||
if (properties.supportsVisualFaceTracking)
|
||||
return xr::face_tracker_type::fb;
|
||||
}
|
||||
|
||||
if (instance.has_extension(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
auto properties = system.htc_face_tracking_properties();
|
||||
if (properties.supportEyeFacialTracking or properties.supportLipFacialTracking)
|
||||
return xr::face_tracker_type::htc;
|
||||
}
|
||||
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
// The extension used by Pico is not published
|
||||
// it doesn't even need to be requested...
|
||||
if (instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME) and
|
||||
system.eye_gaze_interaction_properties().supportsEyeGazeInteraction)
|
||||
return xr::face_tracker_type::pico;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return xr::face_tracker_type::none;
|
||||
}
|
||||
|
||||
xr::face_tracker xr::make_face_tracker(xr::instance & instance, xr::system & system, xr::session & session)
|
||||
{
|
||||
if (instance.has_extension(XR_FB_FACE_TRACKING2_EXTENSION_NAME))
|
||||
{
|
||||
auto properties = system.fb_face_tracking2_properties();
|
||||
if (properties.supportsVisualFaceTracking)
|
||||
return xr::face_tracker(std::in_place_type_t<xr::fb_face_tracker2>(), instance, session);
|
||||
}
|
||||
|
||||
if (instance.has_extension(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
auto properties = system.htc_face_tracking_properties();
|
||||
if (properties.supportEyeFacialTracking or properties.supportLipFacialTracking)
|
||||
return xr::face_tracker(
|
||||
std::in_place_type_t<xr::htc_face_tracker>(),
|
||||
instance,
|
||||
session,
|
||||
properties.supportEyeFacialTracking,
|
||||
properties.supportLipFacialTracking);
|
||||
}
|
||||
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
// The extension used by Pico is not published
|
||||
// it doesn't even need to be requested...
|
||||
if (instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME) and
|
||||
system.eye_gaze_interaction_properties().supportsEyeGazeInteraction)
|
||||
return xr::face_tracker(std::in_place_type_t<xr::pico_face_tracker>(), instance, session);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return std::monostate();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,11 +18,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "actionset.h"
|
||||
#include "error.h"
|
||||
#include "instance.h"
|
||||
#include "session.h"
|
||||
#include "swapchain.h"
|
||||
#include "system.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr/to_string.h"
|
||||
#include "fb_face_tracker2.h"
|
||||
#include "htc_face_tracker.h"
|
||||
#include "pico_face_tracker.h"
|
||||
#include "xr/system.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace xr
|
||||
{
|
||||
|
||||
class instance;
|
||||
class session;
|
||||
|
||||
using face_tracker = std::variant<std::monostate, xr::fb_face_tracker2, xr::htc_face_tracker, xr::pico_face_tracker>;
|
||||
|
||||
face_tracker make_face_tracker(xr::instance &, xr::system &, xr::session &);
|
||||
|
||||
face_tracker_type face_tracker_supported(xr::instance &, xr::system &);
|
||||
|
||||
} // namespace xr
|
||||
@@ -17,10 +17,11 @@
|
||||
*/
|
||||
|
||||
#include "fb_body_tracker.h"
|
||||
#include "application.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/meta_body_tracking_fidelity.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <ranges>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
@@ -39,59 +40,33 @@ std::vector<XrFullBodyJointMETA> xr::fb_body_tracker::get_whitelisted_joints(boo
|
||||
return {whitelisted_joints.begin(), whitelisted_joints.end()};
|
||||
}
|
||||
|
||||
xr::fb_body_tracker::fb_body_tracker(instance & inst, session & s) :
|
||||
s(s)
|
||||
xr::fb_body_tracker::fb_body_tracker(instance & inst, session & s, bool full_body, bool hip) :
|
||||
handle(inst.get_proc<PFN_xrDestroyBodyTrackerFB>("xrDestroyBodyTrackerFB")),
|
||||
xrRequestBodyTrackingFidelityMETA(inst.get_proc<PFN_xrRequestBodyTrackingFidelityMETA>("xrRequestBodyTrackingFidelityMETA")),
|
||||
xrLocateBodyJointsFB(inst.get_proc<PFN_xrLocateBodyJointsFB>("xrLocateBodyJointsFB")),
|
||||
full_body(full_body),
|
||||
hip(hip)
|
||||
{
|
||||
xrCreateBodyTrackerFB = inst.get_proc<PFN_xrCreateBodyTrackerFB>("xrCreateBodyTrackerFB");
|
||||
xrRequestBodyTrackingFidelityMETA = inst.get_proc<PFN_xrRequestBodyTrackingFidelityMETA>("xrRequestBodyTrackingFidelityMETA");
|
||||
xrLocateBodyJointsFB = inst.get_proc<PFN_xrLocateBodyJointsFB>("xrLocateBodyJointsFB");
|
||||
xrDestroyBodyTrackerFB = inst.get_proc<PFN_xrDestroyBodyTrackerFB>("xrDestroyBodyTrackerFB");
|
||||
}
|
||||
xr::fb_body_tracker::~fb_body_tracker()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
void xr::fb_body_tracker::start(bool full_body, bool hip)
|
||||
{
|
||||
assert(xrCreateBodyTrackerFB);
|
||||
this->full_body = full_body;
|
||||
this->hip = hip;
|
||||
auto xrCreateBodyTrackerFB = inst.get_proc<PFN_xrCreateBodyTrackerFB>("xrCreateBodyTrackerFB");
|
||||
|
||||
XrBodyTrackerCreateInfoFB create_info{
|
||||
.type = XR_TYPE_BODY_TRACKER_CREATE_INFO_FB,
|
||||
.next = nullptr,
|
||||
.bodyJointSet = full_body
|
||||
? XR_BODY_JOINT_SET_FULL_BODY_META
|
||||
: XR_BODY_JOINT_SET_DEFAULT_FB,
|
||||
};
|
||||
create_info.bodyJointSet = full_body
|
||||
? XR_BODY_JOINT_SET_FULL_BODY_META
|
||||
: XR_BODY_JOINT_SET_DEFAULT_FB;
|
||||
|
||||
CHECK_XR(xrCreateBodyTrackerFB(s, &create_info, &handle));
|
||||
CHECK_XR(xrCreateBodyTrackerFB(s, &create_info, &id));
|
||||
|
||||
// Enable IOBT.
|
||||
CHECK_XR(xrRequestBodyTrackingFidelityMETA(handle, XR_BODY_TRACKING_FIDELITY_HIGH_META));
|
||||
CHECK_XR(xrRequestBodyTrackingFidelityMETA(id, XR_BODY_TRACKING_FIDELITY_HIGH_META));
|
||||
|
||||
whitelisted_joints = get_whitelisted_joints(full_body, hip);
|
||||
}
|
||||
void xr::fb_body_tracker::stop()
|
||||
{
|
||||
full_body = false;
|
||||
hip = false;
|
||||
if (handle)
|
||||
{
|
||||
assert(xrDestroyBodyTrackerFB);
|
||||
CHECK_XR(xrDestroyBodyTrackerFB(std::exchange(handle, nullptr)));
|
||||
}
|
||||
}
|
||||
size_t xr::fb_body_tracker::count() const
|
||||
{
|
||||
const auto & config = application::get_config();
|
||||
return get_whitelisted_joints(config.fb_lower_body, config.fb_hip).size();
|
||||
}
|
||||
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> xr::fb_body_tracker::locate_spaces(XrTime time, XrSpace reference)
|
||||
{
|
||||
if (!handle)
|
||||
if (!id)
|
||||
return std::nullopt;
|
||||
|
||||
assert(xrLocateBodyJointsFB);
|
||||
@@ -111,7 +86,7 @@ std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_h
|
||||
.jointLocations = joints.data(),
|
||||
};
|
||||
|
||||
if (auto res = xrLocateBodyJointsFB(handle, &locate_info, &joint_locations); !XR_SUCCEEDED(res))
|
||||
if (auto res = xrLocateBodyJointsFB(id, &locate_info, &joint_locations); !XR_SUCCEEDED(res))
|
||||
{
|
||||
spdlog::warn("xrLocateBodyJointsFB returned {}", xr::to_string(res));
|
||||
return std::nullopt;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include "xr/meta_body_tracking_fidelity.h"
|
||||
#include <array>
|
||||
#include <optional>
|
||||
@@ -30,15 +31,10 @@ namespace xr
|
||||
class instance;
|
||||
class session;
|
||||
|
||||
class fb_body_tracker
|
||||
class fb_body_tracker : public utils::handle<XrBodyTrackerFB>
|
||||
{
|
||||
XrSession s;
|
||||
XrBodyTrackerFB handle{};
|
||||
|
||||
PFN_xrCreateBodyTrackerFB xrCreateBodyTrackerFB{};
|
||||
PFN_xrRequestBodyTrackingFidelityMETA xrRequestBodyTrackingFidelityMETA{};
|
||||
PFN_xrLocateBodyJointsFB xrLocateBodyJointsFB{};
|
||||
PFN_xrDestroyBodyTrackerFB xrDestroyBodyTrackerFB{};
|
||||
|
||||
bool full_body{};
|
||||
bool hip{};
|
||||
@@ -59,13 +55,7 @@ public:
|
||||
};
|
||||
static std::vector<XrFullBodyJointMETA> get_whitelisted_joints(bool full_body, bool hip);
|
||||
|
||||
fb_body_tracker() = default;
|
||||
fb_body_tracker(instance & inst, session & s);
|
||||
~fb_body_tracker();
|
||||
|
||||
void start(bool lower_body, bool hip);
|
||||
void stop();
|
||||
size_t count() const;
|
||||
fb_body_tracker(instance & inst, session & s, bool full_body, bool hip);
|
||||
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> locate_spaces(XrTime time, XrSpace reference);
|
||||
};
|
||||
|
||||
@@ -23,18 +23,11 @@
|
||||
#include <cstdint>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
static PFN_xrDestroyFaceTracker2FB xrDestroyFaceTracker2FB{};
|
||||
|
||||
XrResult xr::destroy_fb_face_tracker2(XrFaceTracker2FB id)
|
||||
{
|
||||
return xrDestroyFaceTracker2FB(id);
|
||||
}
|
||||
|
||||
xr::fb_face_tracker2::fb_face_tracker2(instance & inst, session & s)
|
||||
xr::fb_face_tracker2::fb_face_tracker2(instance & inst, session & s) :
|
||||
handle(inst.get_proc<PFN_xrDestroyFaceTracker2FB>("xrDestroyFaceTracker2FB"))
|
||||
{
|
||||
auto xrCreateFaceTracker2FB = inst.get_proc<PFN_xrCreateFaceTracker2FB>("xrCreateFaceTracker2FB");
|
||||
xrGetFaceExpressionWeights2FB = inst.get_proc<PFN_xrGetFaceExpressionWeights2FB>("xrGetFaceExpressionWeights2FB");
|
||||
xrDestroyFaceTracker2FB = inst.get_proc<PFN_xrDestroyFaceTracker2FB>("xrDestroyFaceTracker2FB");
|
||||
assert(xrCreateFaceTracker2FB);
|
||||
|
||||
XrFaceTrackingDataSource2FB data_sources[1];
|
||||
|
||||
@@ -27,16 +27,12 @@ namespace xr
|
||||
class instance;
|
||||
class session;
|
||||
|
||||
XrResult destroy_fb_face_tracker2(XrFaceTracker2FB);
|
||||
|
||||
class fb_face_tracker2 : public utils::handle<XrFaceTracker2FB, destroy_fb_face_tracker2>
|
||||
class fb_face_tracker2 : public utils::handle<XrFaceTracker2FB>
|
||||
{
|
||||
PFN_xrGetFaceExpressionWeights2FB xrGetFaceExpressionWeights2FB{};
|
||||
PFN_xrDestroyFaceTracker2FB xrDestroyFaceTracker2FB{};
|
||||
|
||||
public:
|
||||
using packet_type = wivrn::from_headset::tracking::fb_face2;
|
||||
fb_face_tracker2() = default;
|
||||
fb_face_tracker2(instance & inst, session & s);
|
||||
|
||||
void get_weights(XrTime time, packet_type & out_expressions);
|
||||
|
||||
@@ -23,19 +23,12 @@
|
||||
#include "xr/session.h"
|
||||
#include <cassert>
|
||||
|
||||
static PFN_xrDestroyHandTrackerEXT xrDestroyHandTrackerEXT{};
|
||||
|
||||
XrResult xr::destroy_hand_tracker(XrHandTrackerEXT id)
|
||||
xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info) :
|
||||
handle(inst.get_proc<PFN_xrDestroyHandTrackerEXT>("xrDestroyHandTrackerEXT"))
|
||||
{
|
||||
return xrDestroyHandTrackerEXT(id);
|
||||
}
|
||||
|
||||
xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info)
|
||||
{
|
||||
static auto xrCreateHandTrackerEXT = inst.get_proc<PFN_xrCreateHandTrackerEXT>("xrCreateHandTrackerEXT");
|
||||
auto xrCreateHandTrackerEXT = inst.get_proc<PFN_xrCreateHandTrackerEXT>("xrCreateHandTrackerEXT");
|
||||
assert(xrCreateHandTrackerEXT);
|
||||
xrLocateHandJointsEXT = inst.get_proc<PFN_xrLocateHandJointsEXT>("xrLocateHandJointsEXT");
|
||||
xrDestroyHandTrackerEXT = inst.get_proc<PFN_xrDestroyHandTrackerEXT>("xrDestroyHandTrackerEXT");
|
||||
CHECK_XR(xrCreateHandTrackerEXT(session, &info, &id));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,12 @@ namespace xr
|
||||
{
|
||||
class instance;
|
||||
class session;
|
||||
XrResult destroy_hand_tracker(XrHandTrackerEXT);
|
||||
|
||||
class hand_tracker : public utils::handle<XrHandTrackerEXT, destroy_hand_tracker>
|
||||
class hand_tracker : public utils::handle<XrHandTrackerEXT>
|
||||
{
|
||||
PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT{};
|
||||
|
||||
public:
|
||||
hand_tracker() = default;
|
||||
hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info);
|
||||
|
||||
using joint = std::pair<XrHandJointLocationEXT, XrHandJointVelocityEXT>;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Awzri <awzri@awzricat.com>
|
||||
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,8 +20,7 @@
|
||||
|
||||
#include "htc_body_tracker.h"
|
||||
#include "xr/details/enumerate.h"
|
||||
#include "xr/htc_exts.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/session.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
// Note: This utilizes extensions not present in the OpenXR spec!
|
||||
@@ -28,11 +28,25 @@
|
||||
// https://hub.vive.com/apidoc/api/VIVE.OpenXR.Tracker.ViveXRTracker.html
|
||||
// https://hub.vive.com/apidoc/api/VIVE.OpenXR.VivePathEnumerationHelper.xrEnumeratePathsForInteractionProfileHTCDelegate.html
|
||||
|
||||
xr::vive_xr_tracker::vive_xr_tracker(xr::space && space) :
|
||||
space(std::move(space)) {}
|
||||
void xr::vive_xr_tracker::set_active(bool active)
|
||||
xr::vive_xr_tracker::vive_xr_tracker(XrPath path, xr::space & space, XrSession session) :
|
||||
path(path),
|
||||
space(space)
|
||||
{
|
||||
is_active = active;
|
||||
update_active(session);
|
||||
}
|
||||
|
||||
void xr::vive_xr_tracker::update_active(XrSession session)
|
||||
{
|
||||
XrInputSourceLocalizedNameGetInfo get_info{
|
||||
.type = XR_TYPE_INPUT_SOURCE_LOCALIZED_NAME_GET_INFO,
|
||||
.next = nullptr,
|
||||
.sourcePath = path,
|
||||
.whichComponents = XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BIT,
|
||||
};
|
||||
|
||||
auto role = xr::details::enumerate<char>(xrGetInputSourceLocalizedName, session, &get_info);
|
||||
|
||||
is_active = not role.contains("_");
|
||||
}
|
||||
bool xr::vive_xr_tracker::get_active() const
|
||||
{
|
||||
@@ -76,63 +90,18 @@ static wivrn::from_headset::body_tracking::pose locate_space(XrSpace space, XrSp
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<std::string> xr::htc_body_tracker::get_roles()
|
||||
{
|
||||
auto paths = get_paths();
|
||||
std::vector<std::string> roles{};
|
||||
roles.reserve(paths.size());
|
||||
|
||||
for (auto & path: paths)
|
||||
{
|
||||
XrInputSourceLocalizedNameGetInfo get_info{
|
||||
.type = XR_TYPE_INPUT_SOURCE_LOCALIZED_NAME_GET_INFO,
|
||||
.next = nullptr,
|
||||
.sourcePath = path,
|
||||
.whichComponents = XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BIT,
|
||||
};
|
||||
|
||||
roles.emplace_back(xr::details::enumerate<char>(xrGetInputSourceLocalizedName, s, &get_info));
|
||||
}
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
xr::htc_body_tracker::htc_body_tracker(instance & inst, session & s) :
|
||||
inst(&inst),
|
||||
xr::htc_body_tracker::htc_body_tracker(session & s, std::vector<std::pair<XrPath, xr::space>> & trackers) :
|
||||
s(s)
|
||||
{
|
||||
xrEnumeratePathsForInteractionProfileHTC = inst.get_proc<PFN_xrEnumeratePathsForInteractionProfileHTC>("xrEnumeratePathsForInteractionProfileHTC");
|
||||
}
|
||||
|
||||
std::vector<XrPath> xr::htc_body_tracker::get_paths(XrPath user_path)
|
||||
{
|
||||
assert(xrEnumeratePathsForInteractionProfileHTC);
|
||||
XrPath tracker_profile = inst->string_to_path("/interaction_profiles/htc/vive_xr_tracker");
|
||||
|
||||
XrPathsForInteractionProfileEnumerateInfoHTC profile_info{
|
||||
.type = XR_TYPE_UNKNOWN,
|
||||
.next = nullptr,
|
||||
.interactionProfile = tracker_profile,
|
||||
.userPath = user_path,
|
||||
};
|
||||
return xr::details::enumerate<XrPath>(xrEnumeratePathsForInteractionProfileHTC, *inst, profile_info);
|
||||
}
|
||||
|
||||
void xr::htc_body_tracker::add(xr::space && space)
|
||||
{
|
||||
trackers.emplace_back(std::move(space));
|
||||
}
|
||||
size_t xr::htc_body_tracker::count() const
|
||||
{
|
||||
return trackers.size();
|
||||
this->trackers.reserve(trackers.size());
|
||||
for (auto & [path, space]: trackers)
|
||||
this->trackers.emplace_back(path, space, s);
|
||||
}
|
||||
|
||||
void xr::htc_body_tracker::update_active()
|
||||
{
|
||||
auto roles = get_roles();
|
||||
assert(roles.size() >= trackers.size());
|
||||
for (int i = 0; i < trackers.size(); i++)
|
||||
trackers[i].set_active(!roles[i].contains('_'));
|
||||
for (auto & tracker: trackers)
|
||||
tracker.update_active(s);
|
||||
}
|
||||
|
||||
std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses> xr::htc_body_tracker::locate_spaces(XrTime time, XrSpace reference)
|
||||
@@ -141,7 +110,7 @@ std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_t
|
||||
|
||||
for (int i = 0; i < trackers.size(); i++)
|
||||
{
|
||||
auto & tracker = trackers.at(i);
|
||||
auto & tracker = trackers[i];
|
||||
wivrn::from_headset::body_tracking::pose pose{
|
||||
.pose = {},
|
||||
.flags = 0,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Awzri <awzri@awzricat.com>
|
||||
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,9 +21,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/htc_exts.h"
|
||||
#include "xr/space.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
@@ -34,32 +33,24 @@ class session;
|
||||
class vive_xr_tracker
|
||||
{
|
||||
bool is_active = false;
|
||||
xr::space space;
|
||||
XrPath path;
|
||||
xr::space & space;
|
||||
|
||||
public:
|
||||
vive_xr_tracker(xr::space && s);
|
||||
void set_active(bool active);
|
||||
vive_xr_tracker(XrPath path, xr::space & s, XrSession session);
|
||||
void update_active(XrSession session);
|
||||
bool get_active() const;
|
||||
XrSpace get_space() const;
|
||||
};
|
||||
|
||||
class htc_body_tracker
|
||||
{
|
||||
instance * inst;
|
||||
XrSession s;
|
||||
std::vector<vive_xr_tracker> trackers;
|
||||
|
||||
PFN_xrEnumeratePathsForInteractionProfileHTC xrEnumeratePathsForInteractionProfileHTC{};
|
||||
|
||||
std::vector<std::string> get_roles();
|
||||
|
||||
public:
|
||||
htc_body_tracker() = default;
|
||||
htc_body_tracker(instance & inst, session & s);
|
||||
htc_body_tracker(session & s, std::vector<std::pair<XrPath, xr::space>> & trackers);
|
||||
|
||||
std::vector<XrPath> get_paths(XrPath user_path = XR_NULL_PATH);
|
||||
void add(xr::space && space);
|
||||
size_t count() const;
|
||||
void update_active();
|
||||
std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses> locate_spaces(XrTime time, XrSpace reference);
|
||||
};
|
||||
|
||||
@@ -18,53 +18,43 @@
|
||||
*/
|
||||
|
||||
#include "htc_face_tracker.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
xr::htc_face_tracker::htc_face_tracker(instance & inst, session & s, bool eye, bool lip) :
|
||||
s(s)
|
||||
static XrFacialTrackerHTC make_tracker(xr::instance & inst, xr::session & s, XrFacialTrackingTypeHTC type)
|
||||
{
|
||||
if (!eye && !lip)
|
||||
return;
|
||||
|
||||
xrCreateFacialTrackerHTC = inst.get_proc<PFN_xrCreateFacialTrackerHTC>("xrCreateFacialTrackerHTC");
|
||||
xrGetFacialExpressionsHTC = inst.get_proc<PFN_xrGetFacialExpressionsHTC>("xrGetFacialExpressionsHTC");
|
||||
xrDestroyFacialTrackerHTC = inst.get_proc<PFN_xrDestroyFacialTrackerHTC>("xrDestroyFacialTrackerHTC");
|
||||
|
||||
XrFacialTrackerCreateInfoHTC create_info{
|
||||
.type = XR_TYPE_FACIAL_TRACKER_CREATE_INFO_HTC,
|
||||
.next = nullptr,
|
||||
.facialTrackingType = type,
|
||||
};
|
||||
|
||||
if (eye)
|
||||
{
|
||||
create_info.facialTrackingType = XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC;
|
||||
xrCreateFacialTrackerHTC(s, &create_info, &this->eye);
|
||||
}
|
||||
if (lip)
|
||||
{
|
||||
create_info.facialTrackingType = XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC;
|
||||
xrCreateFacialTrackerHTC(s, &create_info, &this->lip);
|
||||
}
|
||||
auto xrCreateFacialTrackerHTC = inst.get_proc<PFN_xrCreateFacialTrackerHTC>("xrCreateFacialTrackerHTC");
|
||||
XrFacialTrackerHTC id;
|
||||
CHECK_XR(xrCreateFacialTrackerHTC(s, &create_info, &id));
|
||||
return id;
|
||||
}
|
||||
|
||||
xr::htc_face_tracker::~htc_face_tracker()
|
||||
static XrFacialTrackerHTC get_eye_tracker(xr::instance & inst, xr::session & s)
|
||||
{
|
||||
if (!xrDestroyFacialTrackerHTC)
|
||||
return;
|
||||
static XrFacialTrackerHTC res = make_tracker(inst, s, XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC);
|
||||
return res;
|
||||
}
|
||||
static XrFacialTrackerHTC get_lip_tracker(xr::instance & inst, xr::session & s)
|
||||
{
|
||||
static XrFacialTrackerHTC res = make_tracker(inst, s, XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (eye)
|
||||
CHECK_XR(xrDestroyFacialTrackerHTC(std::exchange(eye, nullptr)));
|
||||
if (lip)
|
||||
CHECK_XR(xrDestroyFacialTrackerHTC(std::exchange(lip, nullptr)));
|
||||
xr::htc_face_tracker::htc_face_tracker(instance & inst, session & s, bool eye, bool lip) :
|
||||
xrGetFacialExpressionsHTC(inst.get_proc<PFN_xrGetFacialExpressionsHTC>("xrGetFacialExpressionsHTC")),
|
||||
eye(eye ? get_eye_tracker(inst, s) : XR_NULL_HANDLE),
|
||||
lip(lip ? get_lip_tracker(inst, s) : XR_NULL_HANDLE)
|
||||
{
|
||||
}
|
||||
|
||||
void xr::htc_face_tracker::get_weights(XrTime time, packet_type & out_expressions)
|
||||
{
|
||||
if (!(eye || lip) || !xrGetFacialExpressionsHTC)
|
||||
return;
|
||||
assert(xrGetFacialExpressionsHTC);
|
||||
|
||||
XrFacialExpressionsHTC expressions{
|
||||
.type = XR_TYPE_FACIAL_EXPRESSIONS_HTC,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
@@ -30,18 +29,13 @@ class session;
|
||||
|
||||
class htc_face_tracker
|
||||
{
|
||||
XrSession s;
|
||||
XrFacialTrackerHTC eye{};
|
||||
XrFacialTrackerHTC lip{};
|
||||
PFN_xrCreateFacialTrackerHTC xrCreateFacialTrackerHTC{};
|
||||
PFN_xrGetFacialExpressionsHTC xrGetFacialExpressionsHTC{};
|
||||
PFN_xrDestroyFacialTrackerHTC xrDestroyFacialTrackerHTC{};
|
||||
PFN_xrGetFacialExpressionsHTC xrGetFacialExpressionsHTC;
|
||||
XrFacialTrackerHTC eye;
|
||||
XrFacialTrackerHTC lip;
|
||||
|
||||
public:
|
||||
using packet_type = wivrn::from_headset::tracking::htc_face;
|
||||
htc_face_tracker() = default;
|
||||
htc_face_tracker(instance & inst, session & s, bool eye, bool lip);
|
||||
~htc_face_tracker();
|
||||
|
||||
void get_weights(XrTime time, packet_type & out_expressions);
|
||||
};
|
||||
|
||||
+16
-1
@@ -19,8 +19,9 @@
|
||||
|
||||
#include "instance.h"
|
||||
|
||||
#include "xr.h"
|
||||
#include "xr/details/enumerate.h"
|
||||
#include "xr/htc_exts.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
@@ -212,6 +213,20 @@ XrPath xr::instance::string_to_path(const std::string & path)
|
||||
return p;
|
||||
}
|
||||
|
||||
std::vector<XrPath> xr::instance::enumerate_paths_for_interaction_profile(XrPath interaction_profile, XrPath user_path)
|
||||
{
|
||||
assert(has_extension(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME));
|
||||
static auto xrEnumeratePathsForInteractionProfileHTC = get_proc<PFN_xrEnumeratePathsForInteractionProfileHTC>("xrEnumeratePathsForInteractionProfileHTC");
|
||||
|
||||
XrPathsForInteractionProfileEnumerateInfoHTC profile_info{
|
||||
.type = XR_TYPE_UNKNOWN,
|
||||
.next = nullptr,
|
||||
.interactionProfile = interaction_profile,
|
||||
.userPath = user_path,
|
||||
};
|
||||
return xr::details::enumerate<XrPath>(xrEnumeratePathsForInteractionProfileHTC, id, profile_info);
|
||||
}
|
||||
|
||||
bool xr::instance::poll_event(xr::event & buffer)
|
||||
{
|
||||
buffer.header.type = XR_TYPE_EVENT_DATA_BUFFER;
|
||||
|
||||
@@ -90,6 +90,8 @@ public:
|
||||
XrPath string_to_path(const std::string & path);
|
||||
std::string path_to_string(XrPath path);
|
||||
|
||||
std::vector<XrPath> enumerate_paths_for_interaction_profile(XrPath interaction_profile, XrPath user_path = XR_NULL_PATH);
|
||||
|
||||
void suggest_bindings(const std::string & interaction_profile,
|
||||
std::vector<XrActionSuggestedBinding> & bindings);
|
||||
|
||||
|
||||
@@ -23,27 +23,9 @@
|
||||
#include "xr/check.h"
|
||||
#include "xr/instance.h"
|
||||
|
||||
static PFN_xrDestroyPassthroughLayerFB xrDestroyPassthroughLayerFB{};
|
||||
static PFN_xrDestroyPassthroughFB xrDestroyPassthroughFB{};
|
||||
static PFN_xrDestroyPassthroughHTC xrDestroyPassthroughHTC{};
|
||||
|
||||
XrResult xr::destroy_passthrough_layer_fb(XrPassthroughLayerFB id)
|
||||
xr::passthrough_layer_fb::passthrough_layer_fb(instance & inst, session & s, const XrPassthroughLayerCreateInfoFB & info) :
|
||||
handle(inst.get_proc<PFN_xrDestroyPassthroughLayerFB>("xrDestroyPassthroughLayerFB"))
|
||||
{
|
||||
return xrDestroyPassthroughLayerFB(id);
|
||||
}
|
||||
XrResult xr::destroy_passthrough_fb(XrPassthroughFB id)
|
||||
{
|
||||
return xrDestroyPassthroughFB(id);
|
||||
}
|
||||
XrResult xr::destroy_passthrough_htc(XrPassthroughHTC id)
|
||||
{
|
||||
return xrDestroyPassthroughHTC(id);
|
||||
}
|
||||
|
||||
xr::passthrough_layer_fb::passthrough_layer_fb(instance & inst, session & s, const XrPassthroughLayerCreateInfoFB & info)
|
||||
{
|
||||
xrDestroyPassthroughLayerFB = inst.get_proc<PFN_xrDestroyPassthroughLayerFB>("xrDestroyPassthroughLayerFB");
|
||||
|
||||
PFN_xrCreatePassthroughLayerFB xrCreatePassthroughLayerFB = inst.get_proc<PFN_xrCreatePassthroughLayerFB>("xrCreatePassthroughLayerFB");
|
||||
CHECK_XR(xrCreatePassthroughLayerFB(s, &info, &id));
|
||||
}
|
||||
@@ -51,7 +33,6 @@ xr::passthrough_layer_fb::passthrough_layer_fb(instance & inst, session & s, con
|
||||
static XrPassthroughFB create_passthrough_fb(xr::instance & inst, xr::session & s)
|
||||
{
|
||||
PFN_xrCreatePassthroughFB xrCreatePassthroughFB = inst.get_proc<PFN_xrCreatePassthroughFB>("xrCreatePassthroughFB");
|
||||
xrDestroyPassthroughFB = inst.get_proc<PFN_xrDestroyPassthroughFB>("xrDestroyPassthroughFB");
|
||||
|
||||
XrPassthroughFB id;
|
||||
XrPassthroughCreateInfoFB info{
|
||||
@@ -64,7 +45,7 @@ static XrPassthroughFB create_passthrough_fb(xr::instance & inst, xr::session &
|
||||
}
|
||||
|
||||
xr::passthrough_fb::passthrough_fb(instance & inst, session & s) :
|
||||
utils::handle<XrPassthroughFB, destroy_passthrough_fb>(create_passthrough_fb(inst, s)),
|
||||
handle(create_passthrough_fb(inst, s), inst.get_proc<PFN_xrDestroyPassthroughFB>("xrDestroyPassthroughFB")),
|
||||
passthrough_layer(inst, s, XrPassthroughLayerCreateInfoFB{
|
||||
.type = XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB,
|
||||
.passthrough = id,
|
||||
@@ -98,10 +79,10 @@ void xr::passthrough_fb::pause()
|
||||
CHECK_XR(xrPassthroughPauseFB(id));
|
||||
}
|
||||
|
||||
xr::passthrough_htc::passthrough_htc(instance & inst, session & s)
|
||||
xr::passthrough_htc::passthrough_htc(instance & inst, session & s) :
|
||||
handle(inst.get_proc<PFN_xrDestroyPassthroughHTC>("xrDestroyPassthroughHTC"))
|
||||
{
|
||||
PFN_xrCreatePassthroughHTC xrCreatePassthroughHTC = inst.get_proc<PFN_xrCreatePassthroughHTC>("xrCreatePassthroughHTC");
|
||||
xrDestroyPassthroughHTC = inst.get_proc<PFN_xrDestroyPassthroughHTC>("xrDestroyPassthroughHTC");
|
||||
|
||||
XrPassthroughCreateInfoHTC info{
|
||||
.type = XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC,
|
||||
|
||||
@@ -28,17 +28,13 @@ namespace xr
|
||||
class instance;
|
||||
class session;
|
||||
|
||||
XrResult destroy_passthrough_layer_fb(XrPassthroughLayerFB);
|
||||
XrResult destroy_passthrough_fb(XrPassthroughFB);
|
||||
XrResult destroy_passthrough_htc(XrPassthroughHTC);
|
||||
|
||||
class passthrough_layer_fb : public utils::handle<XrPassthroughLayerFB, destroy_passthrough_layer_fb>
|
||||
class passthrough_layer_fb : public utils::handle<XrPassthroughLayerFB>
|
||||
{
|
||||
public:
|
||||
passthrough_layer_fb(instance &, session &, const XrPassthroughLayerCreateInfoFB &);
|
||||
};
|
||||
|
||||
class passthrough_fb : public utils::handle<XrPassthroughFB, destroy_passthrough_fb>
|
||||
class passthrough_fb : public utils::handle<XrPassthroughFB>
|
||||
{
|
||||
PFN_xrPassthroughStartFB xrPassthroughStartFB{};
|
||||
PFN_xrPassthroughPauseFB xrPassthroughPauseFB{};
|
||||
@@ -59,7 +55,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class passthrough_htc : public utils::handle<XrPassthroughHTC, destroy_passthrough_htc>
|
||||
class passthrough_htc : public utils::handle<XrPassthroughHTC>
|
||||
{
|
||||
XrCompositionLayerPassthroughHTC composition_layer;
|
||||
|
||||
|
||||
@@ -18,19 +18,15 @@
|
||||
|
||||
#include "pico_body_tracker.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
static_assert(xr::pico_body_tracker::joint_whitelist.size() <= wivrn::from_headset::body_tracking::max_tracked_poses);
|
||||
|
||||
static PFN_xrDestroyBodyTrackerBD xrDestroyBodyTrackerBD{};
|
||||
|
||||
XrResult xr::destroy_pico_body_tracker(XrBodyTrackerBD id)
|
||||
{
|
||||
return xrDestroyBodyTrackerBD(id);
|
||||
}
|
||||
|
||||
xr::pico_body_tracker::pico_body_tracker(instance & inst, session & s)
|
||||
xr::pico_body_tracker::pico_body_tracker(instance & inst, session & s) :
|
||||
handle(inst.get_proc<PFN_xrDestroyBodyTrackerBD>("xrDestroyBodyTrackerBD"))
|
||||
{
|
||||
auto xrCreateBodyTrackerBD = inst.get_proc<PFN_xrCreateBodyTrackerBD>("xrCreateBodyTrackerBD");
|
||||
xrLocateBodyJointsBD = inst.get_proc<PFN_xrLocateBodyJointsBD>("xrLocateBodyJointsBD");
|
||||
@@ -45,10 +41,6 @@ xr::pico_body_tracker::pico_body_tracker(instance & inst, session & s)
|
||||
CHECK_XR(xrCreateBodyTrackerBD(s, &create_info, &id));
|
||||
}
|
||||
|
||||
size_t xr::pico_body_tracker::count() const
|
||||
{
|
||||
return joint_whitelist.size();
|
||||
}
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> xr::pico_body_tracker::locate_spaces(XrTime time, XrSpace reference)
|
||||
{
|
||||
if (!xrLocateBodyJointsBD)
|
||||
|
||||
@@ -30,9 +30,7 @@ namespace xr
|
||||
class instance;
|
||||
class session;
|
||||
|
||||
XrResult destroy_pico_body_tracker(XrBodyTrackerBD);
|
||||
|
||||
class pico_body_tracker : public utils::handle<XrBodyTrackerBD, destroy_pico_body_tracker>
|
||||
class pico_body_tracker : public utils::handle<XrBodyTrackerBD>
|
||||
{
|
||||
PFN_xrLocateBodyJointsBD xrLocateBodyJointsBD{};
|
||||
|
||||
@@ -48,10 +46,8 @@ public:
|
||||
XR_BODY_JOINT_RIGHT_FOOT_BD,
|
||||
};
|
||||
|
||||
pico_body_tracker() = default;
|
||||
pico_body_tracker(instance & inst, session & s);
|
||||
|
||||
size_t count() const;
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> locate_spaces(XrTime time, XrSpace reference);
|
||||
};
|
||||
} // namespace xr
|
||||
|
||||
+135
-124
@@ -18,152 +18,163 @@
|
||||
*/
|
||||
|
||||
#include "pico_face_tracker.h"
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/pico_eye_types.h"
|
||||
#include "xr/pico_eye_types_reflection.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/to_string.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <mutex>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
xr::pico_face_tracker::pico_face_tracker(instance & inst, session & s_) :
|
||||
s(s_)
|
||||
struct xr::pico_face_tracker::impl
|
||||
{
|
||||
xrStartEyeTrackingPICO = inst.get_proc<PFN_xrStartEyeTrackingPICO>("xrStartEyeTrackingPICO");
|
||||
xrStopEyeTrackingPICO = inst.get_proc<PFN_xrStopEyeTrackingPICO>("xrStopEyeTrackingPICO");
|
||||
xrSetTrackingModePICO = inst.get_proc<PFN_xrSetTrackingModePICO>("xrSetTrackingModePICO");
|
||||
xrGetFaceTrackingDataPICO = inst.get_proc<PFN_xrGetFaceTrackingDataPICO>("xrGetFaceTrackingDataPICO");
|
||||
}
|
||||
xr::pico_face_tracker::~pico_face_tracker()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
const XrSession s;
|
||||
const PFN_xrStopEyeTrackingPICO xrStopEyeTrackingPICO;
|
||||
const PFN_xrGetFaceTrackingDataPICO xrGetFaceTrackingDataPICO;
|
||||
|
||||
void xr::pico_face_tracker::start()
|
||||
{
|
||||
if (started)
|
||||
throw std::invalid_argument("face tracking already started");
|
||||
|
||||
CHECK_XR(xrStartEyeTrackingPICO(s));
|
||||
CHECK_XR(xrSetTrackingModePICO(s, XR_TRACKING_MODE_FACE_BIT_PICO));
|
||||
started = true;
|
||||
}
|
||||
void xr::pico_face_tracker::stop()
|
||||
{
|
||||
if (!started)
|
||||
return;
|
||||
|
||||
if (auto res = xrStopEyeTrackingPICO(s, XR_TRACKING_MODE_FACE_BIT_PICO); !XR_SUCCEEDED(res))
|
||||
spdlog::warn("Failed to deactivate face tracking: {}", xr::to_string(res));
|
||||
|
||||
started = false;
|
||||
}
|
||||
|
||||
void xr::pico_face_tracker::get_weights(XrTime time, wivrn::from_headset::tracking::fb_face2 & out_expressions)
|
||||
{
|
||||
out_expressions.is_valid = false;
|
||||
out_expressions.is_eye_following_blendshapes_valid = false;
|
||||
|
||||
if (!started or !xrGetFaceTrackingDataPICO)
|
||||
return;
|
||||
|
||||
XrFaceTrackingDataPICO face_tracking{.time = 0};
|
||||
|
||||
if (auto res = xrGetFaceTrackingDataPICO(s, time, XR_GET_FACE_DATA_DEFAULT_PICO, &face_tracking); !XR_SUCCEEDED(res))
|
||||
impl(instance & inst, session & s) :
|
||||
s(s),
|
||||
xrStopEyeTrackingPICO(inst.get_proc<PFN_xrStopEyeTrackingPICO>("xrStopEyeTrackingPICO")),
|
||||
xrGetFaceTrackingDataPICO(inst.get_proc<PFN_xrGetFaceTrackingDataPICO>("xrGetFaceTrackingDataPICO"))
|
||||
{
|
||||
spdlog::warn("Unable to get face tracking data: xrGetFaceTrackingDataPICO returned {}", xr::to_string(res));
|
||||
return;
|
||||
auto xrStartEyeTrackingPICO = inst.get_proc<PFN_xrStartEyeTrackingPICO>("xrStartEyeTrackingPICO");
|
||||
auto xrSetTrackingModePICO = inst.get_proc<PFN_xrSetTrackingModePICO>("xrSetTrackingModePICO");
|
||||
CHECK_XR(xrStartEyeTrackingPICO(s));
|
||||
CHECK_XR(xrSetTrackingModePICO(s, XR_TRACKING_MODE_FACE_BIT_PICO));
|
||||
}
|
||||
|
||||
if (face_tracking.time == 0)
|
||||
return;
|
||||
~impl()
|
||||
{
|
||||
if (auto res = xrStopEyeTrackingPICO(s, XR_TRACKING_MODE_FACE_BIT_PICO); not XR_SUCCEEDED(res))
|
||||
spdlog::warn("Failed to deactivate face tracking: {}", xr::to_string(res));
|
||||
}
|
||||
|
||||
void get_weights(XrTime time, wivrn::from_headset::tracking::fb_face2 & out_expressions)
|
||||
{
|
||||
out_expressions.is_valid = false;
|
||||
out_expressions.is_eye_following_blendshapes_valid = false;
|
||||
|
||||
XrFaceTrackingDataPICO face_tracking{.time = 0};
|
||||
|
||||
if (auto res = xrGetFaceTrackingDataPICO(s, time, XR_GET_FACE_DATA_DEFAULT_PICO, &face_tracking); !XR_SUCCEEDED(res))
|
||||
{
|
||||
spdlog::warn("Unable to get face tracking data: xrGetFaceTrackingDataPICO returned {}", xr::to_string(res));
|
||||
return;
|
||||
}
|
||||
|
||||
if (face_tracking.time == 0)
|
||||
return;
|
||||
|
||||
#define MAP_EXPRESSION(fb, pico) \
|
||||
out_expressions.weights[fb] = face_tracking.blendShapeWeight[pico];
|
||||
|
||||
// Map the blendshapes.
|
||||
out_expressions.weights.fill(0.f);
|
||||
out_expressions.confidences.fill(1.f);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_BROW_LOWERER_L_FB, XR_BS_BROWDOWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_BROW_LOWERER_R_FB, XR_BS_BROWDOWN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHEEK_PUFF_L_FB, XR_BS_CHEEKPUFF_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHEEK_PUFF_R_FB, XR_BS_CHEEKPUFF_PICO);
|
||||
// XR_FACE_EXPRESSION2_CHEEK_RAISER_L_FB
|
||||
// XR_FACE_EXPRESSION2_CHEEK_RAISER_R_FB
|
||||
// XR_FACE_EXPRESSION2_CHEEK_SUCK_L_FB
|
||||
// XR_FACE_EXPRESSION2_CHEEK_SUCK_R_FB
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHIN_RAISER_B_FB, XR_BS_MOUTHSHRUGLOWER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHIN_RAISER_T_FB, XR_BS_MOUTHSHRUGUPPER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_DIMPLER_L_FB, XR_BS_MOUTHDIMPLE_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_DIMPLER_R_FB, XR_BS_MOUTHDIMPLE_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_CLOSED_L_FB, XR_BS_EYEBLINK_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_CLOSED_R_FB, XR_BS_EYEBLINK_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_L_FB, XR_BS_EYELOOKDOWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_R_FB, XR_BS_EYELOOKDOWN_R_PICO);
|
||||
// Map the blendshapes.
|
||||
out_expressions.weights.fill(0.f);
|
||||
out_expressions.confidences.fill(1.f);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_BROW_LOWERER_L_FB, XR_BS_BROWDOWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_BROW_LOWERER_R_FB, XR_BS_BROWDOWN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHEEK_PUFF_L_FB, XR_BS_CHEEKPUFF_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHEEK_PUFF_R_FB, XR_BS_CHEEKPUFF_PICO);
|
||||
// XR_FACE_EXPRESSION2_CHEEK_RAISER_L_FB
|
||||
// XR_FACE_EXPRESSION2_CHEEK_RAISER_R_FB
|
||||
// XR_FACE_EXPRESSION2_CHEEK_SUCK_L_FB
|
||||
// XR_FACE_EXPRESSION2_CHEEK_SUCK_R_FB
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHIN_RAISER_B_FB, XR_BS_MOUTHSHRUGLOWER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_CHIN_RAISER_T_FB, XR_BS_MOUTHSHRUGUPPER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_DIMPLER_L_FB, XR_BS_MOUTHDIMPLE_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_DIMPLER_R_FB, XR_BS_MOUTHDIMPLE_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_CLOSED_L_FB, XR_BS_EYEBLINK_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_CLOSED_R_FB, XR_BS_EYEBLINK_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_L_FB, XR_BS_EYELOOKDOWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_DOWN_R_FB, XR_BS_EYELOOKDOWN_R_PICO);
|
||||
|
||||
// "out" is left for the left eye, right for the right eye
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_L_FB, XR_BS_EYELOOKOUT_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_L_FB, XR_BS_EYELOOKIN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_R_FB, XR_BS_EYELOOKIN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_R_FB, XR_BS_EYELOOKOUT_R_PICO);
|
||||
// "out" is left for the left eye, right for the right eye
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_L_FB, XR_BS_EYELOOKOUT_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_L_FB, XR_BS_EYELOOKIN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_LEFT_R_FB, XR_BS_EYELOOKIN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_RIGHT_R_FB, XR_BS_EYELOOKOUT_R_PICO);
|
||||
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_UP_L_FB, XR_BS_EYELOOKUP_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_UP_R_FB, XR_BS_EYELOOKUP_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_INNER_BROW_RAISER_L_FB, XR_BS_BROWINNERUP_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_INNER_BROW_RAISER_R_FB, XR_BS_BROWINNERUP_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_DROP_FB, XR_BS_JAWOPEN_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_SIDEWAYS_LEFT_FB, XR_BS_JAWLEFT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_SIDEWAYS_RIGHT_FB, XR_BS_JAWRIGHT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_THRUST_FB, XR_BS_JAWFORWARD_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LID_TIGHTENER_L_FB, XR_BS_EYESQUINT_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LID_TIGHTENER_R_FB, XR_BS_EYESQUINT_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_L_FB, XR_BS_MOUTHFROWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_R_FB, XR_BS_MOUTHFROWN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_L_FB, XR_BS_MOUTHSMILE_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_R_FB, XR_BS_MOUTHSMILE_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_LB_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_LT_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_RB_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_RT_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PRESSOR_L_FB, XR_BS_MOUTHPRESS_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PRESSOR_R_FB, XR_BS_MOUTHPRESS_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PUCKER_L_FB, XR_BS_MOUTHPUCKER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PUCKER_R_FB, XR_BS_MOUTHPUCKER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_STRETCHER_L_FB, XR_BS_MOUTHSTRETCH_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_STRETCHER_R_FB, XR_BS_MOUTHSTRETCH_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_LB_FB, XR_BS_MOUTHROLLLOWER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_LT_FB, XR_BS_MOUTHROLLLOWER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_RT_FB, XR_BS_MOUTHROLLUPPER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_RB_FB, XR_BS_MOUTHROLLUPPER_PICO);
|
||||
// XR_FACE_EXPRESSION2_LIP_TIGHTENER_L_FB
|
||||
// XR_FACE_EXPRESSION2_LIP_TIGHTENER_R_FB
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIPS_TOWARD_FB, XR_BS_MOUTHCLOSE_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_L_FB, XR_BS_MOUTHLOWERDOWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_R_FB, XR_BS_MOUTHLOWERDOWN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_MOUTH_LEFT_FB, XR_BS_MOUTHLEFT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_MOUTH_RIGHT_FB, XR_BS_MOUTHRIGHT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_NOSE_WRINKLER_L_FB, XR_BS_NOSESNEER_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_NOSE_WRINKLER_R_FB, XR_BS_NOSESNEER_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_L_FB, XR_BS_BROWOUTERUP_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_R_FB, XR_BS_BROWOUTERUP_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LID_RAISER_L_FB, XR_BS_EYEWIDE_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LID_RAISER_R_FB, XR_BS_EYEWIDE_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_L_FB, XR_BS_MOUTHUPPERUP_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_R_FB, XR_BS_MOUTHUPPERUP_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_TONGUE_OUT_FB, XR_BS_TONGUEOUT_PICO);
|
||||
// XR_FACE_EXPRESSION2_TONGUE_TIP_INTERDENTAL_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_TIP_ALVEOLAR_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_FRONT_DORSAL_PALATE_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_MID_DORSAL_PALATE_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_BACK_DORSAL_VELAR_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_RETREAT_FB
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_UP_L_FB, XR_BS_EYELOOKUP_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_EYES_LOOK_UP_R_FB, XR_BS_EYELOOKUP_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_INNER_BROW_RAISER_L_FB, XR_BS_BROWINNERUP_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_INNER_BROW_RAISER_R_FB, XR_BS_BROWINNERUP_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_DROP_FB, XR_BS_JAWOPEN_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_SIDEWAYS_LEFT_FB, XR_BS_JAWLEFT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_SIDEWAYS_RIGHT_FB, XR_BS_JAWRIGHT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_JAW_THRUST_FB, XR_BS_JAWFORWARD_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LID_TIGHTENER_L_FB, XR_BS_EYESQUINT_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LID_TIGHTENER_R_FB, XR_BS_EYESQUINT_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_L_FB, XR_BS_MOUTHFROWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_DEPRESSOR_R_FB, XR_BS_MOUTHFROWN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_L_FB, XR_BS_MOUTHSMILE_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_CORNER_PULLER_R_FB, XR_BS_MOUTHSMILE_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_LB_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_LT_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_RB_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_FUNNELER_RT_FB, XR_BS_MOUTHFUNNEL_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PRESSOR_L_FB, XR_BS_MOUTHPRESS_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PRESSOR_R_FB, XR_BS_MOUTHPRESS_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PUCKER_L_FB, XR_BS_MOUTHPUCKER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_PUCKER_R_FB, XR_BS_MOUTHPUCKER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_STRETCHER_L_FB, XR_BS_MOUTHSTRETCH_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_STRETCHER_R_FB, XR_BS_MOUTHSTRETCH_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_LB_FB, XR_BS_MOUTHROLLLOWER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_LT_FB, XR_BS_MOUTHROLLLOWER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_RT_FB, XR_BS_MOUTHROLLUPPER_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIP_SUCK_RB_FB, XR_BS_MOUTHROLLUPPER_PICO);
|
||||
// XR_FACE_EXPRESSION2_LIP_TIGHTENER_L_FB
|
||||
// XR_FACE_EXPRESSION2_LIP_TIGHTENER_R_FB
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LIPS_TOWARD_FB, XR_BS_MOUTHCLOSE_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_L_FB, XR_BS_MOUTHLOWERDOWN_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_LOWER_LIP_DEPRESSOR_R_FB, XR_BS_MOUTHLOWERDOWN_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_MOUTH_LEFT_FB, XR_BS_MOUTHLEFT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_MOUTH_RIGHT_FB, XR_BS_MOUTHRIGHT_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_NOSE_WRINKLER_L_FB, XR_BS_NOSESNEER_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_NOSE_WRINKLER_R_FB, XR_BS_NOSESNEER_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_L_FB, XR_BS_BROWOUTERUP_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_OUTER_BROW_RAISER_R_FB, XR_BS_BROWOUTERUP_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LID_RAISER_L_FB, XR_BS_EYEWIDE_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LID_RAISER_R_FB, XR_BS_EYEWIDE_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_L_FB, XR_BS_MOUTHUPPERUP_L_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_UPPER_LIP_RAISER_R_FB, XR_BS_MOUTHUPPERUP_R_PICO);
|
||||
MAP_EXPRESSION(XR_FACE_EXPRESSION2_TONGUE_OUT_FB, XR_BS_TONGUEOUT_PICO);
|
||||
// XR_FACE_EXPRESSION2_TONGUE_TIP_INTERDENTAL_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_TIP_ALVEOLAR_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_FRONT_DORSAL_PALATE_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_MID_DORSAL_PALATE_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_BACK_DORSAL_VELAR_FB
|
||||
// XR_FACE_EXPRESSION2_TONGUE_RETREAT_FB
|
||||
|
||||
#undef MAP_EXPRESSION
|
||||
|
||||
out_expressions.is_valid = true;
|
||||
out_expressions.is_eye_following_blendshapes_valid = true;
|
||||
out_expressions.is_valid = true;
|
||||
out_expressions.is_eye_following_blendshapes_valid = true;
|
||||
}
|
||||
};
|
||||
|
||||
xr::pico_face_tracker::pico_face_tracker(instance & inst, session & s)
|
||||
{
|
||||
// The API has a global start and stop method
|
||||
// use a shared handle so we can have independent objects
|
||||
// and start/stop accordingly
|
||||
static std::mutex mutex;
|
||||
std::unique_lock lock(mutex);
|
||||
static std::weak_ptr<impl> instance;
|
||||
if (auto shared = instance.lock())
|
||||
{
|
||||
i = std::move(shared);
|
||||
return;
|
||||
}
|
||||
i = std::make_unique<impl>(inst, s);
|
||||
instance = i;
|
||||
}
|
||||
|
||||
void xr::pico_face_tracker::get_weights(XrTime time, packet_type & out_expressions)
|
||||
{
|
||||
return i->get_weights(time, out_expressions);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/pico_eye_types.h"
|
||||
#include "xr/pico_eye_types_reflection.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr
|
||||
@@ -31,22 +29,13 @@ class session;
|
||||
|
||||
class pico_face_tracker
|
||||
{
|
||||
PFN_xrStartEyeTrackingPICO xrStartEyeTrackingPICO{};
|
||||
PFN_xrStopEyeTrackingPICO xrStopEyeTrackingPICO{};
|
||||
PFN_xrSetTrackingModePICO xrSetTrackingModePICO{};
|
||||
PFN_xrGetFaceTrackingDataPICO xrGetFaceTrackingDataPICO{};
|
||||
|
||||
XrSession s;
|
||||
bool started{};
|
||||
struct impl;
|
||||
std::shared_ptr<impl> i;
|
||||
|
||||
public:
|
||||
using packet_type = wivrn::from_headset::tracking::fb_face2;
|
||||
pico_face_tracker() = default;
|
||||
pico_face_tracker(instance & inst, session & s);
|
||||
~pico_face_tracker();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
void get_weights(XrTime time, packet_type & out_expressions);
|
||||
};
|
||||
} // namespace xr
|
||||
|
||||
@@ -19,18 +19,19 @@
|
||||
|
||||
#include "session.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "details/enumerate.h"
|
||||
#include "openxr/openxr.h"
|
||||
#include "utils/contains.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/system.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <ranges>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
xr::session::session(xr::instance & inst, xr::system & sys, vk::raii::Instance & vk_inst, vk::raii::PhysicalDevice & pdev, vk::raii::Device & dev, int queue_family_index) :
|
||||
inst(&inst)
|
||||
xr::session::session(xr::instance & inst, xr::system & sys, vk::raii::Instance & vk_inst, vk::raii::PhysicalDevice & pdev, vk::raii::Device & dev, thread_safe<vk::raii::Queue> & queue, int queue_family_index) :
|
||||
inst(&inst),
|
||||
queue(&queue)
|
||||
{
|
||||
XrGraphicsBindingVulkan2KHR vulkan_binding{
|
||||
.type = XR_TYPE_GRAPHICS_BINDING_VULKAN2_KHR,
|
||||
@@ -127,7 +128,7 @@ void xr::session::begin_frame()
|
||||
.type = XR_TYPE_FRAME_BEGIN_INFO,
|
||||
};
|
||||
|
||||
auto lock = application::get_queue().lock();
|
||||
auto lock = queue->lock();
|
||||
CHECK_XR(xrBeginFrame(id, &begin_info));
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ void xr::session::end_frame(XrTime display_time, const std::vector<XrComposition
|
||||
.layers = layers.data(),
|
||||
};
|
||||
|
||||
auto lock = application::get_queue().lock();
|
||||
auto lock = queue->lock();
|
||||
CHECK_XR(xrEndFrame(id, &end_info));
|
||||
}
|
||||
|
||||
@@ -344,14 +345,14 @@ void xr::session::enable_passthrough(xr::system & system)
|
||||
if (not std::holds_alternative<std::monostate>(passthrough))
|
||||
return;
|
||||
|
||||
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
|
||||
if (system.passthrough_supported() == xr::passthrough_type::none)
|
||||
return;
|
||||
|
||||
if (utils::contains(application::get_xr_extensions(), XR_FB_PASSTHROUGH_EXTENSION_NAME))
|
||||
if (inst->has_extension(XR_FB_PASSTHROUGH_EXTENSION_NAME))
|
||||
{
|
||||
passthrough.emplace<xr::passthrough_fb>(*inst, *this);
|
||||
}
|
||||
else if (utils::contains(application::get_xr_extensions(), XR_HTC_PASSTHROUGH_EXTENSION_NAME))
|
||||
else if (inst->has_extension(XR_HTC_PASSTHROUGH_EXTENSION_NAME))
|
||||
{
|
||||
passthrough.emplace<xr::passthrough_htc>(*inst, *this);
|
||||
}
|
||||
|
||||
+3
-1
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include "utils/thread_safe.h"
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -39,10 +40,11 @@ class session : public utils::handle<XrSession, xrDestroySession>
|
||||
{
|
||||
instance * inst = nullptr;
|
||||
xr::passthrough passthrough;
|
||||
thread_safe<vk::raii::Queue> * queue = nullptr;
|
||||
|
||||
public:
|
||||
session() = default;
|
||||
session(instance &, system &, vk::raii::Instance &, vk::raii::PhysicalDevice &, vk::raii::Device &, int queue_family_index);
|
||||
session(instance &, system &, vk::raii::Instance &, vk::raii::PhysicalDevice &, vk::raii::Device &, thread_safe<vk::raii::Queue> & queue, int queue_family_index);
|
||||
|
||||
std::vector<XrReferenceSpaceType> get_reference_spaces() const;
|
||||
space create_reference_space(XrReferenceSpaceType ref, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
|
||||
|
||||
+28
-7
@@ -19,12 +19,14 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "body_tracker.h"
|
||||
#include "details/enumerate.h"
|
||||
#include "face_tracker.h"
|
||||
#include "openxr/openxr.h"
|
||||
#include "utils/contains.h"
|
||||
#include "vk/check.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr/instance.h"
|
||||
#include <cassert>
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
@@ -41,6 +43,12 @@ xr::system::system(xr::instance & inst, XrFormFactor formfactor)
|
||||
CHECK_XR(xrGetSystem(inst, &system_info, &id));
|
||||
|
||||
assert(id != XR_NULL_SYSTEM_ID);
|
||||
|
||||
if (inst.has_extension(XR_EXT_HAND_TRACKING_EXTENSION_NAME))
|
||||
hand_tracking_supported_ = hand_tracking_properties().supportsHandTracking;
|
||||
|
||||
body_tracker = xr::body_tracker_supported(inst, *this);
|
||||
face_tracker = xr::face_tracker_supported(inst, *this);
|
||||
}
|
||||
|
||||
XrGraphicsRequirementsVulkan2KHR xr::system::graphics_requirements() const
|
||||
@@ -195,16 +203,15 @@ XrSystemBodyTrackingPropertiesBD xr::system::bd_body_tracking_properties() const
|
||||
return body_tracking_prop;
|
||||
}
|
||||
|
||||
xr::system::passthrough_type xr::system::passthrough_supported() const
|
||||
xr::passthrough_type xr::system::passthrough_supported() const
|
||||
{
|
||||
if (utils::contains(environment_blend_modes(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO), XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND))
|
||||
return passthrough_type::color;
|
||||
|
||||
const std::vector<std::string> & xr_extensions = application::get_xr_extensions();
|
||||
if (utils::contains(xr_extensions, XR_HTC_PASSTHROUGH_EXTENSION_NAME))
|
||||
if (inst->has_extension(XR_HTC_PASSTHROUGH_EXTENSION_NAME))
|
||||
return passthrough_type::color;
|
||||
|
||||
if (utils::contains(xr_extensions, XR_FB_PASSTHROUGH_EXTENSION_NAME))
|
||||
if (inst->has_extension(XR_FB_PASSTHROUGH_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemPassthroughProperties2FB passthrough_prop2{
|
||||
.type = XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB,
|
||||
@@ -224,7 +231,7 @@ xr::system::passthrough_type xr::system::passthrough_supported() const
|
||||
if (passthrough_prop.supportsPassthrough)
|
||||
{
|
||||
if (!(passthrough_prop2.capabilities & XR_PASSTHROUGH_CAPABILITY_BIT_FB))
|
||||
return passthrough_type::no_passthrough;
|
||||
return passthrough_type::none;
|
||||
|
||||
if (passthrough_prop2.capabilities & XR_PASSTHROUGH_CAPABILITY_COLOR_BIT_FB)
|
||||
return passthrough_type::color;
|
||||
@@ -233,7 +240,21 @@ xr::system::passthrough_type xr::system::passthrough_supported() const
|
||||
}
|
||||
}
|
||||
|
||||
return passthrough_type::no_passthrough;
|
||||
return passthrough_type::none;
|
||||
}
|
||||
xr::face_tracker_type xr::system::face_tracker_supported() const
|
||||
{
|
||||
return face_tracker;
|
||||
}
|
||||
|
||||
xr::body_tracker_type xr::system::body_tracker_supported() const
|
||||
{
|
||||
return body_tracker;
|
||||
}
|
||||
|
||||
bool xr::system::hand_tracking_supported() const
|
||||
{
|
||||
return hand_tracking_supported_;
|
||||
}
|
||||
|
||||
vk::raii::PhysicalDevice xr::system::physical_device(vk::raii::Instance & vulkan) const
|
||||
|
||||
+31
-7
@@ -32,19 +32,39 @@ namespace xr
|
||||
{
|
||||
class instance;
|
||||
|
||||
enum class passthrough_type
|
||||
{
|
||||
none,
|
||||
bw,
|
||||
color
|
||||
};
|
||||
|
||||
enum class body_tracker_type
|
||||
{
|
||||
none,
|
||||
fb,
|
||||
htc,
|
||||
pico,
|
||||
};
|
||||
|
||||
enum class face_tracker_type
|
||||
{
|
||||
none,
|
||||
fb,
|
||||
htc,
|
||||
pico,
|
||||
};
|
||||
|
||||
class system
|
||||
{
|
||||
instance * inst = nullptr;
|
||||
XrSystemId id = XR_NULL_SYSTEM_ID;
|
||||
bool hand_tracking_supported_ = false;
|
||||
passthrough_type passthrough;
|
||||
body_tracker_type body_tracker;
|
||||
face_tracker_type face_tracker;
|
||||
|
||||
public:
|
||||
enum class passthrough_type
|
||||
{
|
||||
no_passthrough,
|
||||
bw,
|
||||
color
|
||||
};
|
||||
|
||||
system() = default;
|
||||
system(const system &) = default;
|
||||
system & operator=(const system &) = default;
|
||||
@@ -67,7 +87,11 @@ public:
|
||||
XrSystemFacialTrackingPropertiesHTC htc_face_tracking_properties() const;
|
||||
XrSystemBodyTrackingPropertiesFB fb_body_tracking_properties() const;
|
||||
XrSystemBodyTrackingPropertiesBD bd_body_tracking_properties() const;
|
||||
|
||||
bool hand_tracking_supported() const;
|
||||
passthrough_type passthrough_supported() const;
|
||||
face_tracker_type face_tracker_supported() const;
|
||||
body_tracker_type body_tracker_supported() const;
|
||||
|
||||
XrGraphicsRequirementsVulkan2KHR graphics_requirements() const;
|
||||
vk::raii::PhysicalDevice physical_device(vk::raii::Instance & vulkan) const;
|
||||
|
||||
@@ -69,10 +69,9 @@ wivrn::fd_base::~fd_base()
|
||||
wivrn::UDP::UDP()
|
||||
{
|
||||
fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
if (fd < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
|
||||
wivrn::UDP::UDP(int fd)
|
||||
@@ -177,10 +176,9 @@ wivrn::TCP::TCP(int fd)
|
||||
wivrn::TCP::TCP(in6_addr address, int port)
|
||||
{
|
||||
fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
if (fd < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
sockaddr_in6 sa;
|
||||
sa.sin6_family = AF_INET6;
|
||||
@@ -199,10 +197,9 @@ wivrn::TCP::TCP(in6_addr address, int port)
|
||||
wivrn::TCP::TCP(in_addr address, int port)
|
||||
{
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
if (fd < 0)
|
||||
throw std::system_error{errno, std::generic_category()};
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
sockaddr_in sa;
|
||||
sa.sin_family = AF_INET;
|
||||
|
||||
@@ -148,7 +148,8 @@ xrt_result_t wivrn_generic_tracker::get_tracked_pose(xrt_input_name name, int64_
|
||||
{
|
||||
std::tie(extrapolation_time, *res) = poses.get_pose_at(at_timestamp_ns);
|
||||
|
||||
cnx.set_tracker_enabled(index, true);
|
||||
active = true;
|
||||
cnx.update_tracker_enabled();
|
||||
cnx.add_predict_offset(extrapolation_time);
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
@@ -160,6 +161,9 @@ xrt_result_t wivrn_generic_tracker::get_tracked_pose(xrt_input_name name, int64_
|
||||
void wivrn_generic_tracker::update_tracking(const from_headset::body_tracking & tracking, const from_headset::body_tracking::pose & pose, const clock_offset & offset)
|
||||
{
|
||||
if (!poses.update_tracking(tracking.production_timestamp, tracking.timestamp, pose, offset))
|
||||
cnx.set_tracker_enabled(index, false);
|
||||
{
|
||||
active = false;
|
||||
cnx.update_tracker_enabled();
|
||||
}
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -45,6 +45,7 @@ class wivrn_generic_tracker : public xrt_device
|
||||
{
|
||||
tracker_pose_list poses;
|
||||
xrt_input pose_input;
|
||||
std::atomic_bool active = false;
|
||||
|
||||
wivrn_session & cnx;
|
||||
int index;
|
||||
@@ -57,5 +58,10 @@ public:
|
||||
xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation);
|
||||
|
||||
void update_tracking(const from_headset::body_tracking & tracking, const from_headset::body_tracking::pose & pose, const clock_offset & offset);
|
||||
|
||||
bool is_active()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
};
|
||||
} // namespace wivrn
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -240,24 +240,31 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
|
||||
xdevs[xdev_count++] = htc_face_tracker.get();
|
||||
}
|
||||
|
||||
num_generic_trackers = get_info().num_generic_trackers;
|
||||
enabled_trackers.fill(false);
|
||||
auto num_generic_trackers = get_info().num_generic_trackers;
|
||||
generic_trackers.reserve(num_generic_trackers);
|
||||
if (num_generic_trackers > 0)
|
||||
{
|
||||
if (num_generic_trackers > from_headset::body_tracking::max_tracked_poses)
|
||||
{
|
||||
U_LOG_W("reported generic trackers %d larger than maximum %lu",
|
||||
num_generic_trackers,
|
||||
from_headset::body_tracking::max_tracked_poses);
|
||||
num_generic_trackers = from_headset::body_tracking::max_tracked_poses;
|
||||
}
|
||||
if (num_generic_trackers + xdev_count > std::size(xdevs))
|
||||
{
|
||||
U_LOG_W("Too many generic trackers: %d, only %lu will be active",
|
||||
num_generic_trackers,
|
||||
std::size(xdevs) - xdev_count);
|
||||
num_generic_trackers = std::size(xdevs) - xdev_count;
|
||||
}
|
||||
U_LOG_I("Creating %d generic trackers", num_generic_trackers);
|
||||
|
||||
if (num_generic_trackers > generic_trackers.size())
|
||||
throw std::out_of_range(
|
||||
std::format("{} generic trackers is larger than maximum {}",
|
||||
num_generic_trackers,
|
||||
generic_trackers.size()));
|
||||
|
||||
for (int i = 0; i < num_generic_trackers; ++i)
|
||||
{
|
||||
auto dev = std::make_unique<wivrn_generic_tracker>(i, &hmd, *this);
|
||||
xdevs[xdev_count++] = dev.get();
|
||||
generic_trackers[i] = std::move(dev);
|
||||
enabled_trackers[i] = true;
|
||||
generic_trackers.push_back(std::move(dev));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,12 +549,10 @@ void wivrn_session::operator()(from_headset::body_tracking && body_tracking)
|
||||
{
|
||||
auto offset = offset_est.get_offset();
|
||||
|
||||
for (int i = 0; i < num_generic_trackers; i++)
|
||||
assert(generic_trackers.size() <= from_headset::body_tracking::max_tracked_poses);
|
||||
for (int i = 0; i < generic_trackers.size(); i++)
|
||||
{
|
||||
auto pose = body_tracking.poses ? body_tracking.poses->at(i) : from_headset::body_tracking::pose{
|
||||
.pose = {},
|
||||
.flags = 0,
|
||||
};
|
||||
auto pose = body_tracking.poses ? (*body_tracking.poses)[i] : from_headset::body_tracking::pose{};
|
||||
generic_trackers[i]->update_tracking(body_tracking, pose, offset);
|
||||
}
|
||||
}
|
||||
@@ -612,12 +617,10 @@ void wivrn_session::set_enabled(device_id id, bool enabled)
|
||||
if (tracking_control.set_enabled(to_tracking_control(id), enabled) and enabled)
|
||||
tracking_control.send(*connection, true);
|
||||
}
|
||||
void wivrn_session::set_tracker_enabled(int index, bool enabled)
|
||||
void wivrn_session::update_tracker_enabled()
|
||||
{
|
||||
assert(index < std::size(enabled_trackers));
|
||||
enabled_trackers[index] = enabled;
|
||||
bool keep_active = std::ranges::any_of(enabled_trackers, [](bool b) { return b; });
|
||||
if (tracking_control.set_enabled(to_headset::tracking_control::id::generic_tracker, keep_active))
|
||||
bool active = std::ranges::any_of(generic_trackers, [](auto & t) { return t->is_active(); });
|
||||
if (tracking_control.set_enabled(to_headset::tracking_control::id::generic_tracker, active) and active)
|
||||
tracking_control.send(*connection, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,9 +117,7 @@ class wivrn_session : public xrt_system_devices
|
||||
std::unique_ptr<wivrn_eye_tracker> eye_tracker;
|
||||
std::unique_ptr<wivrn_fb_face2_tracker> fb_face2_tracker;
|
||||
std::unique_ptr<wivrn_htc_face_tracker> htc_face_tracker;
|
||||
uint32_t num_generic_trackers;
|
||||
std::array<std::unique_ptr<wivrn_generic_tracker>, from_headset::body_tracking::max_tracked_poses> generic_trackers;
|
||||
std::array<bool, from_headset::body_tracking::max_tracked_poses> enabled_trackers;
|
||||
std::vector<std::unique_ptr<wivrn_generic_tracker>> generic_trackers;
|
||||
|
||||
std::shared_mutex comp_target_mutex;
|
||||
wivrn_comp_target * comp_target;
|
||||
@@ -169,7 +167,7 @@ public:
|
||||
|
||||
void set_enabled(to_headset::tracking_control::id id, bool enabled);
|
||||
void set_enabled(device_id id, bool enabled);
|
||||
void set_tracker_enabled(int index, bool enabled);
|
||||
void update_tracker_enabled();
|
||||
|
||||
void operator()(from_headset::crypto_handshake &&) {}
|
||||
void operator()(from_headset::pin_check_1 &&) {}
|
||||
|
||||
Reference in New Issue
Block a user