Forward hand tracking data source

This commit is contained in:
Patrick Nicolas
2026-10-16 18:30:38 +02:00
parent 7d610b2959
commit a98410bae0
12 changed files with 110 additions and 74 deletions
+11 -11
View File
@@ -981,28 +981,28 @@ void scenes::lobby::render(const XrFrameState & frame_state)
auto windows = imgui_ctx->windows();
auto left = left_hand->locate(world_space, frame_state.predictedDisplayTime);
if (left)
if (left.joints)
{
if (left->is_input_source())
stick_finger_to_gui(left->joints, windows);
if (left.is_input_source())
stick_finger_to_gui(*left.joints, windows);
hide_left_controller = true;
}
auto right = right_hand->locate(world_space, frame_state.predictedDisplayTime);
if (right)
if (right.joints)
{
if (right->is_input_source())
stick_finger_to_gui(right->joints, windows);
if (right.is_input_source())
stick_finger_to_gui(*right.joints, windows);
hide_right_controller = true;
}
hand_model::apply(world, left ? &left->joints : nullptr, right ? &right->joints : nullptr);
hand_model::apply(world, left.joints ? &*left.joints : nullptr, right.joints ? &*right.joints : nullptr);
if (not new_gui_position and head_position and left and left->is_input_source())
new_gui_position = check_recenter_gesture(xr::spaces::palm_left, left->joints, *head_position);
if (not new_gui_position and head_position and left.joints and left.is_input_source())
new_gui_position = check_recenter_gesture(xr::spaces::palm_left, *left.joints, *head_position);
if (not new_gui_position and head_position and right and right->is_input_source())
new_gui_position = check_recenter_gesture(xr::spaces::palm_right, right->joints, *head_position);
if (not new_gui_position and head_position and right.joints and right.is_input_source())
new_gui_position = check_recenter_gesture(xr::spaces::palm_right, *right.joints, *head_position);
}
if (head_position and new_gui_position)
+4 -4
View File
@@ -1097,12 +1097,12 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
auto left = left_hand->locate(world_space, predicted_display_time);
auto right = right_hand->locate(world_space, predicted_display_time);
if (left and left->is_input_source() and
xr::hand_tracker::check_flags(left->joints, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
if (left.joints and left.is_input_source() and
xr::hand_tracker::check_flags(*left.joints, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
hide_left_controller = true;
if (right and right->is_input_source() and
xr::hand_tracker::check_flags(right->joints, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
if (right.joints and right.is_input_source() and
xr::hand_tracker::check_flags(*right.joints, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
hide_right_controller = true;
}
+32 -21
View File
@@ -155,16 +155,33 @@ public:
} // namespace
static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT>> locate_hands(xr::hand_tracker & hand, XrSpace space, XrTime time)
static from_headset::hand_tracking locate_hands(
xr::hand_tracker & tracker,
XrSpace space,
XrTime now,
XrTime time)
{
auto located = hand.locate(space, time);
using hand_id = from_headset::hand_tracking::hand_id;
auto located = tracker.locate(space, time);
if (located and located->is_input_source())
from_headset::hand_tracking res{
.production_timestamp = now,
.timestamp = time,
.hand = tracker.hand() == XR_HAND_LEFT_EXT ? hand_id::left : hand_id::right,
};
if (located.data_source == XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT)
res.hand = tracker.hand() == XR_HAND_LEFT_EXT
? hand_id::left_controller
: hand_id::right_controller;
if (located.joints)
{
std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT> poses;
const auto & joints = *located.joints;
auto & poses = res.joints.emplace();
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
const auto & joint = located->joints[i];
const auto & joint = joints[i];
poses[i] = {
.position = joint.first.pose.position,
.orientation = pack(joint.first.pose.orientation),
@@ -174,11 +191,9 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
.flags = from_headset::to_pose_flags(joint.first.locationFlags, joint.second.velocityFlags),
};
}
return poses;
}
else
return std::nullopt;
return res;
}
template <typename T>
@@ -503,23 +518,19 @@ void scenes::stream::tracking()
break;
case wivrn::device_id::LEFT_HAND:
if (left_hand)
{
hands.emplace_back(
hands.emplace_back(locate_hands(
*left_hand,
height_offset_space,
t0,
at_time,
from_headset::hand_tracking::left,
locate_hands(*left_hand, height_offset_space, tracking.timestamp));
}
at_time));
break;
case wivrn::device_id::RIGHT_HAND:
if (right_hand)
{
hands.emplace_back(
hands.emplace_back(locate_hands(
*right_hand,
height_offset_space,
t0,
at_time,
from_headset::hand_tracking::right,
locate_hands(*right_hand, height_offset_space, tracking.timestamp));
}
at_time));
break;
case wivrn::device_id::BODY:
std::visit(utils::overloaded{