Remove bool return from update_tracking
This commit is contained in:
@@ -120,14 +120,13 @@ static xrt_hand_joint_set convert_joints(const std::optional<std::array<from_hea
|
||||
return output_joints;
|
||||
}
|
||||
|
||||
bool hand_joints_list::update_tracking(const from_headset::hand_tracking & tracking, const clock_offset & offset)
|
||||
void hand_joints_list::update_tracking(const from_headset::hand_tracking & tracking, const clock_offset & offset)
|
||||
{
|
||||
if (tracking.hand == hand_id)
|
||||
return add_sample(
|
||||
add_sample(
|
||||
tracking.production_timestamp,
|
||||
tracking.timestamp,
|
||||
convert_joints(tracking.joints),
|
||||
offset);
|
||||
return true;
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -38,6 +38,6 @@ public:
|
||||
hand_joints_list(int hand_id) :
|
||||
hand_id(hand_id) {}
|
||||
|
||||
bool update_tracking(const wivrn::from_headset::hand_tracking & tracking, const clock_offset & offset);
|
||||
void update_tracking(const wivrn::from_headset::hand_tracking & tracking, const clock_offset & offset);
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
+3
-13
@@ -20,7 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "clock_offset.h"
|
||||
#include "os/os_time.h"
|
||||
#include "util/u_time.h"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
@@ -40,21 +40,15 @@ class history
|
||||
std::array<TimedData, MaxSamples> data{};
|
||||
|
||||
std::mutex mutex;
|
||||
XrTime last_request;
|
||||
|
||||
protected:
|
||||
history() :
|
||||
last_request(os_monotonic_get_ns()) {}
|
||||
|
||||
// return true if object is active (last request is not too old)
|
||||
bool add_sample(XrTime produced_timestamp, XrTime timestamp, const Data & sample, const clock_offset & offset)
|
||||
void add_sample(XrTime produced_timestamp, XrTime timestamp, const Data & sample, const clock_offset & offset)
|
||||
{
|
||||
XrTime produced = offset.from_headset(produced_timestamp);
|
||||
XrTime t = offset.from_headset(timestamp);
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
bool active = produced - last_request < 1'000'000'000;
|
||||
|
||||
TimedData * target = data.data();
|
||||
if (offset)
|
||||
{
|
||||
@@ -62,7 +56,7 @@ protected:
|
||||
{
|
||||
// Discard reordered packets
|
||||
if (item.produced_timestamp > produced)
|
||||
return active;
|
||||
return;
|
||||
|
||||
if (std::abs(item.at_timestamp_ns - t) < 2'000'000)
|
||||
{
|
||||
@@ -75,7 +69,6 @@ protected:
|
||||
}
|
||||
}
|
||||
*target = TimedData(sample, produced, t);
|
||||
return active;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -83,8 +76,6 @@ public:
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
last_request = os_monotonic_get_ns();
|
||||
|
||||
TimedData * before = nullptr;
|
||||
TimedData * after = nullptr;
|
||||
|
||||
@@ -133,7 +124,6 @@ public:
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
data.fill({});
|
||||
last_request = os_monotonic_get_ns();
|
||||
}
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "math/m_eigen_interop.hpp"
|
||||
#include "math/m_space.h"
|
||||
#include "math/m_vec3.h"
|
||||
#include "os/os_time.h"
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
@@ -91,10 +90,10 @@ xrt_space_relation pose_list::extrapolate(const xrt_space_relation & a, const xr
|
||||
return res;
|
||||
}
|
||||
|
||||
bool pose_list::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||
void pose_list::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||
{
|
||||
if (source)
|
||||
return false;
|
||||
return;
|
||||
|
||||
for (const auto & pose: tracking.device_poses)
|
||||
{
|
||||
@@ -103,7 +102,6 @@ bool pose_list::update_tracking(const from_headset::tracking & tracking, const c
|
||||
|
||||
return add_sample(tracking.production_timestamp, tracking.timestamp, pose, offset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void pose_list::set_derived(pose_list * source, xrt_pose offset, bool force)
|
||||
@@ -143,10 +141,9 @@ void pose_list::reset()
|
||||
std::lock_guard lock(mutex);
|
||||
positions.reset();
|
||||
orientations.reset();
|
||||
last_request = os_monotonic_get_ns();
|
||||
}
|
||||
|
||||
bool pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const from_headset::tracking::pose & pose, const clock_offset & offset)
|
||||
void pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const from_headset::tracking::pose & pose, const clock_offset & offset)
|
||||
{
|
||||
production_timestamp = offset.from_headset(production_timestamp);
|
||||
timestamp = offset.from_headset(timestamp);
|
||||
@@ -195,15 +192,12 @@ bool pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const
|
||||
std::lock_guard lock(mutex);
|
||||
positions.add_sample(position);
|
||||
orientations.add_sample(orientation);
|
||||
return timestamp - last_request < 1'000'000'000;
|
||||
}
|
||||
|
||||
std::pair<XrTime, xrt_space_relation> pose_list::get_at(XrTime at_timestamp_ns)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
last_request = os_monotonic_get_ns();
|
||||
|
||||
xrt_space_relation ret{};
|
||||
auto flags = [&](int f) {
|
||||
ret.relation_flags = xrt_space_relation_flags(int(ret.relation_flags) | f);
|
||||
|
||||
@@ -35,7 +35,6 @@ class pose_list
|
||||
xrt_pose offset;
|
||||
std::atomic_bool derive_forced = false;
|
||||
std::mutex mutex;
|
||||
XrTime last_request;
|
||||
|
||||
polynomial_interpolator<3> positions;
|
||||
polynomial_interpolator<4, true> orientations;
|
||||
@@ -49,7 +48,7 @@ public:
|
||||
pose_list(wivrn::device_id id) :
|
||||
device(id) {}
|
||||
|
||||
bool update_tracking(const wivrn::from_headset::tracking &, const clock_offset & offset);
|
||||
void update_tracking(const wivrn::from_headset::tracking &, const clock_offset & offset);
|
||||
void set_derived(pose_list * source, xrt_pose offset, bool force = false);
|
||||
|
||||
std::tuple<XrTime, xrt_space_relation, device_id> get_pose_at(XrTime at_timestamp_ns);
|
||||
@@ -58,6 +57,6 @@ public:
|
||||
std::pair<XrTime, xrt_space_relation> get_at(XrTime at_timestamp_ns);
|
||||
|
||||
private:
|
||||
bool add_sample(XrTime production_timestamp, XrTime timestamp, const from_headset::tracking::pose & pose, const clock_offset & offset);
|
||||
void add_sample(XrTime production_timestamp, XrTime timestamp, const from_headset::tracking::pose & pose, const clock_offset & offset);
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
bool view_list::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||
void view_list::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||
{
|
||||
if (not std::ranges::contains(tracking.device_poses, device_id::HEAD, &from_headset::tracking::pose::device))
|
||||
return true;
|
||||
return;
|
||||
|
||||
std::lock_guard lock(mutex);
|
||||
flags = tracking.view_flags;
|
||||
@@ -37,7 +37,7 @@ bool view_list::update_tracking(const from_headset::tracking & tracking, const c
|
||||
fovs[eye] = xrt_cast(tracking.views[eye].fov);
|
||||
}
|
||||
|
||||
return head_poses.update_tracking(tracking, offset);
|
||||
head_poses.update_tracking(tracking, offset);
|
||||
}
|
||||
|
||||
std::pair<XrTime, tracked_views> view_list::get_at(XrTime at_timestamp_ns)
|
||||
|
||||
@@ -44,7 +44,7 @@ class view_list
|
||||
std::array<xrt_fov, 2> fovs;
|
||||
|
||||
public:
|
||||
bool update_tracking(const from_headset::tracking & tracking, const clock_offset & offset);
|
||||
void update_tracking(const from_headset::tracking & tracking, const clock_offset & offset);
|
||||
std::pair<XrTime, tracked_views> get_at(XrTime at_timestamp_ns);
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -75,9 +75,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
bool update_tracking(const XrTime & production_timestamp, const XrTime & timestamp, const wivrn_android_face_data & data, const clock_offset & offset)
|
||||
void update_tracking(const XrTime & production_timestamp, const XrTime & timestamp, const wivrn_android_face_data & data, const clock_offset & offset)
|
||||
{
|
||||
return this->add_sample(production_timestamp, timestamp, data, offset);
|
||||
add_sample(production_timestamp, timestamp, data, offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_session.h"
|
||||
|
||||
#include "os/os_time.h"
|
||||
#include "util/u_logging.h"
|
||||
#include <array>
|
||||
#include <format>
|
||||
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
bool update_tracking(const XrTime & production_timestamp, const XrTime & timestamp, const wivrn_fb_face2_data & data, const clock_offset & offset)
|
||||
void update_tracking(const XrTime & production_timestamp, const XrTime & timestamp, const wivrn_fb_face2_data & data, const clock_offset & offset)
|
||||
{
|
||||
return this->add_sample(production_timestamp, timestamp, data, offset);
|
||||
add_sample(production_timestamp, timestamp, data, offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ xrt_space_relation tracker_pose_list::extrapolate(const xrt_space_relation & a,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::body_tracking::pose & pose, const clock_offset & offset)
|
||||
void tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::body_tracking::pose & pose, const clock_offset & offset)
|
||||
{
|
||||
return add_sample(produced_timestamp, timestamp, convert_pose(pose), offset);
|
||||
add_sample(produced_timestamp, timestamp, convert_pose(pose), offset);
|
||||
}
|
||||
|
||||
static xrt_space_relation_flags convert_flags(uint8_t flags)
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
tracker_pose_list() = default;
|
||||
|
||||
bool update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::body_tracking::pose & pose, const clock_offset & offset);
|
||||
void update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::body_tracking::pose & pose, const clock_offset & offset);
|
||||
|
||||
static xrt_space_relation convert_pose(const wivrn::from_headset::body_tracking::pose &);
|
||||
};
|
||||
|
||||
@@ -93,9 +93,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
bool update_tracking(const XrTime & production_timestamp, const XrTime & timestamp, const wivrn_htc_face_data & data, const clock_offset & offset)
|
||||
void update_tracking(const XrTime & production_timestamp, const XrTime & timestamp, const wivrn_htc_face_data & data, const clock_offset & offset)
|
||||
{
|
||||
return this->add_sample(production_timestamp, timestamp, data, offset);
|
||||
add_sample(production_timestamp, timestamp, data, offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user