Merge branch 'Networking' of github.com:teamfisk/TacticalZ into Networking
# Conflicts: # include/Game/InterpolationSystem.h # src/Game/InterpolationSystem.cpp
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "Network/EInterpolate.h"
|
||||
|
||||
class Client : public Network
|
||||
{
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
|
||||
#include "Network/EInterpolate.h"
|
||||
|
||||
|
||||
class InterpolationSystem : public PureSystem
|
||||
{
|
||||
struct Transform {
|
||||
struct Transform
|
||||
{
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Scale;
|
||||
glm::vec3 Orientation;
|
||||
|
||||
@@ -119,12 +119,16 @@ void Client::InterpolateFields(Packet& packet, const ComponentInfo& componentInf
|
||||
int sizeOfFields = 0;
|
||||
for (auto field : componentInfo.FieldsInOrder) {
|
||||
ComponentInfo::Field_t fieldInfo = componentInfo.Fields.at(field);
|
||||
sizeOfFields = fieldInfo.Stride;
|
||||
sizeOfFields += fieldInfo.Stride;
|
||||
}
|
||||
// Is the size correct?
|
||||
boost::shared_array<char> eventData(new char[componentInfo.Meta.Stride]);
|
||||
memcpy(eventData.get(), packet.ReadData(componentInfo.Meta.Stride), componentInfo.Meta.Stride);
|
||||
//Send event to interpolat system
|
||||
Events::Interpolate e;
|
||||
e.Entity = entityID;
|
||||
e.DataArray = eventData;
|
||||
m_EventBroker->Publish(e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ void InterpolationSystem::UpdateComponent(World * world, ComponentWrapper & tran
|
||||
sTransform.interpolationTime += dt;
|
||||
glm::vec3 nextPosition = sTransform.Position;
|
||||
glm::vec3 currentPosition = static_cast<glm::vec3>(transform["Position"]);
|
||||
transform["Position"] = vectorInterpolation(currentPosition, nextPosition, sTransform.interpolationTime);
|
||||
(glm::vec3&)transform["Position"] += vectorInterpolation(currentPosition, nextPosition, sTransform.interpolationTime);
|
||||
}
|
||||
|
||||
glm::vec3 InterpolationSystem::vectorInterpolation(glm::vec3 prev, glm::vec3 next, double currentTime)
|
||||
@@ -46,7 +46,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;
|
||||
transform.interpolationTime = 0.0f;
|
||||
m_InterpolationPoints[e.Entity] = transform;
|
||||
// Check if queue already exists
|
||||
//if (m_InterpolationPoints.find(e.Entity) != m_InterpolationPoints.end()) { // Did exist, push to queue
|
||||
|
||||
Reference in New Issue
Block a user