DescriptorListCombinerComponent.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <LmbrCentral/Dependency/DependencyMonitor.h>
  11. #include <SurfaceData/SurfaceDataTagEnumeratorRequestBus.h>
  12. #include <SurfaceData/SurfaceDataTagEnumeratorRequestBus.h>
  13. #include <Vegetation/Ebuses/DescriptorListCombinerRequestBus.h>
  14. #include <Vegetation/Ebuses/DescriptorProviderRequestBus.h>
  15. namespace LmbrCentral
  16. {
  17. template<typename, typename>
  18. class EditorWrappedComponentBase;
  19. }
  20. namespace Vegetation
  21. {
  22. class DescriptorListCombinerConfig
  23. : public AZ::ComponentConfig
  24. {
  25. public:
  26. AZ_CLASS_ALLOCATOR(DescriptorListCombinerConfig, AZ::SystemAllocator);
  27. AZ_RTTI(DescriptorListCombinerConfig, "{A62E9C87-093C-4534-AB48-DEF8EC80C190}", AZ::ComponentConfig);
  28. static void Reflect(AZ::ReflectContext* context);
  29. AZStd::vector<AZ::EntityId> m_descriptorProviders;
  30. size_t GetNumDescriptors() const;
  31. AZ::EntityId GetDescriptorEntityId(int index) const;
  32. void RemoveDescriptorEntityId(int index);
  33. void SetDescriptorEntityId(int index, AZ::EntityId entityId);
  34. void AddDescriptorEntityId(AZ::EntityId entityId);
  35. };
  36. inline constexpr AZ::TypeId DescriptorListCombinerComponentTypeId{ "{1A1267EA-8A29-42AE-A385-BB0E60899EEF}" };
  37. /**
  38. * Retrieve a list of descriptors from multiple providers
  39. */
  40. class DescriptorListCombinerComponent
  41. : public AZ::Component
  42. , private DescriptorProviderRequestBus::Handler
  43. , private DescriptorListCombinerRequestBus::Handler
  44. , private SurfaceData::SurfaceDataTagEnumeratorRequestBus::Handler
  45. {
  46. public:
  47. template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
  48. AZ_COMPONENT(DescriptorListCombinerComponent, DescriptorListCombinerComponentTypeId);
  49. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  50. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  51. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  52. static void Reflect(AZ::ReflectContext* context);
  53. DescriptorListCombinerComponent(const DescriptorListCombinerConfig& configuration);
  54. DescriptorListCombinerComponent() = default;
  55. ~DescriptorListCombinerComponent() = default;
  56. //////////////////////////////////////////////////////////////////////////
  57. // AZ::Component interface implementation
  58. void Activate() override;
  59. void Deactivate() override;
  60. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  61. bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
  62. //////////////////////////////////////////////////////////////////////////
  63. // DescriptorProviderRequestBus
  64. void GetDescriptors(DescriptorPtrVec& descriptors) const override;
  65. //////////////////////////////////////////////////////////////////////////
  66. // SurfaceData::SurfaceDataTagEnumeratorRequestBus
  67. void GetInclusionSurfaceTags(SurfaceData::SurfaceTagVector& tags, bool& includeAll) const override;
  68. void GetExclusionSurfaceTags(SurfaceData::SurfaceTagVector& tags) const override;
  69. protected:
  70. //////////////////////////////////////////////////////////////////////////
  71. // DescriptorListCombinerRequestBus
  72. size_t GetNumDescriptors() const override;
  73. AZ::EntityId GetDescriptorEntityId(int index) const override;
  74. void RemoveDescriptorEntityId(int index) override;
  75. void SetDescriptorEntityId(int index, AZ::EntityId entityId) override;
  76. void AddDescriptorEntityId(AZ::EntityId entityId) override;
  77. private:
  78. DescriptorListCombinerConfig m_configuration;
  79. LmbrCentral::DependencyMonitor m_dependencyMonitor;
  80. void SetupDependencies();
  81. };
  82. }