Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-07-03 11:13:41 +00:00
5 changed files with 28 additions and 65 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ jobs:
run: |
git config --global --add safe.directory $(pwd)
pip install toml aiohttp
tools/gen_flatpak_manifest.py --git https://github.com/${{github.repository}}.git --out flatpak
tools/gen_flatpak_manifest.py --gitlocal --out flatpak
cat flatpak/io.github.wivrn.wivrn.yml
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.4
+17 -8
View File
@@ -948,10 +948,17 @@ void application::initialize_actions()
if (!profile.available)
continue;
// Patch profile to add palm_ext
if (utils::contains(xr_extensions, 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"))
// Patch profile to add grip_surface or palm_ext
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") //
and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose"))
{
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) //
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"))
{
profile.input_sources.push_back("/user/hand/left/input/palm_ext/pose");
profile.input_sources.push_back("/user/hand/right/input/palm_ext/pose");
@@ -995,16 +1002,16 @@ void application::initialize_actions()
spaces[size_t(xr::spaces::grip_left)] = xr_session.create_action_space(a);
else if (name == "/user/hand/left/input/aim/pose")
spaces[size_t(xr::spaces::aim_left)] = xr_session.create_action_space(a);
else if (name == "/user/hand/left/input/palm_ext/pose" or name == "/user/hand/left/input/grip_surface/pose")
spaces[size_t(xr::spaces::palm_left)] = xr_session.create_action_space(a);
else if (name == "/user/hand/right/input/grip/pose")
spaces[size_t(xr::spaces::grip_right)] = xr_session.create_action_space(a);
else if (name == "/user/hand/right/input/aim/pose")
spaces[size_t(xr::spaces::aim_right)] = xr_session.create_action_space(a);
else if (name == "/user/hand/right/input/palm_ext/pose" or name == "/user/hand/right/input/grip_surface/pose")
spaces[size_t(xr::spaces::palm_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 == "/user/hand/right/input/palm_ext/pose")
spaces[size_t(xr::spaces::palm_right)] = xr_session.create_action_space(a);
else if (name == "/user/hand/left/input/palm_ext/pose")
spaces[size_t(xr::spaces::palm_left)] = 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));
}
@@ -1087,6 +1094,8 @@ void application::initialize()
// Optional extensions
std::vector<std::string> opt_extensions;
opt_extensions.push_back(XR_KHR_LOCATE_SPACES_EXTENSION_NAME);
opt_extensions.push_back(XR_KHR_MAINTENANCE1_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME);
opt_extensions.push_back(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
opt_extensions.push_back(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
+9 -9
View File
@@ -114,22 +114,22 @@ public:
locate_spaces_functor(xr::instance & instance, XrSpace reference) :
reference(reference)
{
if (instance.get_api_version() >= XR_MAKE_VERSION(1, 1, 0))
try
{
try
{
if (instance.get_api_version() >= XR_MAKE_VERSION(1, 1, 0))
locate_spaces = instance.get_proc<PFN_xrLocateSpaces>("xrLocateSpaces");
}
catch (std::exception & e)
{
spdlog::warn("Failed to load xrLocateSpaces function, fallback to xrLocateSpace");
}
else
locate_spaces = instance.get_proc<PFN_xrLocateSpacesKHR>("xrLocateSpacesKHR");
}
catch (std::exception & e)
{
spdlog::warn("Failed to load xrLocateSpaces function, fallback to xrLocateSpace");
}
}
void add_space(wivrn::device_id device, XrSpace space, XrTime t, std::vector<from_headset::tracking::pose> & out)
{
if (not locate_spaces)
if (locate_spaces)
{
// store, will be located later
devices.push_back(device);
+1 -44
View File
@@ -18,13 +18,10 @@
*/
#include "hand_tracker.h"
#include "hardware.h"
#include "xr/check.h"
#include "xr/instance.h"
#include "xr/session.h"
#include <cassert>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
static PFN_xrDestroyHandTrackerEXT xrDestroyHandTrackerEXT{};
@@ -33,8 +30,7 @@ XrResult xr::destroy_hand_tracker(XrHandTrackerEXT id)
return xrDestroyHandTrackerEXT(id);
}
xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info) :
hand_id(info.hand)
xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info)
{
static auto xrCreateHandTrackerEXT = inst.get_proc<PFN_xrCreateHandTrackerEXT>("xrCreateHandTrackerEXT");
assert(xrCreateHandTrackerEXT);
@@ -81,48 +77,9 @@ std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::
if (!std::ranges::any_of(joints_pos, [](const auto & loc) { return loc.locationFlags != 0; }))
return std::nullopt;
float offset_angle = 0;
// check if we have a device that needs a thumb offset
switch (guess_model())
{
case model::meta_quest_3:
case model::meta_quest_pro:
case model::meta_quest_3s:
case model::oculus_quest:
case model::oculus_quest_2:
if (hand_id == XR_HAND_LEFT_EXT)
offset_angle = glm::radians(-90.0f);
else if (hand_id == XR_HAND_RIGHT_EXT)
offset_angle = glm::radians(90.0f);
break;
default:
break;
}
std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT> joints;
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
if (i >= XR_HAND_JOINT_THUMB_METACARPAL_EXT && i <= XR_HAND_JOINT_THUMB_TIP_EXT)
{
// Need to convert the XrQuaternionf to a glm::quat to use glm::rotate
glm::quat q(
joints_pos[i].pose.orientation.w,
joints_pos[i].pose.orientation.x,
joints_pos[i].pose.orientation.y,
joints_pos[i].pose.orientation.z);
glm::quat offset_rotation = glm::rotate(q, offset_angle, glm::vec3(0, 0, 1));
joints_pos[i].pose.orientation = {
.x = offset_rotation.x,
.y = offset_rotation.y,
.z = offset_rotation.z,
.w = offset_rotation.w,
};
}
joints[i] = {joints_pos[i], joints_vel[i]};
}
-3
View File
@@ -43,8 +43,5 @@ public:
std::optional<std::array<joint, XR_HAND_JOINT_COUNT_EXT>> locate(XrSpace space, XrTime time);
static bool check_flags(const std::array<joint, XR_HAND_JOINT_COUNT_EXT> & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity);
private:
XrHandEXT hand_id;
};
} // namespace xr