EditorMeshStats.cpp 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/Serialization/Json/RegistrationContext.h>
  11. #include <Mesh/EditorMeshStats.h>
  12. #include <Mesh/EditorMeshStatsSerializer.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. void EditorMeshStatsForLod::Reflect(ReflectContext* context)
  18. {
  19. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  20. {
  21. serializeContext->Class<EditorMeshStatsForLod>()
  22. ->Field("meshCount", &EditorMeshStatsForLod::m_meshCount)
  23. ->Field("vertCount", &EditorMeshStatsForLod::m_vertCount)
  24. ->Field("triCount", &EditorMeshStatsForLod::m_triCount)
  25. ;
  26. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  27. {
  28. editContext->Class<EditorMeshStatsForLod>("EditorMeshStatsForLod", "")
  29. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  30. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  31. ->DataElement(AZ::Edit::UIHandlers::Default, &EditorMeshStatsForLod::m_meshCount, "Mesh Count", "")
  32. ->Attribute(AZ::Edit::Attributes::ReadOnly, true)
  33. ->DataElement(AZ::Edit::UIHandlers::Default, &EditorMeshStatsForLod::m_vertCount, "Vert Count", "")
  34. ->Attribute(AZ::Edit::Attributes::ReadOnly, true)
  35. ->DataElement(AZ::Edit::UIHandlers::Default, &EditorMeshStatsForLod::m_triCount, "Tri Count", "")
  36. ->Attribute(AZ::Edit::Attributes::ReadOnly, true)
  37. ;
  38. }
  39. }
  40. }
  41. void EditorMeshStats::Reflect(ReflectContext* context)
  42. {
  43. EditorMeshStatsForLod::Reflect(context);
  44. if (auto jsonContext = azrtti_cast<JsonRegistrationContext*>(context))
  45. {
  46. jsonContext->Serializer<JsonEditorMeshStatsSerializer>()->HandlesType<EditorMeshStats>();
  47. }
  48. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  49. {
  50. serializeContext->Class<EditorMeshStats>()
  51. ->Field("meshStatsForLod", &EditorMeshStats::m_meshStatsForLod)
  52. ;
  53. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  54. {
  55. editContext->Class<EditorMeshStats>(
  56. "EditorMeshStats", "")
  57. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  58. ->DataElement(AZ::Edit::UIHandlers::Default, &EditorMeshStats::m_meshStatsForLod, "Mesh Stats", "")
  59. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  60. ->Attribute(AZ::Edit::Attributes::ContainerCanBeModified, false)
  61. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  62. ->Attribute(AZ::Edit::Attributes::IndexedChildNameLabelOverride, &EditorMeshStats::GetLodLabel)
  63. ;
  64. }
  65. }
  66. }
  67. AZStd::string EditorMeshStats::GetLodLabel(int index) const
  68. {
  69. return AZStd::string::format("LOD %d", index);
  70. }
  71. } // namespace Render
  72. } // namespace AZ