3
0

DecalComponentController.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 <AzCore/Component/TransformBus.h>
  11. #include <AzCore/Component/NonUniformScaleBus.h>
  12. #include <AtomLyIntegration/CommonFeatures/Decals/DecalBus.h>
  13. #include <AtomLyIntegration/CommonFeatures/Decals/DecalComponentConfig.h>
  14. #include <Atom/Feature/Decals/DecalFeatureProcessorInterface.h>
  15. namespace AZ
  16. {
  17. namespace Render
  18. {
  19. class DecalComponentController final
  20. : private TransformNotificationBus::Handler
  21. , public DecalRequestBus::Handler
  22. {
  23. public:
  24. friend class EditorDecalComponent;
  25. AZ_TYPE_INFO(AZ::Render::DecalComponentController, "{95834373-5D39-4C96-B0B2-F06E6B40B5BB}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  30. DecalComponentController() = default;
  31. DecalComponentController(const DecalComponentConfig& config);
  32. void Activate(EntityId entityId);
  33. void Deactivate();
  34. void SetConfiguration(const DecalComponentConfig& config);
  35. const DecalComponentConfig& GetConfiguration() const;
  36. private:
  37. AZ_DISABLE_COPY(DecalComponentController);
  38. // TransformNotificationBus::Handler overrides ...
  39. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  40. // DecalRequestBus::Handler overrides ...
  41. float GetAttenuationAngle() const override;
  42. void SetAttenuationAngle(float intensity) override;
  43. const AZ::Vector3& GetDecalColor() const override;
  44. void SetDecalColor(const AZ::Vector3& color) override;
  45. float GetDecalColorFactor() const override;
  46. void SetDecalColorFactor(float colorFactor) override;
  47. float GetOpacity() const override;
  48. void SetOpacity(float opacity) override;
  49. float GetNormalMapOpacity() const override;
  50. void SetNormalMapOpacity(float opacity) override;
  51. uint8_t GetSortKey() const override;
  52. void SetSortKey(uint8_t sortKeys) override;
  53. void SetMaterialAssetId(Data::AssetId) override;
  54. Data::AssetId GetMaterialAssetId() const override;
  55. void ConfigurationChanged();
  56. void AttenuationAngleChanged();
  57. void DecalColorChanged();
  58. void DecalColorFactorChanged();
  59. void OpacityChanged();
  60. void NormalMapOpacityChanged();
  61. void SortKeyChanged();
  62. void MaterialChanged();
  63. void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale);
  64. DecalComponentConfig m_configuration;
  65. DecalFeatureProcessorInterface* m_featureProcessor = nullptr;
  66. DecalFeatureProcessorInterface::DecalHandle m_handle;
  67. EntityId m_entityId;
  68. AZ::Vector3 m_cachedNonUniformScale = AZ::Vector3::CreateOne();
  69. AZ::NonUniformScaleChangedEvent::Handler m_nonUniformScaleChangedHandler
  70. {
  71. [&](const AZ::Vector3& nonUniformScale) { HandleNonUniformScaleChange(nonUniformScale); }
  72. };
  73. };
  74. } // namespace Render
  75. } // AZ namespace