From 8921edb954f93adf51f8186d205f375e816c01fd Mon Sep 17 00:00:00 2001 From: pereslav Date: Wed, 16 Jun 2021 23:58:07 +0100 Subject: [PATCH] Fixed crash when BlastFamilyComponent is used on an entity with no render mesh data --- .../Components/BlastFamilyComponent.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp index 1da9663b8f..bf1f3bc5af 100644 --- a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp @@ -286,9 +286,13 @@ namespace Blast // Create damage and actor render managers m_damageManager = AZStd::make_unique(blastMaterial, m_family->GetActorTracker()); - m_actorRenderManager = AZStd::make_unique( - AZ::RPI::Scene::GetFeatureProcessorForEntity(GetEntityId()), - m_meshDataComponent, GetEntityId(), m_blastAsset->GetPxAsset()->getChunkCount(), AZ::Vector3(transform.GetUniformScale())); + + if (m_meshDataComponent) + { + m_actorRenderManager = AZStd::make_unique( + AZ::RPI::Scene::GetFeatureProcessorForEntity(GetEntityId()), + m_meshDataComponent, GetEntityId(), m_blastAsset->GetPxAsset()->getChunkCount(), AZ::Vector3(transform.GetUniformScale())); + } // Spawn the family m_family->Spawn(transform); @@ -540,7 +544,11 @@ namespace Blast void BlastFamilyComponent::OnActorCreated([[maybe_unused]] const BlastFamily& family, const BlastActor& actor) { - m_actorRenderManager->OnActorCreated(actor); + if (m_actorRenderManager) + { + m_actorRenderManager->OnActorCreated(actor); + } + m_solver->notifyActorCreated(*actor.GetTkActor().getActorLL()); if (auto* physicsSystem = AZ::Interface::Get()) @@ -576,7 +584,11 @@ namespace Blast } m_solver->notifyActorDestroyed(*actor.GetTkActor().getActorLL()); - m_actorRenderManager->OnActorDestroyed(actor); + + if (m_actorRenderManager) + { + m_actorRenderManager->OnActorDestroyed(actor); + } } // Update positions of entities with render meshes corresponding to their right dynamic bodies.