#ifndef Systems_InterpolationSystem_h__ #define Systems_InterpolationSystem_h__ #include #include #include #include #include #include "Common.h" #include "Core/System.h" #include "Core/EventBroker.h" #include "Core/ResourceManager.h" #include "Core/ConfigFile.h" #include "Core/EPlayerSpawned.h" #include "Network/EInterpolate.h" class InterpolationSystem : public ImpureSystem { public: InterpolationSystem(SystemParams params); ~InterpolationSystem() { } virtual void Update(double dt) override; private: template struct Interpolation { Interpolation(const ComponentWrapper& Component, const std::string& Field, const T& Start, const T& Goal) : Component(Component) , Field(Field) , Start(Start) , Goal(Goal) { } ComponentWrapper Component; std::string Field; T Start; T Goal; double Alpha = 0.0; }; float m_SnapshotInterval; std::unordered_map> m_InterpolatePosition; std::unordered_map> m_InterpolateOrientation; std::unordered_map> m_InterpolateVelocity; EventRelay m_EInterpolate; bool InterpolationSystem::OnInterpolate(Events::Interpolate& e); template T vectorInterpolation(T prev, T next, double currentTime) { T difference = next - prev; T vector = difference * (static_cast(currentTime) / m_SnapshotInterval); return vector; } }; #endif