/* * WiVRn VR streaming * Copyright (C) 2022 Guillaume Meunier * Copyright (C) 2022 Patrick Nicolas * Copyright (C) 2026 Sapphire * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include "driver/wivrn_generic_tracker.h" #include "utils/thread_safe.h" #include "xrt/xrt_defines.h" #include "xrt/xrt_device.h" #include "history.h" #include "pose_list.h" #include "wivrn_packets.h" #include #include namespace wivrn { class wivrn_session; class wivrn_body_tracker; struct clock_offset; class body_joints_list : public history { wivrn::from_headset::body_type type; wivrn_body_tracker & parent; public: body_joints_list(wivrn::from_headset::body_type type, wivrn_body_tracker & parent) : type(type), parent(parent) {} xrt_body_joint_set interpolate(const xrt_body_joint_set & a, const xrt_body_joint_set & b, float t); xrt_body_joint_set extrapolate(const xrt_body_joint_set & a, const xrt_body_joint_set & b, int64_t ta, int64_t tb, int64_t t); void update_tracking(const wivrn::from_headset::meta_body & tracking, const clock_offset & offset); void update_tracking(const wivrn::from_headset::bd_body & tracking, const clock_offset & offset); }; class wivrn_body_tracker : public xrt_device { friend body_joints_list; body_joints_list joints_list; std::vector inputs_array; wivrn_session & cnx; thread_safe meta_skeleton; std::atomic_uint32_t meta_skeleton_generation; protected: // key is joint std::unordered_map joint_body_parts; // key is joint std::unordered_map virtual_trackers; public: using base_t = xrt_device; wivrn_body_tracker(xrt_device * hmd, wivrn_session & cnx, std::function device_add_callback); xrt_result_t update_inputs(); xrt_result_t get_body_skeleton(xrt_input_name body_tracking_type, xrt_body_skeleton * out_value); xrt_result_t get_body_joints(xrt_input_name body_tracking_type, int64_t at_timestamp_ns, xrt_body_joint_set * out_value); void update_tracking(const from_headset::meta_body &, const clock_offset &); void update_tracking(const from_headset::bd_body &, const clock_offset &); void update_skeleton(const from_headset::meta_body_skeleton &); void operator()(const from_headset::settings_changed & settings); }; } // namespace wivrn