Rebase almost everything to Master
This commit is contained in:
+131
-159
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "application.h"
|
||||
#include "asset.h"
|
||||
|
||||
#include "hardware.h"
|
||||
#include "openxr/openxr.h"
|
||||
#include "scene.h"
|
||||
@@ -26,18 +26,23 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/files.h"
|
||||
#include "utils/i18n.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>
|
||||
@@ -67,7 +72,6 @@ struct interaction_profile
|
||||
std::string profile_name;
|
||||
std::vector<std::string> required_extensions;
|
||||
XrVersion min_version = XR_MAKE_VERSION(1, 0, 0);
|
||||
XrVersion max_version = XR_MAKE_VERSION(2, 0, 0); // exclusive
|
||||
std::vector<std::string> input_sources;
|
||||
bool available;
|
||||
};
|
||||
@@ -134,8 +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"},
|
||||
.max_version = XR_MAKE_VERSION(1, 1, 0),
|
||||
.required_extensions = {XR_FB_TOUCH_CONTROLLER_PRO_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/left/output/haptic_trigger_fb",
|
||||
@@ -247,8 +250,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"},
|
||||
.max_version = XR_MAKE_VERSION(1, 1, 0),
|
||||
.required_extensions = {XR_META_TOUCH_CONTROLLER_PLUS_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -348,7 +350,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 +393,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 +436,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 +479,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 +521,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 +550,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",
|
||||
},
|
||||
@@ -649,6 +654,7 @@ VkBool32 application::vulkan_debug_report_callback(
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool my_error = true;
|
||||
if (level >= spdlog::level::warn)
|
||||
{
|
||||
bool validation_layer_found = false;
|
||||
@@ -659,10 +665,13 @@ VkBool32 application::vulkan_debug_report_callback(
|
||||
|
||||
if (validation_layer_found && i.library != "libVkLayer_khronos_validation.so")
|
||||
spdlog::log(level, "{:#016x}: {} + {:#x}", i.pc, i.library, i.pc - i.library_base);
|
||||
|
||||
if (i.library == "libopenxr_loader.so")
|
||||
my_error = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (level >= spdlog::level::err)
|
||||
if (level >= spdlog::level::err and my_error)
|
||||
abort();
|
||||
#endif
|
||||
|
||||
@@ -717,15 +726,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,28 +741,27 @@ 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);
|
||||
optional_device_extensions.emplace(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
vk_device_extensions.push_back(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
|
||||
@@ -874,6 +880,7 @@ void application::initialize_vulkan()
|
||||
.ppEnabledExtensionNames = vk_device_extensions.data(),
|
||||
.pEnabledFeatures = &device_features,
|
||||
},
|
||||
vk::PhysicalDeviceFragmentShadingRateFeaturesKHR{},
|
||||
#ifdef __ANDROID__
|
||||
vk::PhysicalDeviceSamplerYcbcrConversionFeaturesKHR{
|
||||
.samplerYcbcrConversion = VK_TRUE,
|
||||
@@ -881,6 +888,22 @@ void application::initialize_vulkan()
|
||||
#endif
|
||||
};
|
||||
|
||||
if (utils::contains(vk_device_extensions, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME) and
|
||||
utils::contains(vk_device_extensions, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME))
|
||||
{
|
||||
auto [feat, fragment_feat] = vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceFragmentShadingRateFeaturesKHR>();
|
||||
auto & create_feat = device_create_info.get<vk::PhysicalDeviceFragmentShadingRateFeaturesKHR>();
|
||||
create_feat.primitiveFragmentShadingRate = fragment_feat.primitiveFragmentShadingRate;
|
||||
create_feat.attachmentFragmentShadingRate = fragment_feat.attachmentFragmentShadingRate;
|
||||
spdlog::info("Fragment shading rate features: primitive={} attachment={}",
|
||||
create_feat.primitiveFragmentShadingRate,
|
||||
create_feat.attachmentFragmentShadingRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
device_create_info.unlink<vk::PhysicalDeviceFragmentShadingRateFeaturesKHR>();
|
||||
}
|
||||
|
||||
vk_device = xr_system_id.create_device(vk_physical_device, device_create_info.get());
|
||||
*vk_queue.lock() = vk_device.getQueue(vk_queue_family_index, 0);
|
||||
|
||||
@@ -902,10 +925,16 @@ void application::initialize_vulkan()
|
||||
pipeline_cache = vk::raii::PipelineCache(vk_device, pipeline_cache_info);
|
||||
|
||||
allocator.emplace(VmaAllocatorCreateInfo{
|
||||
.physicalDevice = *vk_physical_device,
|
||||
.device = *vk_device,
|
||||
.instance = *vk_instance,
|
||||
});
|
||||
.physicalDevice = *vk_physical_device,
|
||||
.device = *vk_device,
|
||||
.instance = *vk_instance,
|
||||
},
|
||||
#ifndef NDEBUG
|
||||
debug_utils_found
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
void application::log_views()
|
||||
@@ -952,8 +981,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");
|
||||
@@ -967,7 +994,8 @@ 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;
|
||||
|
||||
if (profile.profile_name.ends_with("khr/simple_controller"))
|
||||
{
|
||||
@@ -1008,15 +1036,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"))
|
||||
{
|
||||
@@ -1027,14 +1055,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,8 +1111,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
|
||||
@@ -1120,7 +1155,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)});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1137,7 +1172,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
|
||||
@@ -1157,7 +1192,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);
|
||||
@@ -1230,21 +1265,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;
|
||||
@@ -1252,93 +1282,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;
|
||||
@@ -1348,50 +1330,47 @@ void application::initialize()
|
||||
vk_cmdpool = vk::raii::CommandPool{vk_device, cmdpool_create_info};
|
||||
|
||||
initialize_actions();
|
||||
load_locale();
|
||||
}
|
||||
|
||||
void application::load_locale()
|
||||
{
|
||||
gen.add_messages_domain("wivrn");
|
||||
std::locale loc = gen("");
|
||||
|
||||
messages_info.encoding = "UTF-8";
|
||||
if (config->locale.empty())
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
jni::klass java_util_Locale("java/util/Locale");
|
||||
auto default_locale = java_util_Locale.call<jni::object<"java/util/Locale">>("getDefault");
|
||||
jni::klass java_util_Locale("java/util/Locale");
|
||||
auto default_locale = java_util_Locale.call<jni::object<"java/util/Locale">>("getDefault");
|
||||
|
||||
// if (auto language = default_locale.call<jni::string>("toString"))
|
||||
if (auto language = default_locale.call<jni::string>("getLanguage"))
|
||||
messages_info.language = language;
|
||||
|
||||
if (auto country = default_locale.call<jni::string>("getCountry"))
|
||||
messages_info.country = country;
|
||||
|
||||
messages_info.encoding = "UTF-8";
|
||||
// if (auto language = default_locale.call<jni::string>("toString"))
|
||||
if (auto language = default_locale.call<jni::string>("getLanguage"))
|
||||
messages_info.language = language;
|
||||
|
||||
if (auto country = default_locale.call<jni::string>("getCountry"))
|
||||
messages_info.country = country;
|
||||
#else
|
||||
auto & facet = std::use_facet<boost::locale::info>(loc);
|
||||
messages_info.language = facet.language();
|
||||
messages_info.country = facet.country();
|
||||
messages_info.encoding = "UTF-8";
|
||||
auto & facet = std::use_facet<boost::locale::info>(loc);
|
||||
messages_info.language = facet.language();
|
||||
messages_info.country = facet.country();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pos = config->locale.find("_");
|
||||
messages_info.language = config->locale.substr(0, pos);
|
||||
if (pos != std::string::npos)
|
||||
messages_info.country = config->locale.substr(pos + 1);
|
||||
}
|
||||
|
||||
spdlog::info("Current locale: language {}, country {}, encoding {}", messages_info.language, messages_info.country, messages_info.encoding);
|
||||
|
||||
messages_info.paths.push_back("locale");
|
||||
|
||||
messages_info.domains.push_back(boost::locale::gnu_gettext::messages_info::domain("wivrn"));
|
||||
messages_info.callback = [](const std::string & file_name, const std::string & encoding) {
|
||||
std::vector<char> buffer;
|
||||
try
|
||||
{
|
||||
asset file(file_name);
|
||||
buffer.resize(file.size());
|
||||
memcpy(buffer.data(), file.data(), file.size());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
return buffer;
|
||||
};
|
||||
|
||||
messages_info.callback = open_locale_file;
|
||||
loc = std::locale(loc, boost::locale::gnu_gettext::create_messages_facet<char>(messages_info));
|
||||
|
||||
std::locale::global(loc);
|
||||
@@ -1875,13 +1854,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: {
|
||||
|
||||
Reference in New Issue
Block a user