Merge remote-tracking branch 'origin/Networking' into Networking
This commit is contained in:
@@ -36,6 +36,18 @@ EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
|
||||
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
|
||||
{
|
||||
EntityWrapper entity = *this;
|
||||
while (entity.Parent().Valid()) {
|
||||
entity = entity.Parent();
|
||||
if (entity == potentialParent) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EntityWrapper::Valid()
|
||||
{
|
||||
if (this->World == nullptr) {
|
||||
|
||||
@@ -48,14 +48,9 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
}
|
||||
|
||||
EntityWrapper entity(m_World, modelComponent.EntityID);
|
||||
bool isLocalPlayer = entity == m_LocalPlayer;
|
||||
while (entity.Parent().Valid()) {
|
||||
entity = entity.Parent();
|
||||
if (entity == m_LocalPlayer) {
|
||||
isLocalPlayer = true;
|
||||
}
|
||||
}
|
||||
if (isLocalPlayer) {
|
||||
|
||||
// Don't render the local player
|
||||
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -149,18 +144,6 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
|
||||
continue;
|
||||
}
|
||||
|
||||
EntityWrapper entity(m_World, textComponent.EntityID);
|
||||
bool isLocalPlayer = entity == m_LocalPlayer;
|
||||
while (entity.Parent().Valid()) {
|
||||
entity = entity.Parent();
|
||||
if (entity == m_LocalPlayer) {
|
||||
isLocalPlayer = true;
|
||||
}
|
||||
}
|
||||
if (isLocalPlayer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Font* font;
|
||||
try {
|
||||
font = ResourceManager::Load<Font>(resource);
|
||||
|
||||
@@ -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"]));
|
||||
|
||||
Reference in New Issue
Block a user