Disable view extrapolation

This commit is contained in:
Patrick Nicolas
2024-09-03 23:34:23 +02:00
parent 7455af1e41
commit e6496c869c
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -27,7 +27,7 @@
#include <list> #include <list>
#include <mutex> #include <mutex>
template <typename Derived, typename Data, bool extrapolate = false, size_t MaxSamples = 10> template <typename Derived, typename Data, XrDuration extrapolation = 0, size_t MaxSamples = 10>
class history class history
{ {
struct TimedData : public Data struct TimedData : public Data
@@ -127,10 +127,11 @@ public:
if (data.front().at_timestamp_ns > at_timestamp_ns) if (data.front().at_timestamp_ns > at_timestamp_ns)
{ {
if constexpr (extrapolate) if constexpr (extrapolation)
{ {
auto second = data.begin(); auto second = data.begin();
auto first = second++; auto first = second++;
at_timestamp_ns = std::max(at_timestamp_ns, data.front().at_timestamp_ns - extrapolation);
return {ex, Derived::extrapolate(*first, *second, first->at_timestamp_ns, second->at_timestamp_ns, at_timestamp_ns)}; return {ex, Derived::extrapolate(*first, *second, first->at_timestamp_ns, second->at_timestamp_ns, at_timestamp_ns)};
} }
else else
@@ -147,10 +148,11 @@ public:
} }
} }
if constexpr (extrapolate) if constexpr (extrapolation)
{ {
auto prev = data.rbegin(); auto prev = data.rbegin();
auto last = prev++; auto last = prev++;
at_timestamp_ns = std::min(at_timestamp_ns, data.back().at_timestamp_ns + extrapolation);
return {ex, Derived::extrapolate(*prev, *last, prev->at_timestamp_ns, last->at_timestamp_ns, at_timestamp_ns)}; return {ex, Derived::extrapolate(*prev, *last, prev->at_timestamp_ns, last->at_timestamp_ns, at_timestamp_ns)};
} }
else else
+1 -1
View File
@@ -30,7 +30,7 @@ struct tracked_views
std::array<xrt_fov, 2> fovs; std::array<xrt_fov, 2> fovs;
}; };
class view_list : public history<view_list, tracked_views, true> class view_list : public history<view_list, tracked_views>
{ {
public: public:
static tracked_views interpolate(const tracked_views & a, const tracked_views & b, float t); static tracked_views interpolate(const tracked_views & a, const tracked_views & b, float t);