DescriptorWeightSelectorComponent.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 <Vegetation/Ebuses/DescriptorSelectorRequestBus.h>
  11. #include <Vegetation/Ebuses/DescriptorWeightSelectorRequestBus.h>
  12. #include <GradientSignal/GradientSampler.h>
  13. #include <LmbrCentral/Dependency/DependencyMonitor.h>
  14. namespace LmbrCentral
  15. {
  16. template<typename, typename>
  17. class EditorWrappedComponentBase;
  18. }
  19. namespace Vegetation
  20. {
  21. class DescriptorWeightSelectorConfig
  22. : public AZ::ComponentConfig
  23. {
  24. public:
  25. AZ_CLASS_ALLOCATOR(DescriptorWeightSelectorConfig, AZ::SystemAllocator);
  26. AZ_RTTI(DescriptorWeightSelectorConfig, "{382116B1-5843-42A3-915B-A3BFC3CFAB78}", AZ::ComponentConfig);
  27. static void Reflect(AZ::ReflectContext* context);
  28. SortBehavior m_sortBehavior = SortBehavior::Unsorted;
  29. GradientSignal::GradientSampler m_gradientSampler;
  30. };
  31. inline constexpr AZ::TypeId DescriptorWeightSelectorComponentTypeId{ "{D282AF06-4D89-4353-B4E5-92E5389C8EF7}" };
  32. /**
  33. * Default placement logic for vegetation in an area
  34. */
  35. class DescriptorWeightSelectorComponent
  36. : public AZ::Component
  37. , private DescriptorSelectorRequestBus::Handler
  38. , private DescriptorWeightSelectorRequestBus::Handler
  39. {
  40. public:
  41. template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
  42. AZ_COMPONENT(DescriptorWeightSelectorComponent, DescriptorWeightSelectorComponentTypeId);
  43. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  44. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  45. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  46. static void Reflect(AZ::ReflectContext* context);
  47. DescriptorWeightSelectorComponent(const DescriptorWeightSelectorConfig& configuration);
  48. DescriptorWeightSelectorComponent() = default;
  49. ~DescriptorWeightSelectorComponent() = default;
  50. //////////////////////////////////////////////////////////////////////////
  51. // AZ::Component interface implementation
  52. void Activate() override;
  53. void Deactivate() override;
  54. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  55. bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
  56. //////////////////////////////////////////////////////////////////////////
  57. // DescriptorSelectorRequestBus
  58. void SelectDescriptors(const DescriptorSelectorParams& params, DescriptorPtrVec& descriptors) const override;
  59. protected:
  60. //////////////////////////////////////////////////////////////////////////
  61. // DescriptorWeightSelectorRequestBus
  62. SortBehavior GetSortBehavior() const override;
  63. void SetSortBehavior(SortBehavior behavior) override;
  64. GradientSignal::GradientSampler& GetGradientSampler() override;
  65. private:
  66. DescriptorWeightSelectorConfig m_configuration;
  67. LmbrCentral::DependencyMonitor m_dependencyMonitor;
  68. };
  69. }