Store body trackers in variant
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "lobby.h"
|
||||
#include "stream.h"
|
||||
#include "utils/i18n.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "version.h"
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
@@ -741,7 +742,7 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
|
||||
{
|
||||
ImGui::BeginDisabled(not(application::get_fb_body_tracking_supported() or application::get_htc_body_tracking_supported() or application::get_pico_body_tracking_supported()));
|
||||
ImGui::BeginDisabled(not application::get_body_tracking_supported());
|
||||
bool enabled = config.check_feature(feature::body_tracking);
|
||||
if (ImGui::Checkbox(_S("Enable body tracking"), &enabled))
|
||||
{
|
||||
@@ -757,18 +758,25 @@ void scenes::lobby::gui_settings()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (application::get_fb_body_tracking_supported())
|
||||
tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
|
||||
else if (application::get_htc_body_tracking_supported())
|
||||
tooltip(_("Forwards positions of Vive Ultimate Trackers"));
|
||||
else if (application::get_pico_body_tracking_supported())
|
||||
tooltip(_("Uses the Pico Motion Trackers to track body joint positions"));
|
||||
std::visit(utils::overloaded{
|
||||
[](auto &) {},
|
||||
[this](xr::fb_body_tracker &) {
|
||||
tooltip(_("Requires 'Hand and body tracking' to be enabled in the Quest movement tracking settings,\notherwise body data will be guessed from controller and headset positions"));
|
||||
},
|
||||
[this](xr::htc_body_tracker &) {
|
||||
tooltip(_("Forwards positions of Vive Ultimate Trackers"));
|
||||
},
|
||||
[this](xr::pico_body_tracker &) {
|
||||
tooltip(_("Uses the Pico Motion Trackers to track body joint positions"));
|
||||
},
|
||||
},
|
||||
application::get_body_tracker());
|
||||
}
|
||||
}
|
||||
|
||||
vibrate_on_hover();
|
||||
}
|
||||
if (application::get_fb_body_tracking_supported())
|
||||
if (std::holds_alternative<xr::fb_body_tracker>(application::get_body_tracker()))
|
||||
{
|
||||
ImGui::BeginDisabled(not config.check_feature(feature::body_tracking));
|
||||
ImGui::Indent();
|
||||
@@ -1484,7 +1492,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
});
|
||||
}
|
||||
|
||||
if (application::get_fb_body_tracking_supported() or application::get_htc_body_tracking_supported() or application::get_pico_body_tracking_supported())
|
||||
if (application::get_body_tracking_supported())
|
||||
{
|
||||
items.push_back({
|
||||
.f = feature::body_tracking,
|
||||
|
||||
@@ -230,12 +230,15 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
info.num_generic_trackers = 0;
|
||||
if (config.check_feature(feature::body_tracking))
|
||||
{
|
||||
if (application::get_fb_body_tracking_supported())
|
||||
info.num_generic_trackers = xr::fb_body_tracker::get_whitelisted_joints(config.fb_lower_body, config.fb_hip).size();
|
||||
else if (application::get_htc_body_tracking_supported())
|
||||
info.num_generic_trackers = application::get_htc_body_tracker().count();
|
||||
else if (application::get_pico_body_tracking_supported())
|
||||
info.num_generic_trackers = xr::pico_body_tracker::joint_whitelist.size();
|
||||
info.num_generic_trackers = std::visit(utils::overloaded{
|
||||
[&](std::monostate &) {
|
||||
return size_t(0);
|
||||
},
|
||||
[&](auto & b) {
|
||||
return b.count();
|
||||
},
|
||||
},
|
||||
application::get_body_tracker());
|
||||
}
|
||||
|
||||
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
|
||||
#include "application.h"
|
||||
#include "stream.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include <ranges>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <thread>
|
||||
@@ -244,6 +246,7 @@ void scenes::stream::tracking()
|
||||
|
||||
const bool hand_tracking = config.check_feature(feature::hand_tracking);
|
||||
from_headset::face_type face_tracking = from_headset::face_type::none;
|
||||
const bool body_tracking = config.check_feature(feature::body_tracking);
|
||||
if (config.check_feature(feature::face_tracking))
|
||||
{
|
||||
if (application::get_fb_face_tracking2_supported())
|
||||
@@ -260,29 +263,17 @@ void scenes::stream::tracking()
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
auto & body_tracker = application::get_body_tracker();
|
||||
if (body_tracking)
|
||||
{
|
||||
body_none,
|
||||
body_fb,
|
||||
body_htc,
|
||||
body_pico,
|
||||
} body_tracking = body_none;
|
||||
|
||||
if (config.check_feature(feature::body_tracking))
|
||||
{
|
||||
if (application::get_fb_body_tracking_supported())
|
||||
if (auto * body_fb = std::get_if<xr::fb_body_tracker>(&body_tracker))
|
||||
{
|
||||
body_tracking = body_fb;
|
||||
// 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);
|
||||
body_fb->stop();
|
||||
body_fb->start(config.fb_lower_body, config.fb_hip);
|
||||
}
|
||||
else if (application::get_htc_body_tracking_supported())
|
||||
body_tracking = body_htc;
|
||||
else if (application::get_pico_body_tracking_supported())
|
||||
body_tracking = body_pico;
|
||||
}
|
||||
|
||||
on_interaction_profile_changed({});
|
||||
@@ -363,32 +354,26 @@ void scenes::stream::tracking()
|
||||
locate_hands(application::get_right_hand(), world_space, t0 + Δt));
|
||||
}
|
||||
|
||||
if (body_tracking != body_none and t0 >= last_body_sample + period and
|
||||
(Δt == 0 or Δt >= prediction - 2 * period))
|
||||
{
|
||||
last_body_sample = t0;
|
||||
if (control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
auto & body_packet = body.emplace_back(from_headset::body_tracking{
|
||||
.production_timestamp = t0,
|
||||
.timestamp = t0 + Δt,
|
||||
});
|
||||
switch (body_tracking)
|
||||
{
|
||||
case body_none:
|
||||
__builtin_unreachable();
|
||||
case body_fb:
|
||||
body_packet.poses = application::get_fb_body_tracker().locate_spaces(t0 + Δt, world_space);
|
||||
break;
|
||||
case body_htc:
|
||||
body_packet.poses = application::get_htc_body_tracker().locate_spaces(t0 + Δt, world_space);
|
||||
break;
|
||||
case body_pico:
|
||||
body_packet.poses = application::get_pico_body_tracker().locate_spaces(t0 + Δt, world_space);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (body_tracking)
|
||||
std::visit(utils::overloaded{
|
||||
[](std::monostate &) {},
|
||||
[&](auto & b) {
|
||||
if (t0 >= last_body_sample + period and
|
||||
(Δt == 0 or Δt >= prediction - 2 * period))
|
||||
{
|
||||
last_body_sample = t0;
|
||||
if (control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
body.push_back(from_headset::body_tracking{
|
||||
.production_timestamp = t0,
|
||||
.timestamp = t0 + Δt,
|
||||
.poses = b.locate_spaces(t0 + Δt, world_space),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
body_tracker);
|
||||
|
||||
if (control.enabled[size_t(tid::face)])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user