EditorCommonSystemComponent.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 <EditorCommonSystemComponent.h>
  9. #include <Material/UseTextureFunctorSourceData.h>
  10. #include <Material/SubsurfaceTransmissionParameterFunctorSourceData.h>
  11. #include <Material/Transform2DFunctorSourceData.h>
  12. #include <Material/ConvertEmissiveUnitFunctorSourceData.h>
  13. #include <Atom/Feature/Utils/EditorLightingPreset.h>
  14. #include <Atom/Feature/Utils/EditorModelPreset.h>
  15. #include <AzCore/Serialization/SerializeContext.h>
  16. #include <AzCore/Serialization/EditContext.h>
  17. #include <AzCore/Serialization/EditContextConstants.inl>
  18. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  19. #include <AzToolsFramework/API/EditorAssetSystemAPI.h>
  20. #include <AzFramework/Application/Application.h>
  21. #include <Atom/RPI.Edit/Material/MaterialFunctorSourceDataRegistration.h>
  22. #include <Atom/RPI.Edit/Material/LuaMaterialFunctorSourceData.h>
  23. namespace AZ
  24. {
  25. namespace Render
  26. {
  27. //! Main system component for the Atom Common Feature Gem's editor/tools module.
  28. void EditorCommonSystemComponent::Reflect(AZ::ReflectContext* context)
  29. {
  30. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  31. {
  32. serialize->Class<EditorCommonSystemComponent, AZ::Component>()
  33. ->Version(1)
  34. ->Attribute(Edit::Attributes::SystemComponentTags, AZStd::vector<Crc32>({ AssetBuilderSDK::ComponentTags::AssetBuilder }))
  35. ;
  36. if (AZ::EditContext* ec = serialize->GetEditContext())
  37. {
  38. ec->Class<EditorCommonSystemComponent>("Common", "Configures editor- and tool-specific functionality for common render features.")
  39. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  40. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  41. ;
  42. }
  43. AZ::Render::UseTextureFunctorSourceData::Reflect(context);
  44. AZ::Render::Transform2DFunctorSourceData::Reflect(context);
  45. AZ::Render::ConvertEmissiveUnitFunctorSourceData::Reflect(context);
  46. AZ::Render::SubsurfaceTransmissionParameterFunctorSourceData::Reflect(context);
  47. AZ::Render::EditorLightingPreset::Reflect(context);
  48. AZ::Render::EditorModelPreset::Reflect(context);
  49. }
  50. }
  51. void EditorCommonSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  52. {
  53. provided.push_back(AZ_CRC_CE("EditorCommonService"));
  54. }
  55. void EditorCommonSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  56. {
  57. incompatible.push_back(AZ_CRC_CE("EditorCommonService"));
  58. }
  59. void EditorCommonSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  60. {
  61. AZ_UNUSED(required);
  62. }
  63. void EditorCommonSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  64. {
  65. AZ_UNUSED(dependent);
  66. }
  67. void EditorCommonSystemComponent::Init()
  68. {
  69. }
  70. void EditorCommonSystemComponent::Activate()
  71. {
  72. RPI::MaterialFunctorSourceDataRegistration* materialFunctorRegistration = RPI::MaterialFunctorSourceDataRegistration::Get();
  73. if (!materialFunctorRegistration)
  74. {
  75. // On some host platforms shader processing is not supported and this interface is not available.
  76. return;
  77. }
  78. materialFunctorRegistration->RegisterMaterialFunctor("UseTexture", azrtti_typeid<UseTextureFunctorSourceData>());
  79. materialFunctorRegistration->RegisterMaterialFunctor("Transform2D", azrtti_typeid<Transform2DFunctorSourceData>());
  80. materialFunctorRegistration->RegisterMaterialFunctor("ConvertEmissiveUnit", azrtti_typeid<ConvertEmissiveUnitFunctorSourceData>());
  81. materialFunctorRegistration->RegisterMaterialFunctor("HandleSubsurfaceScatteringParameters", azrtti_typeid<SubsurfaceTransmissionParameterFunctorSourceData>());
  82. materialFunctorRegistration->RegisterMaterialFunctor("Lua", azrtti_typeid<RPI::LuaMaterialFunctorSourceData>());
  83. }
  84. void EditorCommonSystemComponent::Deactivate()
  85. {
  86. }
  87. } // namespace Render
  88. } // namespace AZ