diff --git a/client/scenes/stream_tracking.cpp b/client/scenes/stream_tracking.cpp index 434f6d93..8d471e69 100644 --- a/client/scenes/stream_tracking.cpp +++ b/client/scenes/stream_tracking.cpp @@ -238,6 +238,7 @@ void scenes::stream::tracking() std::vector tracking; std::vector tracking_pool; // pre-allocated objects std::vector hands; + std::array should_skip_simple_controllers{}; std::vector body; std::vector views; @@ -245,8 +246,22 @@ void scenes::stream::tracking() std::vector packets; const bool hand_tracking = config.check_feature(feature::hand_tracking); + // Quest hand tracking creates a fake khr/simple_controller when hand tracking + // is enabled, let's not send it when hand tracking data is invalid + bool block_khr_simple_controller = false; + switch (guess_model()) + { + case model::meta_quest_3: + case model::meta_quest_pro: + case model::meta_quest_3s: + case model::oculus_quest_2: + block_khr_simple_controller = hand_tracking; + break; + default: + break; + } + 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()) @@ -263,6 +278,7 @@ void scenes::stream::tracking() } } + const bool body_tracking = config.check_feature(feature::body_tracking); auto & body_tracker = application::get_body_tracker(); if (body_tracking) { @@ -327,31 +343,70 @@ void scenes::stream::tracking() if (recenter_requested.exchange(false)) packet.state_flags = wivrn::from_headset::tracking::recentered; - packet.device_poses.clear(); - for (auto [device, space]: spaces) - { - if (enabled(control, device)) - packet.device_poses.emplace_back(locate_space(device, space, world_space, t0 + Δt)); - } - // Hand tracking data are very large, send fewer samples than other items if (hand_tracking and t0 >= last_hand_sample + period and (Δt == 0 or Δt >= prediction - 2 * period)) { last_hand_sample = t0; if (control.enabled[size_t(tid::left_hand)]) + { + auto joints = locate_hands(application::get_left_hand(), world_space, t0 + Δt); + should_skip_simple_controllers[0] = !joints.has_value(); hands.emplace_back( t0, t0 + Δt, from_headset::hand_tracking::left, - locate_hands(application::get_left_hand(), world_space, t0 + Δt)); + joints); + } + else + { + should_skip_simple_controllers[0] = false; + } if (control.enabled[size_t(tid::right_hand)]) + { + auto joints = locate_hands(application::get_right_hand(), world_space, t0 + Δt); + should_skip_simple_controllers[1] = !joints.has_value(); hands.emplace_back( t0, t0 + Δt, from_headset::hand_tracking::right, - locate_hands(application::get_right_hand(), world_space, t0 + Δt)); + joints); + } + else + { + should_skip_simple_controllers[1] = false; + } + } + + packet.device_poses.clear(); + for (auto [device, space]: spaces) + { + if (enabled(control, device)) + { + switch (device) + { + case device_id::LEFT_AIM: + case device_id::LEFT_GRIP: + case device_id::LEFT_PALM: + case device_id::RIGHT_AIM: + case device_id::RIGHT_GRIP: + case device_id::RIGHT_PALM: { + const bool right = device > device_id::LEFT_PALM; + if (block_khr_simple_controller and interaction_profiles[right].load() == interaction_profile::khr_simple_controller and should_skip_simple_controllers[right]) + { + packet.device_poses.emplace_back(from_headset::tracking::pose{ + .device = device, + }); + continue; + } + [[fallthrough]]; + } + default: + packet.device_poses.emplace_back(locate_space(device, space, world_space, t0 + Δt)); + break; + } + } } if (body_tracking) diff --git a/client/xr/hand_tracker.cpp b/client/xr/hand_tracker.cpp index f8f5beed..261e5e05 100644 --- a/client/xr/hand_tracker.cpp +++ b/client/xr/hand_tracker.cpp @@ -77,6 +77,10 @@ std::optional> xr:: if (!locations.isActive) return std::nullopt; + // bail if none of the joints are valid/tracked + 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