DllMain.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #if !defined(AZ_MONOLITHIC_BUILD)
  9. #include <AzCore/Component/Component.h>
  10. #include <AzCore/Component/ComponentApplicationBus.h>
  11. #include <AzCore/std/containers/vector.h>
  12. #include <AzCore/Module/Environment.h>
  13. #include <SceneAPI/SceneBuilder/SceneImportRequestHandler.h>
  14. #include <SceneAPI/SceneBuilder/SceneImporter.h>
  15. #include <SceneAPI/SceneBuilder/Importers/AssImpBitangentStreamImporter.h>
  16. #include <SceneAPI/SceneBuilder/Importers/AssImpColorStreamImporter.h>
  17. #include <SceneAPI/SceneBuilder/Importers/AssImpCustomPropertyImporter.h>
  18. #include <SceneAPI/SceneBuilder/Importers/AssImpMaterialImporter.h>
  19. #include <SceneAPI/SceneBuilder/Importers/AssImpMeshImporter.h>
  20. #include <SceneAPI/SceneBuilder/Importers/AssImpTangentStreamImporter.h>
  21. #include <SceneAPI/SceneBuilder/Importers/AssImpTransformImporter.h>
  22. #include <SceneAPI/SceneBuilder/Importers/AssImpUvMapImporter.h>
  23. #include <SceneAPI/SceneBuilder/Importers/AssImpSkinImporter.h>
  24. #include <SceneAPI/SceneBuilder/Importers/AssImpSkinWeightsImporter.h>
  25. #include <SceneAPI/SceneBuilder/Importers/AssImpBoneImporter.h>
  26. #include <SceneAPI/SceneBuilder/Importers/AssImpAnimationImporter.h>
  27. #include <SceneAPI/SceneBuilder/Importers/AssImpBlendShapeImporter.h>
  28. namespace AZ
  29. {
  30. namespace SceneAPI
  31. {
  32. namespace SceneBuilder
  33. {
  34. static AZStd::vector<AZ::ComponentDescriptor*> g_componentDescriptors;
  35. void Reflect(AZ::SerializeContext* /*context*/)
  36. {
  37. // Descriptor registration is done in Reflect instead of Initialize because the ResourceCompilerScene initializes the libraries before
  38. // there's an application.
  39. using namespace AZ::SceneAPI;
  40. using namespace AZ::SceneAPI::SceneBuilder;
  41. if (g_componentDescriptors.empty())
  42. {
  43. // Global importer and behavior
  44. g_componentDescriptors.push_back(SceneBuilder::SceneImporter::CreateDescriptor());
  45. g_componentDescriptors.push_back(SceneImportRequestHandler::CreateDescriptor());
  46. // Node and attribute importers
  47. g_componentDescriptors.push_back(AssImpBitangentStreamImporter::CreateDescriptor());
  48. g_componentDescriptors.push_back(AssImpColorStreamImporter::CreateDescriptor());
  49. g_componentDescriptors.push_back(AssImpMaterialImporter::CreateDescriptor());
  50. g_componentDescriptors.push_back(AssImpMeshImporter::CreateDescriptor());
  51. g_componentDescriptors.push_back(AssImpTangentStreamImporter::CreateDescriptor());
  52. g_componentDescriptors.push_back(AssImpTransformImporter::CreateDescriptor());
  53. g_componentDescriptors.push_back(AssImpUvMapImporter::CreateDescriptor());
  54. g_componentDescriptors.push_back(AssImpSkinImporter::CreateDescriptor());
  55. g_componentDescriptors.push_back(AssImpSkinWeightsImporter::CreateDescriptor());
  56. g_componentDescriptors.push_back(AssImpBoneImporter::CreateDescriptor());
  57. g_componentDescriptors.push_back(AssImpAnimationImporter::CreateDescriptor());
  58. g_componentDescriptors.push_back(AssImpBlendShapeImporter::CreateDescriptor());
  59. g_componentDescriptors.push_back(AssImpCustomPropertyImporter::CreateDescriptor());
  60. for (AZ::ComponentDescriptor* descriptor : g_componentDescriptors)
  61. {
  62. AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Handler::RegisterComponentDescriptor, descriptor);
  63. }
  64. }
  65. }
  66. void ReflectBehavior([[maybe_unused]] AZ::BehaviorContext* context)
  67. {
  68. // stub in until LYN-1284 is done
  69. }
  70. void Activate()
  71. {
  72. }
  73. void Deactivate()
  74. {
  75. }
  76. void Uninitialize()
  77. {
  78. if (!g_componentDescriptors.empty())
  79. {
  80. for (AZ::ComponentDescriptor* descriptor : g_componentDescriptors)
  81. {
  82. descriptor->ReleaseDescriptor();
  83. }
  84. g_componentDescriptors.clear();
  85. g_componentDescriptors.shrink_to_fit();
  86. }
  87. }
  88. } // namespace SceneBuilder
  89. } // namespace SceneAPI
  90. } // namespace AZ
  91. extern "C" AZ_DLL_EXPORT void InitializeDynamicModule()
  92. {
  93. }
  94. extern "C" AZ_DLL_EXPORT void Reflect(AZ::SerializeContext* context)
  95. {
  96. AZ::SceneAPI::SceneBuilder::Reflect(context);
  97. }
  98. extern "C" AZ_DLL_EXPORT void ReflectBehavior(AZ::BehaviorContext* context)
  99. {
  100. AZ::SceneAPI::SceneBuilder::ReflectBehavior(context);
  101. }
  102. extern "C" AZ_DLL_EXPORT void UninitializeDynamicModule()
  103. {
  104. AZ::SceneAPI::SceneBuilder::Uninitialize();
  105. }
  106. #endif // !defined(AZ_MONOLITHIC_BUILD)