Merge branch 'development' into math_string_converters

This commit is contained in:
puvvadar
2022-02-14 10:42:48 -08:00
committed by GitHub
373 changed files with 15071 additions and 5781 deletions
@@ -22,6 +22,9 @@
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/std/sort.h>
AZ_CVAR(bool, bg_AssertNetBindOnDeactivationWithoutMarkForRemoval, false, nullptr, AZ::ConsoleFunctorFlags::Null,
"If true, assert when a multiplayer entity is deactivated without first calling MarkForRemoval from NetworkEntityManager.");
namespace Multiplayer
{
void NetBindComponent::Reflect(AZ::ReflectContext* context)
@@ -167,10 +170,13 @@ namespace Multiplayer
void NetBindComponent::Deactivate()
{
AZ_Assert(
m_needsToBeStopped == false,
"Entity (%s) appears to have been improperly deleted. Use MarkForRemoval to correctly clean up a networked entity.",
GetEntity() ? GetEntity()->GetName().c_str() : "null");
if (bg_AssertNetBindOnDeactivationWithoutMarkForRemoval)
{
AZ_Assert(
m_needsToBeStopped == false,
"Entity (%s) appears to have been improperly deleted. Use MarkForRemoval to correctly clean up a networked entity.",
GetEntity() ? GetEntity()->GetName().c_str() : "null");
}
m_handleLocalServerRpcMessageEventHandle.Disconnect();
if (NetworkRoleHasController(m_netEntityRole))
{
@@ -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();
}
}
}
}