ManifestMetaInfoHandler.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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/Memory/SystemAllocator.h>
  9. #include <AzCore/std/containers/unordered_set.h>
  10. #include <AzToolsFramework/Debug/TraceContext.h>
  11. #include <SceneAPI/SceneCore/Containers/Scene.h>
  12. #include <SceneAPI/SceneCore/Utilities/Reporting.h>
  13. #include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
  14. #include <SceneAPI/SceneData/ManifestMetaInfoHandler.h>
  15. #include <SceneAPI/SceneData/Groups/MeshGroup.h>
  16. #include <SceneAPI/SceneData/Groups/SkeletonGroup.h>
  17. #include <SceneAPI/SceneData/Groups/SkinGroup.h>
  18. #include <SceneAPI/SceneData/Groups/AnimationGroup.h>
  19. #include <SceneAPI/SceneData/Rules/BlendShapeRule.h>
  20. #include <SceneAPI/SceneData/Rules/CommentRule.h>
  21. #include <SceneAPI/SceneData/Rules/LodRule.h>
  22. #include <SceneAPI/SceneData/Rules/MaterialRule.h>
  23. #include <SceneAPI/SceneData/Rules/UnmodifiableRule.h>
  24. #include <SceneAPI/SceneData/Rules/StaticMeshAdvancedRule.h>
  25. #include <SceneAPI/SceneData/Rules/SkeletonProxyRule.h>
  26. #include <SceneAPI/SceneData/Rules/TangentsRule.h>
  27. #include <SceneAPI/SceneData/Rules/SkinMeshAdvancedRule.h>
  28. #include <SceneAPI/SceneData/Rules/SkinRule.h>
  29. #include <SceneAPI/SceneData/Rules/CoordinateSystemRule.h>
  30. #include <SceneAPI/SceneData/Rules/TagRule.h>
  31. #include <SceneAPI/SceneData/Rules/UVsRule.h>
  32. namespace AZ
  33. {
  34. namespace SceneAPI
  35. {
  36. namespace SceneData
  37. {
  38. AZ_CLASS_ALLOCATOR_IMPL(ManifestMetaInfoHandler, SystemAllocator);
  39. ManifestMetaInfoHandler::ManifestMetaInfoHandler()
  40. {
  41. BusConnect();
  42. }
  43. ManifestMetaInfoHandler::~ManifestMetaInfoHandler()
  44. {
  45. BusDisconnect();
  46. }
  47. void ManifestMetaInfoHandler::GetAvailableModifiers(ModifiersList& modifiers, const Containers::Scene& /*scene*/,
  48. const DataTypes::IManifestObject& target)
  49. {
  50. AZ_TraceContext("Object Type", target.RTTI_GetTypeName());
  51. modifiers.push_back(SceneData::CommentRule::TYPEINFO_Uuid());
  52. modifiers.push_back(SceneData::UnmodifiableRule::TYPEINFO_Uuid());
  53. if (target.RTTI_IsTypeOf(DataTypes::IMeshGroup::TYPEINFO_Uuid()))
  54. {
  55. const DataTypes::IMeshGroup* group = azrtti_cast<const DataTypes::IMeshGroup*>(&target);
  56. const Containers::RuleContainer& rules = group->GetRuleContainerConst();
  57. AZStd::unordered_set<Uuid> existingRules;
  58. const size_t ruleCount = rules.GetRuleCount();
  59. for (size_t i = 0; i < ruleCount; ++i)
  60. {
  61. existingRules.insert(rules.GetRule(i)->RTTI_GetType());
  62. }
  63. if (existingRules.find(SceneData::LodRule::TYPEINFO_Uuid()) == existingRules.end())
  64. {
  65. modifiers.push_back(SceneData::LodRule::TYPEINFO_Uuid());
  66. }
  67. if (existingRules.find(SceneData::MaterialRule::TYPEINFO_Uuid()) == existingRules.end())
  68. {
  69. modifiers.push_back(SceneData::MaterialRule::TYPEINFO_Uuid());
  70. }
  71. if (existingRules.find(SceneData::StaticMeshAdvancedRule::TYPEINFO_Uuid()) == existingRules.end())
  72. {
  73. modifiers.push_back(SceneData::StaticMeshAdvancedRule::TYPEINFO_Uuid());
  74. }
  75. if (existingRules.find(SceneData::SkinRule::TYPEINFO_Uuid()) == existingRules.end())
  76. {
  77. modifiers.push_back(SceneData::SkinRule::TYPEINFO_Uuid());
  78. }
  79. if (existingRules.find(azrtti_typeid<CoordinateSystemRule>()) == existingRules.end())
  80. {
  81. modifiers.push_back(azrtti_typeid<CoordinateSystemRule>());
  82. }
  83. if (existingRules.find(SceneData::UVsRule::TYPEINFO_Uuid()) == existingRules.end())
  84. {
  85. modifiers.push_back(SceneData::UVsRule::TYPEINFO_Uuid());
  86. }
  87. if (existingRules.find(SceneData::TangentsRule::TYPEINFO_Uuid()) == existingRules.end())
  88. {
  89. modifiers.push_back(SceneData::TangentsRule::TYPEINFO_Uuid());
  90. }
  91. if (existingRules.find(SceneData::TagRule::TYPEINFO_Uuid()) == existingRules.end())
  92. {
  93. modifiers.push_back(SceneData::TagRule::TYPEINFO_Uuid());
  94. }
  95. }
  96. else if (target.RTTI_IsTypeOf(DataTypes::ISkinGroup::TYPEINFO_Uuid()))
  97. {
  98. const DataTypes::ISkinGroup* group = azrtti_cast<const DataTypes::ISkinGroup*>(&target);
  99. const Containers::RuleContainer& rules = group->GetRuleContainerConst();
  100. AZStd::unordered_set<AZ::Uuid> existingRules;
  101. const size_t ruleCount = rules.GetRuleCount();
  102. for (size_t i = 0; i < ruleCount; ++i)
  103. {
  104. existingRules.insert(rules.GetRule(i)->RTTI_GetType());
  105. }
  106. if (existingRules.find(SceneData::BlendShapeRule::TYPEINFO_Uuid()) == existingRules.end())
  107. {
  108. modifiers.push_back(SceneData::BlendShapeRule::TYPEINFO_Uuid());
  109. }
  110. if (existingRules.find(SceneData::LodRule::TYPEINFO_Uuid()) == existingRules.end())
  111. {
  112. modifiers.push_back(SceneData::LodRule::TYPEINFO_Uuid());
  113. }
  114. if (existingRules.find(SceneData::MaterialRule::TYPEINFO_Uuid()) == existingRules.end())
  115. {
  116. modifiers.push_back(SceneData::MaterialRule::TYPEINFO_Uuid());
  117. }
  118. if (existingRules.find(SceneData::SkinMeshAdvancedRule::TYPEINFO_Uuid()) == existingRules.end())
  119. {
  120. modifiers.push_back(SceneData::SkinMeshAdvancedRule::TYPEINFO_Uuid());
  121. }
  122. }
  123. else if (target.RTTI_IsTypeOf(DataTypes::ISkeletonGroup::TYPEINFO_Uuid()))
  124. {
  125. const DataTypes::ISkeletonGroup* group = azrtti_cast<const DataTypes::ISkeletonGroup*>(&target);
  126. const Containers::RuleContainer& rules = group->GetRuleContainerConst();
  127. AZStd::unordered_set<AZ::Uuid> existingRules;
  128. const size_t ruleCount = rules.GetRuleCount();
  129. for (size_t i = 0; i < ruleCount; ++i)
  130. {
  131. existingRules.insert(rules.GetRule(i)->RTTI_GetType());
  132. }
  133. }
  134. }
  135. } // namespace SceneData
  136. } // namespace SceneAPI
  137. } // namespace AZ