From 0a6ddfab5efd24ab232105927f04200a393debeb Mon Sep 17 00:00:00 2001 From: puvvadar Date: Fri, 1 Oct 2021 11:02:12 -0700 Subject: [PATCH] Revert optimization change in favor of another PR Signed-off-by: puvvadar --- .../Source/MultiplayerSystemComponent.cpp | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index b1d80a87b5..71e8b04d85 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -903,9 +903,8 @@ namespace Multiplayer // Unfortunately necessary, as NotifyPreRender can update transforms and thus cause a deadlock inside the vis system AZStd::vector gatheredEntities; - INetworkEntityManager* netEntityManager = GetNetworkEntityManager(); AZ::Interface::Get()->GetDefaultVisibilityScene()->Enumerate(viewFrustum, - [netEntityManager, &gatheredEntities](const AzFramework::IVisibilityScene::NodeData& nodeData) + [&gatheredEntities](const AzFramework::IVisibilityScene::NodeData& nodeData) { gatheredEntities.reserve(gatheredEntities.size() + nodeData.m_entries.size()); for (AzFramework::VisibilityEntry* visEntry : nodeData.m_entries) @@ -913,14 +912,10 @@ namespace Multiplayer if (visEntry->m_typeFlags & AzFramework::VisibilityEntry::TypeFlags::TYPE_Entity) { AZ::Entity* entity = static_cast(visEntry->m_userData); - NetEntityId netEntitydId = netEntityManager->GetNetEntityIdById(entity->GetId()); - if (netEntitydId != InvalidNetEntityId) + NetBindComponent* netBindComponent = entity->FindComponent(); + if (netBindComponent != nullptr) { - NetBindComponent* netBindComponent = netEntityManager->GetEntity(netEntitydId).GetNetBindComponent(); - if (netBindComponent != nullptr) - { - gatheredEntities.push_back(netBindComponent); - } + gatheredEntities.push_back(netBindComponent); } } } @@ -937,14 +932,10 @@ namespace Multiplayer for (auto& iter : *(m_networkEntityManager.GetNetworkEntityTracker())) { AZ::Entity* entity = iter.second; - NetEntityId netEntitydId = GetNetworkEntityManager()->GetNetEntityIdById(entity->GetId()); - if (netEntitydId != InvalidNetEntityId) + NetBindComponent* netBindComponent = entity->FindComponent(); + if (netBindComponent != nullptr) { - NetBindComponent* netBindComponent = GetNetworkEntityManager()->GetEntity(netEntitydId).GetNetBindComponent(); - if (netBindComponent != nullptr) - { - netBindComponent->NotifyPreRender(deltaTime); - } + netBindComponent->NotifyPreRender(deltaTime); } } }