From 3e90ed564c0de4288e29f84087fd481c596681d3 Mon Sep 17 00:00:00 2001 From: Jocke Date: Mon, 18 Jan 2016 18:07:39 +0100 Subject: [PATCH] Moved Struct in InterpolationSystem.h and fixed bug. --- include/Game/InterpolationSystem.h | 14 ++++++++------ src/Game/InterpolationSystem.cpp | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/Game/InterpolationSystem.h b/include/Game/InterpolationSystem.h index c87ee5a7..2acea373 100644 --- a/include/Game/InterpolationSystem.h +++ b/include/Game/InterpolationSystem.h @@ -12,15 +12,17 @@ #include "Network/EInterpolate.h" -struct Transform { - glm::vec3 Position; - glm::vec3 Scale; - glm::vec3 Orientation; - double interpolationTime; -}; class InterpolationSystem : public PureSystem { + struct Transform + { + glm::vec3 Position; + glm::vec3 Scale; + glm::vec3 Orientation; + double interpolationTime; + }; + public: InterpolationSystem(EventBroker* eventbroker) : PureSystem(eventbroker, "Transform") diff --git a/src/Game/InterpolationSystem.cpp b/src/Game/InterpolationSystem.cpp index d2d81fda..72207531 100644 --- a/src/Game/InterpolationSystem.cpp +++ b/src/Game/InterpolationSystem.cpp @@ -16,7 +16,7 @@ void InterpolationSystem::UpdateComponent(World * world, ComponentWrapper & tran } glm::vec3 nextPosition = sTransform.Position; glm::vec3 currentPosition = static_cast(transform["Position"]); - transform["Position"] = vectorInterpolation(currentPosition, nextPosition, sTransform.interpolationTime); + (glm::vec3&)transform["Position"] += vectorInterpolation(currentPosition, nextPosition, sTransform.interpolationTime); } } @@ -37,6 +37,7 @@ bool InterpolationSystem::OnInterpolate(const Events::Interpolate & e) memcpy(&transform.Orientation, e.DataArray.get() + offset, sizeof(glm::vec3)); offset += sizeof(glm::vec3); memcpy(&transform.Scale, e.DataArray.get() + offset, sizeof(glm::vec3)); + transform.interpolationTime = 0.0f; // Check if queue already exists if (m_InterpolationPoints.find(e.Entity) != m_InterpolationPoints.end()) { // Did exist, push to queue