Networking bugfixes

This commit is contained in:
2016-01-24 18:37:36 +01:00
parent b4081b3e45
commit 9f3d887ac4
3 changed files with 15 additions and 9 deletions
+2 -5
View File
@@ -8,9 +8,7 @@
</c:AABB>
<c:Collidable/>
<c:Model/>
<c:Physics>
<Gravity>false</Gravity>
</c:Physics>
<c:Physics/>
<c:Player>
<MovementSpeed>5</MovementSpeed>
</c:Player>
@@ -20,7 +18,7 @@
</Team>
</c:Team>
<c:Transform>
<Position X="-0.550999999" Y="0.0264999866" Z="3.01600003"/>
<Position X="-0.246963501" Y="0.0265000071" Z="3.01600003"/>
<Orientation X="0" Y="2.14675093" Z="0"/>
</c:Transform>
</Components>
@@ -31,7 +29,6 @@
<c:Camera/>
<c:Transform>
<Position X="0" Y="1.37700009" Z="0"/>
<Orientation X="0.921535373" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
+5
View File
@@ -137,6 +137,11 @@ EntityID World::generateEntityID()
void World::deleteEntityRecursive(EntityID entity, bool cascaded /*= false*/)
{
// Don't attempt to delete entities that don't exist anyway
if (!ValidEntity(entity)) {
return;
}
if (m_EventBroker != nullptr) {
Events::EntityDeleted e;
e.DeletedEntity = entity;
+8 -4
View File
@@ -12,6 +12,11 @@ InterpolationSystem::InterpolationSystem(World* world, EventBroker* eventBroker)
void InterpolationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& transform, double dt)
{
// Don't interpolate entities that might already have been removed
if (!entity.Valid()) {
return;
}
if (m_NextTransform.find(transform.EntityID) != m_NextTransform.end()) { // Exists in map
m_NextTransform[transform.EntityID].interpolationTime += dt;
Transform sTransform = m_NextTransform[transform.EntityID];
@@ -31,11 +36,10 @@ void InterpolationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe
// Position
glm::vec3 nextPosition = sTransform.Position;
glm::vec3 currentPosition = static_cast<glm::vec3>(transform["Position"]);
// HACK: Hardcoded tolerance value for player position desync = 1
if (isLocalPlayer && glm::length(nextPosition - currentPosition) < 1.f) {
return;
// HACK: Don't force position for players
if (!isLocalPlayer) {
(glm::vec3&)transform["Position"] += vectorInterpolation<glm::vec3>(currentPosition, nextPosition, sTransform.interpolationTime);
}
(glm::vec3&)transform["Position"] += vectorInterpolation<glm::vec3>(currentPosition, nextPosition, sTransform.interpolationTime);
// Orientation
// Don't force orientation for players
if (!isLocalPlayer) {