Use shared pose_flags enum in packets
This commit is contained in:
@@ -35,30 +35,6 @@
|
||||
#include "android/battery.h"
|
||||
#endif
|
||||
|
||||
static uint8_t cast_flags(XrSpaceLocationFlags location, XrSpaceVelocityFlags velocity)
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
if (location & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
flags |= from_headset::tracking::orientation_valid;
|
||||
|
||||
if (location & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
flags |= from_headset::tracking::position_valid;
|
||||
|
||||
if (velocity & XR_SPACE_VELOCITY_LINEAR_VALID_BIT)
|
||||
flags |= from_headset::tracking::linear_velocity_valid;
|
||||
|
||||
if (velocity & XR_SPACE_VELOCITY_ANGULAR_VALID_BIT)
|
||||
flags |= from_headset::tracking::angular_velocity_valid;
|
||||
|
||||
if (location & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
flags |= from_headset::tracking::orientation_tracked;
|
||||
|
||||
if (location & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
flags |= from_headset::tracking::position_tracked;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -81,7 +57,7 @@ from_headset::tracking::pose locate_space(device_id device, XrSpace space, XrSpa
|
||||
.linear_velocity = velocity.linearVelocity,
|
||||
.angular_velocity = velocity.angularVelocity,
|
||||
.device = device,
|
||||
.flags = cast_flags(location.locationFlags, velocity.velocityFlags),
|
||||
.flags = from_headset::to_pose_flags(location.locationFlags, velocity.velocityFlags),
|
||||
};
|
||||
spdlog::warn("xrLocateSpace failed for {}: {}", magic_enum::enum_name(device), xr::to_string(res));
|
||||
return {.device = device};
|
||||
@@ -168,7 +144,7 @@ public:
|
||||
.linear_velocity = velocity.linearVelocity,
|
||||
.angular_velocity = velocity.angularVelocity,
|
||||
.device = devices[i],
|
||||
.flags = cast_flags(location.locationFlags, velocity.velocityFlags),
|
||||
.flags = from_headset::to_pose_flags(location.locationFlags, velocity.velocityFlags),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -191,31 +167,15 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
|
||||
std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT> poses;
|
||||
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
|
||||
{
|
||||
const auto & joint = (*joints)[i];
|
||||
poses[i] = {
|
||||
.position = (*joints)[i].first.pose.position,
|
||||
.orientation = pack((*joints)[i].first.pose.orientation),
|
||||
.linear_velocity = (*joints)[i].second.linearVelocity,
|
||||
.angular_velocity = (*joints)[i].second.angularVelocity,
|
||||
.radius = uint16_t((*joints)[i].first.radius * 10'000),
|
||||
.position = joint.first.pose.position,
|
||||
.orientation = pack(joint.first.pose.orientation),
|
||||
.linear_velocity = joint.second.linearVelocity,
|
||||
.angular_velocity = joint.second.angularVelocity,
|
||||
.radius = uint16_t(joint.first.radius * 10'000),
|
||||
.flags = from_headset::to_pose_flags(joint.first.locationFlags, joint.second.velocityFlags),
|
||||
};
|
||||
|
||||
if ((*joints)[i].first.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
poses[i].flags |= from_headset::hand_tracking::orientation_valid;
|
||||
|
||||
if ((*joints)[i].first.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
poses[i].flags |= from_headset::hand_tracking::position_valid;
|
||||
|
||||
if ((*joints)[i].second.velocityFlags & XR_SPACE_VELOCITY_LINEAR_VALID_BIT)
|
||||
poses[i].flags |= from_headset::hand_tracking::linear_velocity_valid;
|
||||
|
||||
if ((*joints)[i].second.velocityFlags & XR_SPACE_VELOCITY_ANGULAR_VALID_BIT)
|
||||
poses[i].flags |= from_headset::hand_tracking::angular_velocity_valid;
|
||||
|
||||
if ((*joints)[i].first.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
poses[i].flags |= from_headset::hand_tracking::orientation_tracked;
|
||||
|
||||
if ((*joints)[i].first.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
poses[i].flags |= from_headset::hand_tracking::position_tracked;
|
||||
}
|
||||
|
||||
return poses;
|
||||
@@ -503,7 +463,7 @@ void scenes::stream::tracking()
|
||||
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
|
||||
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
|
||||
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
|
||||
using flags = from_headset::tracking::flags;
|
||||
using flags = from_headset::pose_flags;
|
||||
tracking.device_poses.push_back(
|
||||
from_headset::tracking::pose{
|
||||
// Zero position and velocities
|
||||
@@ -798,7 +758,7 @@ void scenes::stream::send_derived_pose()
|
||||
else
|
||||
{
|
||||
if (auto pose = locate_space(target, target_space, source_space, now);
|
||||
pose.flags & from_headset::tracking::position_valid and pose.flags & from_headset::tracking::orientation_valid)
|
||||
pose.flags & from_headset::pose_flags::position_valid and pose.flags & from_headset::pose_flags::orientation_valid)
|
||||
{
|
||||
network_session->send_control(from_headset::derived_pose{
|
||||
.source = source,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "fb_body_tracker.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/to_string.h"
|
||||
@@ -26,21 +27,6 @@
|
||||
#include <variant>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
static uint8_t convert_flags(XrSpaceLocationFlags in_flags)
|
||||
{
|
||||
uint8_t flags{};
|
||||
if (in_flags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
flags |= wivrn::from_headset::meta_body::orientation_valid;
|
||||
if (in_flags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
flags |= wivrn::from_headset::meta_body::position_valid;
|
||||
if (in_flags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
flags |= wivrn::from_headset::meta_body::orientation_tracked;
|
||||
if (in_flags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
flags |= wivrn::from_headset::meta_body::position_tracked;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
xr::fb_body_tracker::fb_body_tracker(instance & inst, session & s, bool lower_body) :
|
||||
handle(inst.get_proc<PFN_xrDestroyBodyTrackerFB>("xrDestroyBodyTrackerFB")),
|
||||
xrRequestBodyTrackingFidelityMETA(inst.get_proc<PFN_xrRequestBodyTrackingFidelityMETA>("xrRequestBodyTrackingFidelityMETA")),
|
||||
@@ -110,7 +96,7 @@ xr::fb_body_tracker::packet_type xr::fb_body_tracker::locate_spaces(XrTime time,
|
||||
o.root = {
|
||||
.position = root.pose.position,
|
||||
.orientation = pack(root.pose.orientation),
|
||||
.flags = convert_flags(root.locationFlags),
|
||||
.flags = wivrn::from_headset::to_pose_flags(root.locationFlags),
|
||||
};
|
||||
for (size_t joint = XR_BODY_JOINT_HIPS_FB; joint < std::size(o.joints) + 1; joint++)
|
||||
{
|
||||
@@ -121,7 +107,7 @@ xr::fb_body_tracker::packet_type xr::fb_body_tracker::locate_spaces(XrTime time,
|
||||
.y = int16_t((loc.pose.position.y - root.pose.position.y) * 10'000.f),
|
||||
.z = int16_t((loc.pose.position.z - root.pose.position.z) * 10'000.f)},
|
||||
.orientation = pack(loc.pose.orientation),
|
||||
.flags = convert_flags(loc.locationFlags),
|
||||
.flags = wivrn::from_headset::to_pose_flags(loc.locationFlags),
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "htc_body_tracker.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/details/enumerate.h"
|
||||
#include "xr/session.h"
|
||||
#include <openxr/openxr.h>
|
||||
@@ -72,21 +73,9 @@ static wivrn::from_headset::htc_body::pose locate_space(XrSpace space, XrSpace r
|
||||
|
||||
wivrn::from_headset::htc_body::pose res{
|
||||
.pose = location.pose,
|
||||
.flags = 0,
|
||||
.flags = wivrn::from_headset::to_pose_flags(location.locationFlags),
|
||||
};
|
||||
|
||||
if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
res.flags |= wivrn::from_headset::htc_body::orientation_valid;
|
||||
|
||||
if (location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
res.flags |= wivrn::from_headset::htc_body::position_valid;
|
||||
|
||||
if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
res.flags |= wivrn::from_headset::htc_body::orientation_tracked;
|
||||
|
||||
if (location.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
res.flags |= wivrn::from_headset::htc_body::position_tracked;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "pico_body_tracker.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/to_string.h"
|
||||
@@ -73,15 +74,8 @@ xr::pico_body_tracker::packet_type xr::pico_body_tracker::locate_spaces(XrTime t
|
||||
ret.joints[joint] = {
|
||||
.position = joint_loc.pose.position,
|
||||
.orientation = pack(joint_loc.pose.orientation),
|
||||
.flags = wivrn::from_headset::to_pose_flags(joint_loc.locationFlags),
|
||||
};
|
||||
if (joint_loc.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
ret.joints[joint].flags |= wivrn::from_headset::bd_body::orientation_valid;
|
||||
if (joint_loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
ret.joints[joint].flags |= wivrn::from_headset::bd_body::position_valid;
|
||||
if (joint_loc.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
ret.joints[joint].flags |= wivrn::from_headset::bd_body::orientation_tracked;
|
||||
if (joint_loc.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
ret.joints[joint].flags |= wivrn::from_headset::bd_body::position_tracked;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
+29
-40
@@ -327,18 +327,37 @@ struct handshake
|
||||
// Sending this on TCP means connection will be TCP only
|
||||
};
|
||||
|
||||
enum pose_flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
linear_velocity_valid = 1 << 2,
|
||||
angular_velocity_valid = 1 << 3,
|
||||
orientation_tracked = 1 << 4,
|
||||
position_tracked = 1 << 5
|
||||
};
|
||||
|
||||
inline uint8_t to_pose_flags(XrSpaceLocationFlags location_flags, XrSpaceVelocityFlags velocity_flags = 0)
|
||||
{
|
||||
uint8_t flags{};
|
||||
if (location_flags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
flags |= pose_flags::orientation_valid;
|
||||
if (location_flags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
flags |= pose_flags::position_valid;
|
||||
if (location_flags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
flags |= pose_flags::orientation_tracked;
|
||||
if (location_flags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
flags |= pose_flags::position_tracked;
|
||||
|
||||
if (velocity_flags & XR_SPACE_VELOCITY_LINEAR_VALID_BIT)
|
||||
flags |= pose_flags::linear_velocity_valid;
|
||||
if (velocity_flags & XR_SPACE_VELOCITY_ANGULAR_VALID_BIT)
|
||||
flags |= pose_flags::angular_velocity_valid;
|
||||
return flags;
|
||||
}
|
||||
|
||||
struct tracking
|
||||
{
|
||||
enum flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
linear_velocity_valid = 1 << 2,
|
||||
angular_velocity_valid = 1 << 3,
|
||||
orientation_tracked = 1 << 4,
|
||||
position_tracked = 1 << 5
|
||||
};
|
||||
|
||||
enum state_flags : uint8_t
|
||||
{
|
||||
recentered = 1 << 0,
|
||||
@@ -413,15 +432,6 @@ struct derived_pose
|
||||
|
||||
struct hand_tracking
|
||||
{
|
||||
enum flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
linear_velocity_valid = 1 << 2,
|
||||
angular_velocity_valid = 1 << 3,
|
||||
orientation_tracked = 1 << 4,
|
||||
position_tracked = 1 << 5
|
||||
};
|
||||
enum hand_id : uint8_t
|
||||
{
|
||||
left,
|
||||
@@ -447,13 +457,6 @@ struct hand_tracking
|
||||
|
||||
struct meta_body
|
||||
{
|
||||
enum flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
orientation_tracked = 1 << 2,
|
||||
position_tracked = 1 << 3,
|
||||
};
|
||||
struct pose
|
||||
{
|
||||
XrVector3f position;
|
||||
@@ -504,13 +507,6 @@ struct meta_body_skeleton
|
||||
|
||||
struct bd_body
|
||||
{
|
||||
enum flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
orientation_tracked = 1 << 2,
|
||||
position_tracked = 1 << 3,
|
||||
};
|
||||
struct pose
|
||||
{
|
||||
XrVector3f position;
|
||||
@@ -527,13 +523,6 @@ struct bd_body
|
||||
struct htc_body
|
||||
{
|
||||
inline static const size_t max_tracked_poses = 16;
|
||||
enum flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
orientation_tracked = 1 << 2,
|
||||
position_tracked = 1 << 3,
|
||||
};
|
||||
struct pose
|
||||
{
|
||||
XrPosef pose{};
|
||||
|
||||
@@ -431,7 +431,7 @@ void foveation::update_tracking(const from_headset::tracking & tracking)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
const uint8_t orientation_ok = from_headset::tracking::orientation_valid | from_headset::tracking::orientation_tracked;
|
||||
const uint8_t orientation_ok = from_headset::pose_flags::orientation_valid | from_headset::pose_flags::orientation_tracked;
|
||||
|
||||
if (tracking.view_flags & XR_VIEW_STATE_POSITION_VALID_BIT)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "hand_joints_list.h"
|
||||
#include "math/m_space.h"
|
||||
#include "pose_list.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xrt_cast.h"
|
||||
|
||||
static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
|
||||
@@ -53,33 +54,10 @@ xrt_hand_joint_set hand_joints_list::extrapolate(const xrt_hand_joint_set & a, c
|
||||
return t <= ta ? a : b;
|
||||
}
|
||||
|
||||
static xrt_space_relation_flags cast_flags(uint8_t in_flags)
|
||||
{
|
||||
std::underlying_type_t<xrt_space_relation_flags> flags = 0;
|
||||
if (in_flags & from_headset::hand_tracking::position_valid)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
|
||||
|
||||
if (in_flags & from_headset::hand_tracking::orientation_valid)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
|
||||
|
||||
if (in_flags & from_headset::hand_tracking::linear_velocity_valid)
|
||||
flags |= XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT;
|
||||
|
||||
if (in_flags & from_headset::hand_tracking::angular_velocity_valid)
|
||||
flags |= XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT;
|
||||
|
||||
if (in_flags & from_headset::hand_tracking::position_tracked)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
|
||||
|
||||
if (in_flags & from_headset::hand_tracking::orientation_tracked)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
|
||||
return xrt_space_relation_flags(flags);
|
||||
}
|
||||
|
||||
static xrt_space_relation to_relation(const from_headset::hand_tracking::pose & pose)
|
||||
{
|
||||
return {
|
||||
.relation_flags = cast_flags(pose.flags),
|
||||
.relation_flags = from_pose_flags(pose.flags),
|
||||
.pose = xrt_cast(XrPosef{
|
||||
.orientation = pose.orientation,
|
||||
.position = pose.position,
|
||||
|
||||
@@ -166,19 +166,19 @@ void pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const
|
||||
// TODO keep the tracked flag
|
||||
|
||||
polynomial_interpolator<3>::sample position{production_timestamp, timestamp};
|
||||
if (pose.flags & from_headset::tracking::position_valid)
|
||||
if (pose.flags & from_headset::pose_flags::position_valid)
|
||||
position.y.emplace(
|
||||
pose.pose.position.x,
|
||||
pose.pose.position.y,
|
||||
pose.pose.position.z);
|
||||
if (pose.flags & from_headset::tracking::linear_velocity_valid)
|
||||
if (pose.flags & from_headset::pose_flags::linear_velocity_valid)
|
||||
position.dy.emplace(
|
||||
pose.linear_velocity.x,
|
||||
pose.linear_velocity.y,
|
||||
pose.linear_velocity.z);
|
||||
|
||||
polynomial_interpolator<4, true>::sample orientation{production_timestamp, timestamp};
|
||||
if (pose.flags & from_headset::tracking::orientation_valid)
|
||||
if (pose.flags & from_headset::pose_flags::orientation_valid)
|
||||
{
|
||||
orientation.y.emplace(
|
||||
pose.pose.orientation.w,
|
||||
@@ -186,7 +186,7 @@ void pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const
|
||||
pose.pose.orientation.y,
|
||||
pose.pose.orientation.z);
|
||||
|
||||
if (pose.flags & from_headset::tracking::angular_velocity_valid)
|
||||
if (pose.flags & from_headset::pose_flags::angular_velocity_valid)
|
||||
{
|
||||
Eigen::Quaternionf q{
|
||||
pose.pose.orientation.w,
|
||||
|
||||
@@ -34,44 +34,10 @@ static_assert(std::to_underlying(XR_BODY_JOINT_COUNT_FB) == std::to_underlying(X
|
||||
static_assert(std::to_underlying(XR_FULL_BODY_JOINT_COUNT_META) == std::to_underlying(XRT_FULL_BODY_JOINT_COUNT_META));
|
||||
static_assert(XR_BODY_JOINT_COUNT_BD == XRT_BODY_JOINT_COUNT_BD);
|
||||
|
||||
static xrt_space_relation_flags cast_meta_flags(uint8_t in_flags)
|
||||
{
|
||||
std::underlying_type_t<xrt_space_relation_flags> flags = 0;
|
||||
if (in_flags & wivrn::from_headset::meta_body::position_valid)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::meta_body::orientation_valid)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::meta_body::position_tracked)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::meta_body::orientation_tracked)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
|
||||
return xrt_space_relation_flags(flags);
|
||||
}
|
||||
|
||||
static xrt_space_relation_flags cast_bd_flags(uint8_t in_flags)
|
||||
{
|
||||
std::underlying_type_t<xrt_space_relation_flags> flags = 0;
|
||||
if (in_flags & wivrn::from_headset::bd_body::position_valid)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::bd_body::orientation_valid)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::bd_body::position_tracked)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::bd_body::orientation_tracked)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
|
||||
return xrt_space_relation_flags(flags);
|
||||
}
|
||||
|
||||
static xrt_space_relation to_relation(const wivrn::from_headset::meta_body::pose & pose)
|
||||
{
|
||||
return {
|
||||
.relation_flags = cast_meta_flags(pose.flags),
|
||||
.relation_flags = from_pose_flags(pose.flags),
|
||||
.pose = xrt_cast(XrPosef{
|
||||
.orientation = pose.orientation,
|
||||
.position = pose.position,
|
||||
@@ -81,7 +47,7 @@ static xrt_space_relation to_relation(const wivrn::from_headset::meta_body::pose
|
||||
static xrt_space_relation to_relation(const wivrn::from_headset::bd_body::pose & pose)
|
||||
{
|
||||
return {
|
||||
.relation_flags = cast_bd_flags(pose.flags),
|
||||
.relation_flags = from_pose_flags(pose.flags),
|
||||
.pose = xrt_cast(XrPosef{
|
||||
.orientation = pose.orientation,
|
||||
.position = pose.position,
|
||||
@@ -91,7 +57,7 @@ static xrt_space_relation to_relation(const wivrn::from_headset::bd_body::pose &
|
||||
static xrt_space_relation to_relation(const wivrn::from_headset::meta_body::pose & base, const wivrn::from_headset::meta_body::packed_pose & pose)
|
||||
{
|
||||
return {
|
||||
.relation_flags = cast_meta_flags(pose.flags),
|
||||
.relation_flags = from_pose_flags(pose.flags),
|
||||
.pose = xrt_cast(XrPosef{
|
||||
.orientation = pose.orientation,
|
||||
.position = {
|
||||
|
||||
@@ -34,23 +34,6 @@
|
||||
|
||||
using namespace xrt::auxiliary::math;
|
||||
|
||||
static xrt_space_relation_flags cast_flags(uint8_t in_flags)
|
||||
{
|
||||
std::underlying_type_t<xrt_space_relation_flags> flags{};
|
||||
if (in_flags & wivrn::from_headset::htc_body::orientation_valid)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::htc_body::position_valid)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::htc_body::orientation_tracked)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
|
||||
|
||||
if (in_flags & wivrn::from_headset::htc_body::position_tracked)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
|
||||
return xrt_space_relation_flags(flags);
|
||||
}
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
@@ -90,7 +73,7 @@ xrt_space_relation tracker_pose_list::extrapolate(const xrt_space_relation & a,
|
||||
void tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::htc_body::pose & pose, const clock_offset & offset)
|
||||
{
|
||||
xrt_space_relation rel{
|
||||
.relation_flags = cast_flags(pose.flags),
|
||||
.relation_flags = from_pose_flags(pose.flags),
|
||||
.pose = xrt_cast(pose.pose),
|
||||
};
|
||||
add_sample(produced_timestamp, timestamp, rel, offset);
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "xrt_cast.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -45,3 +47,21 @@ XRT_CAST(XrFovf, xrt_fov)
|
||||
|
||||
XRT_CAST(xrt_pose, XrPosef)
|
||||
XRT_CAST(xrt_fov, XrFovf)
|
||||
|
||||
xrt_space_relation_flags from_pose_flags(uint8_t in_flags)
|
||||
{
|
||||
std::underlying_type_t<xrt_space_relation_flags> flags{};
|
||||
if (in_flags & wivrn::from_headset::pose_flags::orientation_valid)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
|
||||
if (in_flags & wivrn::from_headset::pose_flags::position_valid)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
|
||||
if (in_flags & wivrn::from_headset::pose_flags::linear_velocity_valid)
|
||||
flags |= XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT;
|
||||
if (in_flags & wivrn::from_headset::pose_flags::angular_velocity_valid)
|
||||
flags |= XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT;
|
||||
if (in_flags & wivrn::from_headset::pose_flags::orientation_tracked)
|
||||
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
|
||||
if (in_flags & wivrn::from_headset::pose_flags::position_tracked)
|
||||
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
|
||||
return xrt_space_relation_flags(flags);
|
||||
}
|
||||
|
||||
@@ -29,3 +29,5 @@ xrt_fov xrt_cast(const XrFovf &);
|
||||
|
||||
XrPosef xrt_cast(const xrt_pose &);
|
||||
XrFovf xrt_cast(const xrt_fov &);
|
||||
|
||||
xrt_space_relation_flags from_pose_flags(uint8_t in_flags);
|
||||
|
||||
Reference in New Issue
Block a user