From 6a72c537c2eba5f7897d5eca025e6dd6afcf98e9 Mon Sep 17 00:00:00 2001 From: EasonZxp Date: Tue, 26 May 2026 15:40:37 +0800 Subject: [PATCH] Add FB hand mesh support with GLB fallback (#934) Use the XR_FB_HAND_TRACKING_MESH extension to render hand models when supported, and fall back to the bundled GLB hand models otherwise. This fixes incorrect hand model rendering on PFDM MR device, Have tested with PFDM MR V4.5.0 version. --- client/application.cpp | 1 + client/render/gpu_buffer.h | 7 + client/scene.cpp | 21 +++ client/scene.h | 3 + client/scenes/hand_model.cpp | 243 +++++++++++++++++++++++++++++++++++ client/scenes/hand_model.h | 5 + client/scenes/lobby.cpp | 21 ++- client/xr/hand_tracker.cpp | 120 +++++++++++++++++ client/xr/hand_tracker.h | 24 +++- client/xr/system.cpp | 8 ++ client/xr/system.h | 2 + 11 files changed, 451 insertions(+), 4 deletions(-) diff --git a/client/application.cpp b/client/application.cpp index 4cb1a58e..04636c61 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -1202,6 +1202,7 @@ void application::initialize() XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME, XR_EXT_HAND_INTERACTION_EXTENSION_NAME, XR_EXT_HAND_TRACKING_EXTENSION_NAME, + XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME, XR_EXT_PALM_POSE_EXTENSION_NAME, XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME, XR_EXT_USER_PRESENCE_EXTENSION_NAME, diff --git a/client/render/gpu_buffer.h b/client/render/gpu_buffer.h index d1c06d9a..9c312944 100644 --- a/client/render/gpu_buffer.h +++ b/client/render/gpu_buffer.h @@ -24,6 +24,7 @@ #include "vk/allocation.h" #include #include +#include #include #include @@ -90,6 +91,12 @@ public: return add(alignment, data_to_add); } + size_t add_indices(std::span indices) + { + usage |= vk::BufferUsageFlagBits::eIndexBuffer; + return add(4, indices.data(), indices.size_bytes()); + } + std::pair add_indices(const fastgltf::Accessor & accessor) { usage |= vk::BufferUsageFlagBits::eIndexBuffer; diff --git a/client/scene.cpp b/client/scene.cpp index 6237d258..0c209aa6 100644 --- a/client/scene.cpp +++ b/client/scene.cpp @@ -25,6 +25,7 @@ #include "utils/i18n.h" #include "utils/overloaded.h" #include "utils/ranges.h" +#include #include #include #include @@ -529,6 +530,26 @@ std::pair scene::add_gltf(const std::filesyste return add_gltf(load_gltf(path), layer_mask); } +std::shared_ptr scene::create_material(std::function init) const +{ + auto material = std::make_shared(*renderer->get_default_material()); + if (init) + init(*material); + + material->buffer = std::make_shared( + device, + vk::BufferCreateInfo{ + .size = sizeof(material->staging), + .usage = vk::BufferUsageFlagBits::eUniformBuffer}, + VmaAllocationCreateInfo{ + .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, + .usage = VMA_MEMORY_USAGE_AUTO}); + material->offset = 0; + std::memcpy(material->buffer->map(), &material->staging, sizeof(material->staging)); + material->buffer->unmap(); + return material; +} + void scene::remove(entt::entity entity) { std::vector to_be_removed{entity}; diff --git a/client/scene.h b/client/scene.h index 31f57816..69a90b1d 100644 --- a/client/scene.h +++ b/client/scene.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -218,6 +219,8 @@ public: entt::registry world; + std::shared_ptr create_material(std::function init = {}) const; + std::shared_ptr load_gltf(const std::filesystem::path & path, std::function progress_cb = {}); void unload_gltf(const std::filesystem::path & path); std::pair add_gltf(std::shared_ptr gltf, uint32_t layer_mask = -1); diff --git a/client/scenes/hand_model.cpp b/client/scenes/hand_model.cpp index 29e05c0a..1e257dd2 100644 --- a/client/scenes/hand_model.cpp +++ b/client/scenes/hand_model.cpp @@ -18,10 +18,21 @@ #include "hand_model.h" #include "openxr/openxr.h" +#include "render/gpu_buffer.h" #include "render/scene_components.h" +#include "vk/shader.h" +#include +#include +#include +#include #include +#include +#include #include #include +#include +#include +#include namespace components { @@ -30,8 +41,175 @@ struct hand_joint XrHandEXT hand; XrHandJointEXT joint; }; + +struct hand_mesh_fb_root +{ + XrHandEXT hand; +}; } // namespace components +static glm::vec3 to_vec3(const XrVector3f & value) +{ + return {value.x, value.y, value.z}; +} + +static glm::quat to_quat(const XrQuaternionf & value) +{ + return glm::quat(value.w, value.x, value.y, value.z); +} + +static glm::mat4 to_matrix(const XrPosef & pose) +{ + return glm::translate(glm::mat4(1), to_vec3(pose.position)) * glm::mat4_cast(to_quat(pose.orientation)); +} + +template +static void write_vertex_attribute(std::vector & buffer, size_t stride, size_t offset, size_t index, const T & value) +{ + std::memcpy(buffer.data() + index * stride + offset, &value, sizeof(value)); +} + +static std::string normalize_hand_mesh_fb_semantic(std::string semantic) +{ + std::transform(semantic.begin(), semantic.end(), semantic.begin(), [](unsigned char c) { + return static_cast(std::toupper(c)); + }); + + if (semantic.starts_with("IN_")) + semantic = semantic.substr(3); + + return semantic; +} + +static renderer::vertex_layout create_hand_mesh_fb_layout(scene & scene) +{ + renderer::vertex_layout layout; + auto shader = load_shader(scene.device, "lit_skinned.vert"); + for (const auto & input: shader->inputs) + { + std::string semantic = normalize_hand_mesh_fb_semantic(input.name); + const uint32_t binding = semantic == "POSITION" || semantic == "JOINTS" || semantic == "WEIGHTS" ? 0 : 1; + layout.add_vertex_attribute(semantic, input.format, binding, input.location, input.array_size); + } + return layout; +} + +static const vk::VertexInputBindingDescription & find_hand_mesh_fb_binding(const renderer::vertex_layout & layout, uint32_t binding) +{ + for (const auto & description: layout.bindings) + if (description.binding == binding) + return description; + + throw std::runtime_error("Missing hand mesh FB vertex binding"); +} + +static const vk::VertexInputAttributeDescription & find_hand_mesh_fb_attribute(const renderer::vertex_layout & layout, std::string_view semantic) +{ + for (size_t i = 0; i < layout.attribute_names.size(); ++i) + if (layout.attribute_names[i] == semantic) + return layout.attributes.at(i); + + throw std::runtime_error("Missing hand mesh FB vertex attribute"); +} + +static std::shared_ptr create_hand_mesh_fb_material(scene & scene, XrHandEXT hand) +{ + return scene.create_material([hand](renderer::material & material) { + material.staging.base_color_factor = {0.5f, 0.5f, 0.5f, 1.0f}; + material.staging.metallic_factor = 0.0f; + material.staging.roughness_factor = 0.5527864f; + material.name = hand == XR_HAND_LEFT_EXT ? "left-hand-mesh-material" : "right-hand-mesh-material"; + material.double_sided = false; + material.blend_enable = false; + }); +} + +static std::shared_ptr create_hand_mesh_fb_mesh(scene & scene, const xr::hand_tracker::mesh_data & mesh) +{ + std::vector indices; + indices.reserve(mesh.indices.size()); + for (int16_t index: mesh.indices) + indices.push_back(static_cast(index)); + + auto layout = create_hand_mesh_fb_layout(scene); + const auto & binding_0_layout = find_hand_mesh_fb_binding(layout, 0); + const auto & binding_1_layout = find_hand_mesh_fb_binding(layout, 1); + const size_t position_offset = find_hand_mesh_fb_attribute(layout, "POSITION").offset; + const size_t joints_offset = find_hand_mesh_fb_attribute(layout, "JOINTS").offset; + const size_t weights_offset = find_hand_mesh_fb_attribute(layout, "WEIGHTS").offset; + const size_t normal_offset = find_hand_mesh_fb_attribute(layout, "NORMAL").offset; + const size_t tangent_offset = find_hand_mesh_fb_attribute(layout, "TANGENT").offset; + const size_t texcoord_0_offset = find_hand_mesh_fb_attribute(layout, "TEXCOORD_0").offset; + const size_t texcoord_1_offset = find_hand_mesh_fb_attribute(layout, "TEXCOORD_1").offset; + const size_t color_offset = find_hand_mesh_fb_attribute(layout, "COLOR").offset; + std::vector binding_0(mesh.vertex_positions.size() * binding_0_layout.stride); + std::vector binding_1(mesh.vertex_positions.size() * binding_1_layout.stride); + + glm::vec3 obb_min; + glm::vec3 obb_max; + for (size_t i = 0; i < mesh.vertex_positions.size(); ++i) + { + glm::vec3 position = to_vec3(mesh.vertex_positions.at(i)); + glm::vec3 normal = to_vec3(mesh.vertex_normals.at(i)); + glm::vec4 tangent{}; + glm::vec2 texcoord_0{mesh.vertex_uvs.at(i).x, mesh.vertex_uvs.at(i).y}; + glm::vec2 texcoord_1{}; + glm::vec4 color{1, 1, 1, 1}; + glm::vec4 joints{ + static_cast(mesh.vertex_blend_indices.at(i).x), + static_cast(mesh.vertex_blend_indices.at(i).y), + static_cast(mesh.vertex_blend_indices.at(i).z), + static_cast(mesh.vertex_blend_indices.at(i).w)}; + glm::vec4 weights{ + mesh.vertex_blend_weights.at(i).x, + mesh.vertex_blend_weights.at(i).y, + mesh.vertex_blend_weights.at(i).z, + mesh.vertex_blend_weights.at(i).w}; + + if (i == 0) + obb_min = obb_max = position; + else + { + obb_min.x = std::min(obb_min.x, position.x); + obb_min.y = std::min(obb_min.y, position.y); + obb_min.z = std::min(obb_min.z, position.z); + obb_max.x = std::max(obb_max.x, position.x); + obb_max.y = std::max(obb_max.y, position.y); + obb_max.z = std::max(obb_max.z, position.z); + } + + write_vertex_attribute(binding_0, binding_0_layout.stride, position_offset, i, position); + write_vertex_attribute(binding_0, binding_0_layout.stride, joints_offset, i, joints); + write_vertex_attribute(binding_0, binding_0_layout.stride, weights_offset, i, weights); + write_vertex_attribute(binding_1, binding_1_layout.stride, normal_offset, i, normal); + write_vertex_attribute(binding_1, binding_1_layout.stride, tangent_offset, i, tangent); + write_vertex_attribute(binding_1, binding_1_layout.stride, texcoord_0_offset, i, texcoord_0); + write_vertex_attribute(binding_1, binding_1_layout.stride, texcoord_1_offset, i, texcoord_1); + write_vertex_attribute(binding_1, binding_1_layout.stride, color_offset, i, color); + } + + fastgltf::Asset asset; + gpu_buffer staging_buffer(scene.physical_device, asset); + auto hand_mesh_fb_mesh = std::make_shared(); + auto & primitive = hand_mesh_fb_mesh->primitives.emplace_back(); + primitive.indexed = true; + primitive.index_count = indices.size(); + primitive.vertex_count = mesh.vertex_positions.size(); + primitive.index_type = vk::IndexType::eUint16; + primitive.index_offset = staging_buffer.add_indices(indices); + primitive.vertex_offset.push_back(staging_buffer.add_vertices(binding_0)); + primitive.vertex_offset.push_back(staging_buffer.add_vertices(binding_1)); + primitive.layout = std::move(layout); + primitive.obb_min = obb_min; + primitive.obb_max = obb_max; + primitive.vertex_shader = "lit_skinned.vert"; + primitive.cull_mode = vk::CullModeFlagBits::eBack; + primitive.front_face = vk::FrontFace::eCounterClockwise; + primitive.topology = vk::PrimitiveTopology::eTriangleList; + hand_mesh_fb_mesh->buffer = std::make_shared(staging_buffer.copy_to_gpu(scene.device)); + return hand_mesh_fb_mesh; +} + static const std::array, XR_HAND_JOINT_COUNT_EXT - 1 /* No palm in gltf */> joints{{ // clang-format off {XR_HAND_JOINT_WRIST_EXT, "wrist"}, @@ -82,6 +260,34 @@ void hand_model::add_hand(scene & scene, scene.world.emplace(entity, hand, (XrHandJointEXT)-1); } +void hand_model::add_hand(scene & scene, + XrHandEXT hand, + const xr::hand_tracker::mesh_data & mesh, + uint32_t layer_mask) +{ + auto material = create_hand_mesh_fb_material(scene, hand); + + entt::entity entity = scene.world.create(); + auto & node = scene.world.emplace(entity); + node.name = hand == XR_HAND_LEFT_EXT ? "left-hand-mesh" : "right-hand-mesh"; + node.mesh = create_hand_mesh_fb_mesh(scene, mesh); + for (auto & primitive: node.mesh->primitives) + primitive.material_ = material; + node.visible = false; + node.layer_mask = layer_mask; + node.joints.reserve(mesh.joint_bind_poses.size()); + scene.world.emplace(entity, hand); + + for (size_t i = 0; i < mesh.joint_bind_poses.size(); ++i) + { + entt::entity joint_entity = scene.world.create(); + auto & joint_node = scene.world.emplace(joint_entity); + joint_node.parent = entity; + joint_node.name = std::string(magic_enum::enum_name(static_cast(i))); + node.joints.emplace_back(joint_entity, glm::inverse(to_matrix(mesh.joint_bind_poses[i]))); + } +} + void hand_model::apply(entt::registry & scene, const std::optional> & left_hand, const std::optional> & right_hand) @@ -127,4 +333,41 @@ void hand_model::apply(entt::registry & scene, break; } } + + for (auto && [entity, hand_root, node]: scene.view().each()) + { + const auto & joints = hand_root.hand == XR_HAND_LEFT_EXT ? left_hand : right_hand; + if (!joints) + { + node.visible = false; + continue; + } + + node.visible = true; + + const auto & wrist_pose = (*joints)[XR_HAND_JOINT_WRIST_EXT].first.pose; + glm::vec3 wrist_position = to_vec3(wrist_pose.position); + glm::quat wrist_orientation = to_quat(wrist_pose.orientation); + glm::quat wrist_orientation_inv = glm::conjugate(wrist_orientation); + + node.position = wrist_position; + node.orientation = wrist_orientation; + + for (size_t i = 0; i < node.joints.size(); ++i) + { + auto & joint_node = scene.get(node.joints[i].first); + if (i == XR_HAND_JOINT_WRIST_EXT) + { + joint_node.position = {}; + joint_node.orientation = {1, 0, 0, 0}; + continue; + } + + const auto & pose = (*joints)[i].first.pose; + glm::vec3 position = to_vec3(pose.position); + glm::quat orientation = to_quat(pose.orientation); + joint_node.position = wrist_orientation_inv * (position - wrist_position); + joint_node.orientation = glm::normalize(wrist_orientation_inv * orientation); + } + } } diff --git a/client/scenes/hand_model.h b/client/scenes/hand_model.h index 44d0b71e..83824c7c 100644 --- a/client/scenes/hand_model.h +++ b/client/scenes/hand_model.h @@ -31,6 +31,11 @@ void add_hand(scene & scene, const std::filesystem::path & gltf_path, uint32_t layer_mask); +void add_hand(scene & scene, + XrHandEXT hand, + const xr::hand_tracker::mesh_data & mesh, + uint32_t layer_mask); + void apply(entt::registry & scene, const std::optional> & left_hand, const std::optional> & right_hand); diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index faf1c3c0..4c7b4997 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -1176,8 +1176,25 @@ void scenes::lobby::on_focused() { 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, "assets://left-hand.glb", layer_controllers); - hand_model::add_hand(*this, XR_HAND_RIGHT_EXT, "assets://right-hand.glb", layer_controllers); + + bool using_hand_mesh_fb = false; + if (system.hand_mesh_fb_supported()) + { + const auto * left_hand_mesh_fb = left_hand->mesh(); + const auto * right_hand_mesh_fb = right_hand->mesh(); + if (left_hand_mesh_fb and right_hand_mesh_fb) + { + hand_model::add_hand(*this, XR_HAND_LEFT_EXT, *left_hand_mesh_fb, layer_controllers); + hand_model::add_hand(*this, XR_HAND_RIGHT_EXT, *right_hand_mesh_fb, layer_controllers); + using_hand_mesh_fb = true; + } + } + + if (!using_hand_mesh_fb) + { + hand_model::add_hand(*this, XR_HAND_LEFT_EXT, "assets://left-hand.glb", layer_controllers); + hand_model::add_hand(*this, XR_HAND_RIGHT_EXT, "assets://right-hand.glb", layer_controllers); + } } std::vector imgui_inputs{ diff --git a/client/xr/hand_tracker.cpp b/client/xr/hand_tracker.cpp index 1be57f10..343657b4 100644 --- a/client/xr/hand_tracker.cpp +++ b/client/xr/hand_tracker.cpp @@ -21,7 +21,10 @@ #include "xr/check.h" #include "xr/instance.h" #include "xr/session.h" +#include "xr/to_string.h" +#include #include +#include xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info) : handle(inst.get_proc("xrDestroyHandTrackerEXT")) @@ -29,6 +32,8 @@ xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandT auto xrCreateHandTrackerEXT = inst.get_proc("xrCreateHandTrackerEXT"); assert(xrCreateHandTrackerEXT); xrLocateHandJointsEXT = inst.get_proc("xrLocateHandJointsEXT"); + if (inst.has_extension(XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME)) + xrGetHandMeshFB = inst.get_proc("xrGetHandMeshFB"); CHECK_XR(xrCreateHandTrackerEXT(session, &info, &id)); } @@ -87,6 +92,121 @@ std::optional> xr:: return joints; } +const xr::hand_tracker::mesh_data * xr::hand_tracker::mesh() +{ + if (hand_mesh_fb_fetched) + return cached_hand_mesh_fb ? &*cached_hand_mesh_fb : nullptr; + + hand_mesh_fb_fetched = true; + + if (!id || !xrGetHandMeshFB) + return nullptr; + + XrHandTrackingMeshFB mesh{ + .type = XR_TYPE_HAND_TRACKING_MESH_FB, + }; + + XrResult result = xrGetHandMeshFB(id, &mesh); + if (XR_FAILED(result)) + { + spdlog::warn("xrGetHandMeshFB count query failed: {}", xr::to_string(result)); + return nullptr; + } + + if (mesh.jointCountOutput != XR_HAND_JOINT_COUNT_EXT) + { + spdlog::warn("Unsupported hand mesh joint count {}", mesh.jointCountOutput); + return nullptr; + } + + if (mesh.jointCountOutput > 32) + { + spdlog::warn("Hand mesh joint count {} exceeds renderer limit", mesh.jointCountOutput); + return nullptr; + } + + if (mesh.vertexCountOutput == 0 || mesh.indexCountOutput == 0) + { + spdlog::warn("Hand mesh data is empty"); + return nullptr; + } + + mesh_data data; + data.joint_bind_poses.resize(mesh.jointCountOutput); + data.joint_radii.resize(mesh.jointCountOutput); + data.joint_parents.resize(mesh.jointCountOutput); + data.vertex_positions.resize(mesh.vertexCountOutput); + data.vertex_normals.resize(mesh.vertexCountOutput); + data.vertex_uvs.resize(mesh.vertexCountOutput); + data.vertex_blend_indices.resize(mesh.vertexCountOutput); + data.vertex_blend_weights.resize(mesh.vertexCountOutput); + data.indices.resize(mesh.indexCountOutput); + + mesh.jointCapacityInput = data.joint_bind_poses.size(); + mesh.jointBindPoses = data.joint_bind_poses.data(); + mesh.jointRadii = data.joint_radii.data(); + mesh.jointParents = data.joint_parents.data(); + mesh.vertexCapacityInput = data.vertex_positions.size(); + mesh.vertexPositions = data.vertex_positions.data(); + mesh.vertexNormals = data.vertex_normals.data(); + mesh.vertexUVs = data.vertex_uvs.data(); + mesh.vertexBlendIndices = data.vertex_blend_indices.data(); + mesh.vertexBlendWeights = data.vertex_blend_weights.data(); + mesh.indexCapacityInput = data.indices.size(); + mesh.indices = data.indices.data(); + + result = xrGetHandMeshFB(id, &mesh); + if (XR_FAILED(result)) + { + spdlog::warn("xrGetHandMeshFB data query failed: {}", xr::to_string(result)); + return nullptr; + } + + auto count_changed = [](const char * what, uint32_t output, size_t expected) { + if (output == expected) + return false; + spdlog::warn("Hand mesh {} count changed from {} to {}", what, expected, output); + return true; + }; + + if (count_changed("joint", mesh.jointCountOutput, data.joint_bind_poses.size()) || + count_changed("vertex", mesh.vertexCountOutput, data.vertex_positions.size()) || + count_changed("index", mesh.indexCountOutput, data.indices.size())) + { + return nullptr; + } + + if (mesh.indexCountOutput % 3 != 0) + { + spdlog::warn("Hand mesh index count {} is not a triangle list", mesh.indexCountOutput); + return nullptr; + } + + const int joint_count = static_cast(mesh.jointCountOutput); + if (!std::ranges::all_of(data.vertex_blend_indices, [joint_count](const XrVector4sFB & blend_indices) { + return 0 <= blend_indices.x && blend_indices.x < joint_count && + 0 <= blend_indices.y && blend_indices.y < joint_count && + 0 <= blend_indices.z && blend_indices.z < joint_count && + 0 <= blend_indices.w && blend_indices.w < joint_count; + })) + { + spdlog::warn("Hand mesh has out-of-range blend indices"); + return nullptr; + } + + const int vertex_count = static_cast(mesh.vertexCountOutput); + if (!std::ranges::all_of(data.indices, [vertex_count](int16_t index) { + return 0 <= index && index < vertex_count; + })) + { + spdlog::warn("Hand mesh has out-of-range indices"); + return nullptr; + } + + cached_hand_mesh_fb = std::move(data); + return &*cached_hand_mesh_fb; +} + bool xr::hand_tracker::check_flags(const std::array & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity) { return std::ranges::all_of(joints, [position, velocity](const auto & joint) { diff --git a/client/xr/hand_tracker.h b/client/xr/hand_tracker.h index 25c3a228..d079d5c5 100644 --- a/client/xr/hand_tracker.h +++ b/client/xr/hand_tracker.h @@ -22,6 +22,7 @@ #include "utils/handle.h" #include #include +#include #include namespace xr @@ -31,14 +32,33 @@ class session; class hand_tracker : public utils::handle { +public: + using joint = std::pair; + + struct mesh_data + { + std::vector joint_bind_poses; + std::vector joint_radii; + std::vector joint_parents; + std::vector vertex_positions; + std::vector vertex_normals; + std::vector vertex_uvs; + std::vector vertex_blend_indices; + std::vector vertex_blend_weights; + std::vector indices; + }; + +private: PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT{}; + PFN_xrGetHandMeshFB xrGetHandMeshFB{}; + std::optional cached_hand_mesh_fb; + bool hand_mesh_fb_fetched = false; public: hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info); - using joint = std::pair; - std::optional> locate(XrSpace space, XrTime time); + const mesh_data * mesh(); static bool check_flags(const std::array & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity); }; diff --git a/client/xr/system.cpp b/client/xr/system.cpp index 0ad34e48..18607c25 100644 --- a/client/xr/system.cpp +++ b/client/xr/system.cpp @@ -47,6 +47,9 @@ xr::system::system(xr::instance & inst, XrFormFactor formfactor) if (inst.has_extension(XR_EXT_HAND_TRACKING_EXTENSION_NAME)) hand_tracking_supported_ = hand_tracking_properties().supportsHandTracking; + if (hand_tracking_supported_ and inst.has_extension(XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME)) + hand_mesh_fb_supported_ = true; + body_tracker = xr::body_tracker_supported(inst, *this); face_tracker = xr::face_tracker_supported(inst, *this); } @@ -275,6 +278,11 @@ bool xr::system::hand_tracking_supported() const return hand_tracking_supported_; } +bool xr::system::hand_mesh_fb_supported() const +{ + return hand_mesh_fb_supported_; +} + vk::raii::PhysicalDevice xr::system::physical_device(vk::raii::Instance & vulkan) const { auto xrGetVulkanGraphicsDevice2KHR = diff --git a/client/xr/system.h b/client/xr/system.h index 3b1cb8a1..d6e314a0 100644 --- a/client/xr/system.h +++ b/client/xr/system.h @@ -61,6 +61,7 @@ class system instance * inst = nullptr; XrSystemId id = XR_NULL_SYSTEM_ID; bool hand_tracking_supported_ = false; + bool hand_mesh_fb_supported_ = false; passthrough_type passthrough; body_tracker_type body_tracker; face_tracker_type face_tracker; @@ -91,6 +92,7 @@ public: XrSystemBodyTrackingPropertiesBD bd_body_tracking_properties() const; bool hand_tracking_supported() const; + bool hand_mesh_fb_supported() const; passthrough_type passthrough_supported() const; face_tracker_type face_tracker_supported() const; body_tracker_type body_tracker_supported() const;