Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -740,6 +740,58 @@ void scenes::lobby::gui_settings()
|
||||
vibrate_on_hover();
|
||||
}
|
||||
|
||||
{
|
||||
ImGui::BeginDisabled(not(application::get_fb_body_tracking_supported() or application::get_pico_body_tracking_supported()));
|
||||
bool enabled = config.check_feature(feature::body_tracking);
|
||||
if (ImGui::Checkbox(_S("Enable body tracking"), &enabled))
|
||||
{
|
||||
config.set_feature(feature::body_tracking, enabled);
|
||||
config.save();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
{
|
||||
if (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled)
|
||||
{
|
||||
tooltip(_("This feature is not supported by your headset"));
|
||||
}
|
||||
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_pico_body_tracking_supported())
|
||||
tooltip(_("Uses the Pico Motion Trackers to track body joint positions"));
|
||||
}
|
||||
}
|
||||
|
||||
vibrate_on_hover();
|
||||
}
|
||||
if (application::get_fb_body_tracking_supported())
|
||||
{
|
||||
ImGui::BeginDisabled(not config.check_feature(feature::body_tracking));
|
||||
ImGui::Indent();
|
||||
if (ImGui::Checkbox(_S("Enable lower body tracking"), &config.fb_lower_body))
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
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::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::BeginDisabled(passthrough_supported == xr::system::passthrough_type::no_passthrough);
|
||||
if (ImGui::Checkbox(_S("Enable video passthrough in lobby"), &config.passthrough_enabled))
|
||||
{
|
||||
@@ -1433,6 +1485,16 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
});
|
||||
}
|
||||
|
||||
if (application::get_fb_body_tracking_supported() or application::get_pico_body_tracking_supported())
|
||||
{
|
||||
items.push_back({
|
||||
.f = feature::body_tracking,
|
||||
.tooltip_enabled = _("Body tracking is enabled"),
|
||||
.tooltip_disabled = _("Body tracking is disabled"),
|
||||
.icon_enabled = ICON_FA_PERSON,
|
||||
});
|
||||
}
|
||||
|
||||
// Get statuses
|
||||
for (auto & i: items)
|
||||
{
|
||||
@@ -1459,7 +1521,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
if (&i != &items.front())
|
||||
ImGui::SameLine();
|
||||
auto pos = ImGui::GetCursorPos();
|
||||
if (ImGui::Button(i.enabled ? i.icon_enabled : i.icon_disabled))
|
||||
if (ImGui::Button(fmt::format("{}##{}", i.enabled ? i.icon_enabled : i.icon_disabled, i.icon_enabled).c_str()))
|
||||
{
|
||||
// button doesn't alter the bool
|
||||
config.set_feature(i.f, not i.enabled);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "utils/overloaded.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#define GLM_FORCE_RADIANS
|
||||
|
||||
#include "stream.h"
|
||||
@@ -224,6 +225,24 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
info.face_tracking = from_headset::face_type::pico;
|
||||
}
|
||||
|
||||
info.num_generic_trackers = 0;
|
||||
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;
|
||||
}
|
||||
else if (application::get_pico_body_tracking_supported())
|
||||
info.num_generic_trackers = xr::pico_body_tracker::joint_whitelist.size();
|
||||
}
|
||||
|
||||
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
|
||||
info.passthrough = self->system.passthrough_supported() != xr::system::passthrough_type::no_passthrough;
|
||||
info.system_name = std::string(self->system.properties().systemName);
|
||||
|
||||
@@ -232,9 +232,11 @@ void scenes::stream::tracking()
|
||||
|
||||
XrTime t0 = instance.now();
|
||||
XrTime last_hand_sample = t0;
|
||||
XrTime last_body_sample = t0;
|
||||
std::vector<from_headset::tracking> tracking;
|
||||
std::vector<from_headset::tracking> tracking_pool; // pre-allocated objects
|
||||
std::vector<from_headset::hand_tracking> hands;
|
||||
std::vector<from_headset::body_tracking> body;
|
||||
std::vector<XrView> views;
|
||||
|
||||
std::vector<from_headset::trackings> merged_tracking;
|
||||
@@ -258,6 +260,27 @@ void scenes::stream::tracking()
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
body_none,
|
||||
body_fb,
|
||||
body_pico,
|
||||
} body_tracking = body_none;
|
||||
|
||||
if (config.check_feature(feature::body_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
|
||||
application::get_fb_body_tracker().stop();
|
||||
application::get_fb_body_tracker().start(config.fb_lower_body, config.fb_hip);
|
||||
}
|
||||
else if (application::get_pico_body_tracking_supported())
|
||||
body_tracking = body_pico;
|
||||
}
|
||||
|
||||
on_interaction_profile_changed({});
|
||||
|
||||
while (not exiting)
|
||||
@@ -266,6 +289,7 @@ void scenes::stream::tracking()
|
||||
{
|
||||
tracking.clear();
|
||||
hands.clear();
|
||||
body.clear();
|
||||
|
||||
XrTime now = instance.now();
|
||||
if (now < t0)
|
||||
@@ -335,6 +359,30 @@ 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_pico:
|
||||
body_packet.poses = application::get_pico_body_tracker().locate_spaces(t0 + Δt, world_space);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (control.enabled[size_t(tid::face)])
|
||||
{
|
||||
switch (face_tracking)
|
||||
@@ -408,7 +456,7 @@ void scenes::stream::tracking()
|
||||
merged_tracking.back().items.emplace_back(std::move(item));
|
||||
}
|
||||
|
||||
packets.resize(std::max(packets.size(), merged_tracking.size() + hands.size()));
|
||||
packets.resize(std::max(packets.size(), merged_tracking.size() + hands.size() + body.size()));
|
||||
size_t packet_count = 0;
|
||||
for (const auto & i: merged_tracking)
|
||||
{
|
||||
@@ -425,6 +473,15 @@ void scenes::stream::tracking()
|
||||
wivrn_session::stream_socket_t::serialize(packet, i);
|
||||
}
|
||||
}
|
||||
for (const auto & i: body)
|
||||
{
|
||||
if (i.poses)
|
||||
{
|
||||
auto & packet = packets[packet_count++];
|
||||
packet.clear();
|
||||
wivrn_session::stream_socket_t::serialize(packet, i);
|
||||
}
|
||||
}
|
||||
|
||||
network_session->send_stream(std::span(packets.data(), packet_count));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user