Add hip tracking toggle for fb body tracking

* Only forward hip joint from FB_body_tracking when lower body is enabled

* Fix body tracking tooltips being too wide
This commit is contained in:
Sapphire
2025-06-08 18:07:23 +02:00
committed by xytovl
parent 1d6b444ec6
commit 40f02b9404
7 changed files with 34 additions and 12 deletions
+3
View File
@@ -226,6 +226,8 @@ configuration::configuration(xr::system & system)
if (auto val = root["fb_lower_body"]; val.is_bool()) if (auto val = root["fb_lower_body"]; val.is_bool())
fb_lower_body = val.get_bool(); fb_lower_body = val.get_bool();
if (auto val = root["fb_hip"]; val.is_bool())
fb_hip = val.get_bool();
if (auto val = root["virtual_keyboard_layout"]; val.is_string()) if (auto val = root["virtual_keyboard_layout"]; val.is_string())
virtual_keyboard_layout = val.get_string().value(); virtual_keyboard_layout = val.get_string().value();
@@ -350,6 +352,7 @@ void configuration::save()
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled; json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio; json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
json << ",\"fb_lower_body\":" << std::boolalpha << fb_lower_body; json << ",\"fb_lower_body\":" << std::boolalpha << fb_lower_body;
json << ",\"fb_hip\":" << std::boolalpha << fb_hip;
for (auto & [key, value]: features) for (auto & [key, value]: features)
json << "," << key << ":" << std::boolalpha << value; json << "," << key << ":" << std::boolalpha << value;
json << ",\"virtual_keyboard_layout\":" << json_string(virtual_keyboard_layout); json << ",\"virtual_keyboard_layout\":" << json_string(virtual_keyboard_layout);
+1
View File
@@ -55,6 +55,7 @@ public:
bool mic_unprocessed_audio = false; bool mic_unprocessed_audio = false;
bool fb_lower_body = false; bool fb_lower_body = false;
bool fb_hip = true;
// Snapdragon Game Super Resolution // Snapdragon Game Super Resolution
struct sgsr_settings struct sgsr_settings
+13 -4
View File
@@ -758,11 +758,9 @@ void scenes::lobby::gui_settings()
else else
{ {
if (application::get_fb_body_tracking_supported()) if (application::get_fb_body_tracking_supported())
tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings, otherwise estimated joint positions will be used")); tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise estimated joint positions will be used"));
else if (application::get_pico_body_tracking_supported()) else if (application::get_pico_body_tracking_supported())
{
tooltip(_("Uses the Pico Motion Trackers to track body joint positions")); tooltip(_("Uses the Pico Motion Trackers to track body joint positions"));
}
} }
} }
@@ -778,7 +776,18 @@ void scenes::lobby::gui_settings()
} }
vibrate_on_hover(); vibrate_on_hover();
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
tooltip(_("Estimate lower body joint positions using Generative Legs, requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings")); tooltip(_("Estimate lower body joint positions using Generative Legs\nRequires 'Hand and body tracking' to be enabled in the Quest movement tracking settings"));
ImGui::BeginDisabled(not config.fb_lower_body);
if (ImGui::Checkbox(_S("Enable hip tracking"), &config.fb_hip))
{
config.save();
}
vibrate_on_hover();
if (ImGui::IsItemHovered())
tooltip(_("Only takes affect with lower body tracking enabled\nMay be desired when using another source of hip tracking"));
ImGui::EndDisabled();
ImGui::Unindent(); ImGui::Unindent();
ImGui::EndDisabled(); ImGui::EndDisabled();
} }
+6 -2
View File
@@ -231,8 +231,12 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (application::get_fb_body_tracking_supported()) if (application::get_fb_body_tracking_supported())
{ {
auto num_trackers = config.fb_lower_body auto num_trackers = config.fb_lower_body
? xr::fb_body_tracker::joint_whitelist.size() ? std::ranges::count_if(xr::fb_body_tracker::joint_whitelist, [&config](auto joint) {
: std::ranges::count_if(xr::fb_body_tracker::joint_whitelist, [](auto & joint) { return joint < XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META; }); 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 = num_trackers;
} }
else if (application::get_pico_body_tracking_supported()) else if (application::get_pico_body_tracking_supported())
+1 -1
View File
@@ -274,7 +274,7 @@ void scenes::stream::tracking()
body_tracking = body_fb; body_tracking = body_fb;
// We start the tracker on connection because there are togglable settings. // We start the tracker on connection because there are togglable settings.
// TODO handle reconnection? // TODO handle reconnection?
application::get_fb_body_tracker().start(config.fb_lower_body); application::get_fb_body_tracker().start(config.fb_lower_body, config.fb_hip);
} }
else if (application::get_pico_body_tracking_supported()) else if (application::get_pico_body_tracking_supported())
body_tracking = body_pico; body_tracking = body_pico;
+8 -4
View File
@@ -37,10 +37,11 @@ xr::fb_body_tracker::~fb_body_tracker()
stop(); stop();
} }
void xr::fb_body_tracker::start(bool full_body) void xr::fb_body_tracker::start(bool full_body, bool hip)
{ {
assert(xrCreateBodyTrackerFB); assert(xrCreateBodyTrackerFB);
this->full_body = full_body; this->full_body = full_body;
this->hip = hip;
XrBodyTrackerCreateInfoFB create_info{ XrBodyTrackerCreateInfoFB create_info{
.type = XR_TYPE_BODY_TRACKER_CREATE_INFO_FB, .type = XR_TYPE_BODY_TRACKER_CREATE_INFO_FB,
@@ -100,11 +101,14 @@ 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{}; 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 (int i = 0; i < joint_whitelist.size(); i++)
{ {
auto joint = joint_whitelist[i]; auto joint = joint_whitelist[i];
if (!full_body && joint >= XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META) if (!full_body && (joint == XR_FULL_BODY_JOINT_HIPS_META || joint >= XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META))
break; continue;
if (!hip && joint == XR_FULL_BODY_JOINT_HIPS_META)
continue;
auto joint_pose = joints[joint]; auto joint_pose = joints[joint];
wivrn::from_headset::body_tracking::pose pose{ wivrn::from_headset::body_tracking::pose pose{
@@ -121,7 +125,7 @@ std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_h
if (joint_pose.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT) if (joint_pose.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
pose.flags |= wivrn::from_headset::body_tracking::position_tracked; pose.flags |= wivrn::from_headset::body_tracking::position_tracked;
poses[i] = std::move(pose); poses[num_poses++] = std::move(pose);
} }
return poses; return poses;
} }
+2 -1
View File
@@ -41,6 +41,7 @@ class fb_body_tracker
PFN_xrDestroyBodyTrackerFB xrDestroyBodyTrackerFB{}; PFN_xrDestroyBodyTrackerFB xrDestroyBodyTrackerFB{};
bool full_body{}; bool full_body{};
bool hip{};
public: public:
static constexpr std::array joint_whitelist{ static constexpr std::array joint_whitelist{
@@ -62,7 +63,7 @@ public:
fb_body_tracker(instance & inst, session & s); fb_body_tracker(instance & inst, session & s);
~fb_body_tracker(); ~fb_body_tracker();
void start(bool lower_body); void start(bool lower_body, bool hip);
void stop(); void stop();
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> locate_spaces(XrTime time, XrSpace reference); std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> locate_spaces(XrTime time, XrSpace reference);