Merge pull request #7534 from aws-lumberyard-dev/mp_desync_nettime

Fix inadvertent exclusion of NetEntities during filtering and missing netcomponent notification
monroegm-disable-blank-issue-2
puvvadar 4 years ago committed by GitHub
commit 61e2929b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -122,43 +122,41 @@ namespace Multiplayer
{
AZ::Entity* entity = static_cast<AZ::Entity*>(visEntry->m_userData);
NetworkEntityHandle entityHandle(entity, networkEntityTracker);
if (entityHandle.GetNetBindComponent() == nullptr)
if (entityHandle.GetNetBindComponent() != nullptr)
{
// Not a net-bound entity, terminate processing of this entity
return;
}
const AZ::Aabb currentBounds = entityBoundsUnion->GetEntityWorldBoundsUnion(entity->GetId());
const AZ::Vector3 currentCenter = currentBounds.GetCenter();
NetworkTransformComponent* networkTransform = entity->template FindComponent<NetworkTransformComponent>();
if (debugDisplay)
{
debugDisplay->SetColor(AZ::Colors::White);
debugDisplay->DrawWireBox(currentBounds.GetMin(), currentBounds.GetMax());
}
if (networkTransform != nullptr)
{
// Get the rewound position for target host frame ID plus the one preceding it for potential lerp
AZ::Vector3 rewindCenter = networkTransform->GetTranslation();
const AZ::Vector3 rewindCenterPrevious = networkTransform->GetTranslationPrevious();
const float blendFactor = GetNetworkTime()->GetHostBlendFactor();
if (!AZ::IsClose(blendFactor, 1.0f) && !rewindCenter.IsClose(rewindCenterPrevious))
{
// If we have a blend factor, lerp the translation for accuracy
rewindCenter = rewindCenterPrevious.Lerp(rewindCenter, blendFactor);
}
const AZ::Vector3 rewindOffset = rewindCenter - currentCenter; // Compute offset between rewound and current positions
const AZ::Aabb rewoundAabb = currentBounds.GetTranslated(rewindOffset); // Apply offset to the entity aabb
const AZ::Aabb currentBounds = entityBoundsUnion->GetEntityWorldBoundsUnion(entity->GetId());
const AZ::Vector3 currentCenter = currentBounds.GetCenter();
NetworkTransformComponent* networkTransform = entity->template FindComponent<NetworkTransformComponent>();
if (debugDisplay)
{
debugDisplay->SetColor(AZ::Colors::Grey);
debugDisplay->DrawWireBox(rewoundAabb.GetMin(), rewoundAabb.GetMax());
debugDisplay->SetColor(AZ::Colors::White);
debugDisplay->DrawWireBox(currentBounds.GetMin(), currentBounds.GetMax());
}
if (AZ::ShapeIntersection::Overlaps(rewoundAabb, rewindVolume)) // Validate the rewound aabb intersects our rewind volume
if (networkTransform != nullptr)
{
m_rewoundEntities.push_back(entityHandle);
// Get the rewound position for target host frame ID plus the one preceding it for potential lerp
AZ::Vector3 rewindCenter = networkTransform->GetTranslation();
const AZ::Vector3 rewindCenterPrevious = networkTransform->GetTranslationPrevious();
const float blendFactor = GetNetworkTime()->GetHostBlendFactor();
if (!AZ::IsClose(blendFactor, 1.0f) && !rewindCenter.IsClose(rewindCenterPrevious))
{
// If we have a blend factor, lerp the translation for accuracy
rewindCenter = rewindCenterPrevious.Lerp(rewindCenter, blendFactor);
}
const AZ::Vector3 rewindOffset = rewindCenter - currentCenter; // Compute offset between rewound and current positions
const AZ::Aabb rewoundAabb = currentBounds.GetTranslated(rewindOffset); // Apply offset to the entity aabb
if (debugDisplay)
{
debugDisplay->SetColor(AZ::Colors::Grey);
debugDisplay->DrawWireBox(rewoundAabb.GetMin(), rewoundAabb.GetMax());
}
if (AZ::ShapeIntersection::Overlaps(rewoundAabb, rewindVolume)) // Validate the rewound aabb intersects our rewind volume
{
m_rewoundEntities.push_back(entityHandle);
entityHandle.GetNetBindComponent()->NotifySyncRewindState();
}
}
}
}

Loading…
Cancel
Save