SlopeAlignmentModifierComponent.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/ModifierRequestBus.h>
  11. #include <Vegetation/Ebuses/SlopeAlignmentModifierRequestBus.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 SlopeAlignmentModifierConfig
  22. : public AZ::ComponentConfig
  23. {
  24. public:
  25. AZ_CLASS_ALLOCATOR(SlopeAlignmentModifierConfig, AZ::SystemAllocator);
  26. AZ_RTTI(SlopeAlignmentModifierConfig, "{73BA7B92-1061-4DDB-AA5B-A0D87303CBC8}", AZ::ComponentConfig);
  27. static void Reflect(AZ::ReflectContext* context);
  28. bool m_allowOverrides = false;
  29. float m_rangeMin = 1.0f;
  30. float m_rangeMax = 1.0f;
  31. GradientSignal::GradientSampler m_gradientSampler;
  32. };
  33. inline constexpr AZ::TypeId SlopeAlignmentModifierComponentTypeId{ "{08831F9F-E720-4FBD-9CC5-0EF09212B0A0}" };
  34. /**
  35. * Component implementing VegetationModifierRequestBus that alignsto slope
  36. */
  37. class SlopeAlignmentModifierComponent
  38. : public AZ::Component
  39. , public ModifierRequestBus::Handler
  40. , private SlopeAlignmentModifierRequestBus::Handler
  41. {
  42. public:
  43. template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
  44. AZ_COMPONENT(SlopeAlignmentModifierComponent, SlopeAlignmentModifierComponentTypeId);
  45. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  46. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  47. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  48. static void Reflect(AZ::ReflectContext* context);
  49. SlopeAlignmentModifierComponent(const SlopeAlignmentModifierConfig& configuration);
  50. SlopeAlignmentModifierComponent() = default;
  51. ~SlopeAlignmentModifierComponent() = default;
  52. //////////////////////////////////////////////////////////////////////////
  53. // AZ::Component interface implementation
  54. void Activate() override;
  55. void Deactivate() override;
  56. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  57. bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
  58. //////////////////////////////////////////////////////////////////////////
  59. // VegetationModifierRequestBus
  60. void Execute(InstanceData& instanceData) const override;
  61. protected:
  62. //////////////////////////////////////////////////////////////////////////
  63. // SlopeAlignmentModifierRequestBus
  64. bool GetAllowOverrides() const override;
  65. void SetAllowOverrides(bool value) override;
  66. float GetRangeMin() const override;
  67. void SetRangeMin(float rangeMin) override;
  68. float GetRangeMax() const override;
  69. void SetRangeMax(float rangeMax) override;
  70. GradientSignal::GradientSampler& GetGradientSampler() override;
  71. private:
  72. SlopeAlignmentModifierConfig m_configuration;
  73. LmbrCentral::DependencyMonitor m_dependencyMonitor;
  74. };
  75. }