diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 2315c38095..474369a984 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -211,21 +211,17 @@ namespace AZ void EditorMeshComponent::OnModelReady(const Data::Asset& /*modelAsset*/, const Data::Instance& /*model*/) { m_stats.m_meshStatsForLod.clear(); - if (m_controller.GetConfiguration().IsAssetSet()) + for (auto& lod : m_controller.GetConfiguration().m_modelAsset->GetLodAssets()) { - auto lods = m_controller.GetConfiguration().m_modelAsset->GetLodAssets(); - for (auto& lod : lods) + EditorMeshStatsForLod stats; + auto meshes = lod->GetMeshes(); + stats.m_meshCount = lod->GetMeshes().size(); + for (auto& mesh : meshes) { - EditorMeshStatsForLod stats; - auto meshes = lod->GetMeshes(); - stats.m_meshCount = lod->GetMeshes().size(); - for (auto& mesh : meshes) - { - stats.m_vertCount += mesh.GetVertexCount(); - stats.m_triCount += mesh.GetIndexCount() / 3; - } - m_stats.m_meshStatsForLod.push_back(stats); + stats.m_vertCount += mesh.GetVertexCount(); + stats.m_triCount += mesh.GetIndexCount() / 3; } + m_stats.m_meshStatsForLod.push_back(stats); } m_stats.UpdateStringRepresentation(); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.h index 93966bfc74..3397540a92 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.h @@ -34,7 +34,6 @@ namespace AZ , private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler , private AzFramework::EntityDebugDisplayEventBus::Handler , private MeshComponentNotificationBus::Handler - , private Data::AssetBus::Handler { public: using BaseClass = EditorRenderComponentAdapter; @@ -74,6 +73,7 @@ namespace AZ // Flag used for button placement bool m_addMaterialComponentFlag = false; + // Stats for current mesh asset EditorMeshStats m_stats; }; } // namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshStats.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshStats.h index baf422d984..a2cca39a82 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshStats.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshStats.h @@ -26,7 +26,6 @@ namespace AZ AZ_RTTI(EditorMeshStatsForLod, "{626E3AEB-0F7A-4777-BAF1-2BBA8C1857ED}"); AZ_CLASS_ALLOCATOR(EditorMeshStatsForLod, SystemAllocator, 0); - int m_meshCount = 0; int m_vertCount = 0; int m_triCount = 0; @@ -38,11 +37,9 @@ namespace AZ AZ_CLASS_ALLOCATOR(EditorMeshStats, SystemAllocator, 0); static void Reflect(ReflectContext* context); - - AZStd::vector m_meshStatsForLod; - void UpdateStringRepresentation(); + AZStd::vector m_meshStatsForLod; AZStd::string m_stringRepresentation = {}; }; } // namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 6c9b4e6514..e7eecd3c7f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -49,7 +49,7 @@ namespace AZ } } - bool MeshComponentConfig::IsAssetSet() const + bool MeshComponentConfig::IsAssetSet() { return m_modelAsset.GetId().IsValid(); } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index e44fad07df..4d63e5e88d 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -44,7 +44,7 @@ namespace AZ static void Reflect(AZ::ReflectContext* context); // Editor helper functions - bool IsAssetSet() const; + bool IsAssetSet(); AZStd::vector> GetLodOverrideValues(); Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad };