Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-06-10 11:29:14 +00:00
6 changed files with 29 additions and 25 deletions
-2
View File
@@ -1226,8 +1226,6 @@ void application::initialize()
if (fb_body_tracking_supported)
{
fb_body_tracker = xr_session.create_fb_body_tracker();
// HACK: always have an active body tracker so the quest runtime doesn't blow up (crash in random functions, controllers not working)
fb_body_tracker.start(false, false);
}
if (pico_body_tracking_supported)
+1 -10
View File
@@ -229,16 +229,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (config.check_feature(feature::body_tracking))
{
if (application::get_fb_body_tracking_supported())
{
auto num_trackers = config.fb_lower_body
? std::ranges::count_if(xr::fb_body_tracker::joint_whitelist, [&config](auto joint) {
return config.fb_hip || joint != XR_FULL_BODY_JOINT_HIPS_META;
})
: std::ranges::count_if(xr::fb_body_tracker::joint_whitelist, [](auto joint) {
return joint != XR_FULL_BODY_JOINT_HIPS_META && joint < XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META;
});
info.num_generic_trackers = num_trackers;
}
info.num_generic_trackers = xr::fb_body_tracker::get_whitelisted_joints(config.fb_lower_body, config.fb_hip).size();
else if (application::get_pico_body_tracking_supported())
info.num_generic_trackers = xr::pico_body_tracker::joint_whitelist.size();
}
+3 -2
View File
@@ -272,8 +272,9 @@ void scenes::stream::tracking()
if (application::get_fb_body_tracking_supported())
{
body_tracking = body_fb;
// We start the tracker on connection because there are toggleable settings.
// TODO maybe handle reconnection better, if the settings are changed the tracker count will mismatch and stuff might break
// 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
application::get_fb_body_tracker().stop();
application::get_fb_body_tracker().start(config.fb_lower_body, config.fb_hip);
}
+19 -8
View File
@@ -20,9 +20,23 @@
#include "spdlog/spdlog.h"
#include "xr/meta_body_tracking_fidelity.h"
#include "xr/xr.h"
#include <ranges>
#include <openxr/openxr.h>
static_assert(xr::pico_body_tracker::joint_whitelist.size() <= wivrn::from_headset::body_tracking::max_tracked_poses);
static_assert(xr::fb_body_tracker::joint_whitelist.size() <= wivrn::from_headset::body_tracking::max_tracked_poses);
std::vector<XrFullBodyJointMETA> xr::fb_body_tracker::get_whitelisted_joints(bool full_body, bool hip)
{
auto whitelisted_joints = std::ranges::filter_view(xr::fb_body_tracker::joint_whitelist, [=](auto joint) {
if (!full_body && (joint == XR_FULL_BODY_JOINT_HIPS_META || joint >= XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META))
return false;
if (!hip && joint == XR_FULL_BODY_JOINT_HIPS_META)
return false;
return true;
});
return {whitelisted_joints.begin(), whitelisted_joints.end()};
}
xr::fb_body_tracker::fb_body_tracker(instance & inst, session & s) :
s(s)
@@ -55,10 +69,13 @@ void xr::fb_body_tracker::start(bool full_body, bool hip)
// Enable IOBT.
CHECK_XR(xrRequestBodyTrackingFidelityMETA(handle, 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);
@@ -102,14 +119,8 @@ std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_h
std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses> poses{};
int num_poses = 0;
for (int i = 0; i < joint_whitelist.size(); i++)
for (auto joint: whitelisted_joints)
{
auto joint = joint_whitelist[i];
if (!full_body && (joint == XR_FULL_BODY_JOINT_HIPS_META || joint >= XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META))
continue;
if (!hip && joint == XR_FULL_BODY_JOINT_HIPS_META)
continue;
const auto & joint_loc = joints[joint];
wivrn::from_headset::body_tracking::pose pose{
.pose = joint_loc.pose,
+2
View File
@@ -42,6 +42,7 @@ class fb_body_tracker
bool full_body{};
bool hip{};
std::vector<XrFullBodyJointMETA> whitelisted_joints{};
public:
static constexpr std::array joint_whitelist{
@@ -56,6 +57,7 @@ public:
XR_FULL_BODY_JOINT_LEFT_FOOT_TRANSVERSE_META,
XR_FULL_BODY_JOINT_RIGHT_FOOT_TRANSVERSE_META,
};
static std::vector<XrFullBodyJointMETA> get_whitelisted_joints(bool full_body, bool hip);
fb_body_tracker() = default;
fb_body_tracker(instance & inst, session & s);
+4 -3
View File
@@ -63,9 +63,10 @@ std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_h
}
std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses> poses{};
for (int i = 0; i < joint_whitelist.size(); i++)
int num_poses = 0;
for (auto joint: joint_whitelist)
{
const auto & joint_loc = joints[joint_whitelist[i]];
const auto & joint_loc = joints[joint];
wivrn::from_headset::body_tracking::pose pose{
.pose = joint_loc.pose,
.flags = 0,
@@ -80,7 +81,7 @@ std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_h
if (joint_loc.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
pose.flags |= wivrn::from_headset::body_tracking::position_tracked;
poses[i] = pose;
poses[num_poses++] = pose;
}
return poses;
}