osb/source/game/StarInterpolationTracker.hpp

40 lines
972 B
C++
Raw Normal View History

#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;
// Time in-between entity updates
float entityUpdateDelta() const;
2023-06-20 04:33:09 +00:00
void receiveTimeUpdate(double remoteTime);
void update(double newLocalTime);
2023-06-20 04:33:09 +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
float interpolationLeadTime() const;
2023-06-20 04:33:09 +00:00
private:
bool m_interpolationEnabled;
float m_entityUpdateDelta;
double m_timeLead;
2023-06-20 04:33:09 +00:00
unsigned m_extrapolationHint;
double m_timeTrackFactor;
double m_timeMaxDistance;
2023-06-20 04:33:09 +00:00
double m_currentTime;
Maybe<double> m_lastTimeUpdate;
Maybe<double> m_predictedTime;
2023-06-20 04:33:09 +00:00
};
}