2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarJson.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
class InterpolationTracker {
|
|
|
|
public:
|
|
|
|
InterpolationTracker(Json config = Json());
|
|
|
|
|
|
|
|
// Should interpolation be enabled on entities at all? If this is false,
|
|
|
|
// extrapolationHint and interpolationLead will always return 0.
|
|
|
|
bool interpolationEnabled() const;
|
|
|
|
unsigned extrapolationHint() const;
|
|
|
|
|
2024-03-17 06:33:31 +00:00
|
|
|
// Time in-between entity updates
|
|
|
|
float entityUpdateDelta() const;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-17 06:33:31 +00:00
|
|
|
void receiveTimeUpdate(double remoteTime);
|
|
|
|
void update(double newLocalTime);
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-17 06:33:31 +00:00
|
|
|
// Lead time that incoming interpolated data as of this moment should be
|
2023-06-20 04:33:09 +00:00
|
|
|
// marked for. If interpolation is disabled, this is always 0.0
|
2024-03-17 06:33:31 +00:00
|
|
|
float interpolationLeadTime() const;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_interpolationEnabled;
|
2024-03-17 06:33:31 +00:00
|
|
|
float m_entityUpdateDelta;
|
|
|
|
double m_timeLead;
|
2023-06-20 04:33:09 +00:00
|
|
|
unsigned m_extrapolationHint;
|
2024-03-17 06:33:31 +00:00
|
|
|
double m_timeTrackFactor;
|
|
|
|
double m_timeMaxDistance;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-17 06:33:31 +00:00
|
|
|
double m_currentTime;
|
|
|
|
Maybe<double> m_lastTimeUpdate;
|
|
|
|
Maybe<double> m_predictedTime;
|
2023-06-20 04:33:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|