From 5dc5117441d000cda49a67ed5d873c46d62daa92 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Thu, 14 Mar 2024 19:58:31 +0100 Subject: [PATCH] Don't accumulate delay if tracking is slow on client --- client/scenes/stream_tracking.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/scenes/stream_tracking.cpp b/client/scenes/stream_tracking.cpp index 61ad1922..627622df 100644 --- a/client/scenes/stream_tracking.cpp +++ b/client/scenes/stream_tracking.cpp @@ -124,6 +124,9 @@ void scenes::stream::tracking() if (now < t0) std::this_thread::sleep_for(std::chrono::nanoseconds(t0 - now - dt)); + // If thread can't keep up, skip timestamps + t0 += tracking_period * ((now - t0) / tracking_period); + for (XrTime Δt = 0; Δt < extrapolation_horizon; Δt += tracking_period) { from_headset::tracking packet{};