Added EntityWrapper::IsChildOf and made snapshot interpolation and rendering exceptions for player less hacky

This commit is contained in:
2016-01-23 11:44:16 +01:00
parent 31e7340daf
commit db0e67b9bd
7 changed files with 21 additions and 24 deletions
+3 -2
View File
@@ -27,16 +27,17 @@ void InterpolationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe
}
}
if (transform.Info.Name == "Transform") {
bool isLocalPlayer = entity == m_LocalPlayer || entity.Parent() == m_LocalPlayer;
bool isLocalPlayer = entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer);
// 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;
}
(glm::vec3&)transform["Position"] += vectorInterpolation<glm::vec3>(currentPosition, nextPosition, sTransform.interpolationTime);
// Orientation
//bool isPlayer = entity.HasComponent("Player") || entity.Parent().HasComponent("Player");
// Don't force orientation for players
if (!isLocalPlayer) {
glm::quat nextOrientation = sTransform.Orientation;
glm::quat currentOrientation = glm::quat(static_cast<glm::vec3>(transform["Orientation"]));