3
0

PostFxLayerComponentController.h 3.8 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 <AtomLyIntegration/CommonFeatures/PostProcess/PostFxLayerComponentConfig.h>
  11. #include <AtomLyIntegration/CommonFeatures/PostProcess/PostFxLayerBus.h>
  12. #include <AzCore/Component/TickBus.h>
  13. #include <Atom/Feature/PostProcess/PostProcessFeatureProcessorInterface.h>
  14. #include <LmbrCentral/Scripting/TagComponentBus.h>
  15. #include <AzFramework/Components/CameraBus.h>
  16. namespace AZ
  17. {
  18. namespace Render
  19. {
  20. class PostFxLayerComponentController final
  21. : public PostFxLayerRequestBus::Handler
  22. , public LmbrCentral::TagGlobalNotificationBus::MultiHandler
  23. , public Camera::CameraNotificationBus::Handler
  24. , public TickBus::Handler
  25. {
  26. public:
  27. friend class EditorPostFxLayerComponent;
  28. AZ_TYPE_INFO(AZ::Render::PostFxLayerComponentController, "{A3285A02-944B-4339-95B1-15E0F410BD1D}");
  29. static void Reflect(AZ::ReflectContext* context);
  30. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  31. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  32. PostFxLayerComponentController() = default;
  33. PostFxLayerComponentController(const PostFxLayerComponentConfig& config);
  34. void Activate(EntityId entityId);
  35. void Deactivate();
  36. void SetConfiguration(const PostFxLayerComponentConfig& config);
  37. const PostFxLayerComponentConfig& GetConfiguration() const;
  38. // Called whenever a tag is added to this component via Editor or Script
  39. void RebuildCameraEntitiesList();
  40. // TagGlobalNotificationBus::MultiHandler overrides
  41. void OnEntityTagAdded(const AZ::EntityId& entityId) override;
  42. void OnEntityTagRemoved(const AZ::EntityId& entityId) override;
  43. // CameraNotificationBus::Handler overrides
  44. void OnCameraAdded(const AZ::EntityId& cameraId) override;
  45. void OnCameraRemoved(const AZ::EntityId& cameraId) override;
  46. // Auto-gen function override declarations (functions definitions in .cpp)...
  47. #include <Atom/Feature/ParamMacros/StartParamFunctionsOverride.inl>
  48. #include <Atom/Feature/PostProcess/PostProcessParams.inl>
  49. #include <Atom/Feature/ParamMacros/EndParams.inl>
  50. private:
  51. AZ_DISABLE_COPY(PostFxLayerComponentController);
  52. void OnConfigChanged();
  53. void OnTick(float deltaTime, ScriptTimePoint time) override;
  54. // Connects to all camera tags listed in this component
  55. void BusConnectToTags();
  56. const AZStd::unordered_set<AZ::EntityId>& GetCameraEntityList() const;
  57. bool IsEditorView(const AZ::RPI::ViewPtr view);
  58. bool HasTags(const AZ::EntityId& entityId, const AZStd::vector<AZStd::string>& tags) const;
  59. // list of entities containing tags set in this component's property.
  60. AZStd::unordered_set<AZ::EntityId> m_taggedCameraEntities;
  61. // a list of cameras tracked by this component. This is used if no camera tags are specified.
  62. AZStd::unordered_set<AZ::EntityId> m_cameraEntities;
  63. // a list of camera views in the scene. This is used to test if a view is an editor view.
  64. AZStd::unordered_set<AZ::RPI::View*> m_allCameraViews;
  65. PostProcessFeatureProcessorInterface* m_featureProcessorInterface = nullptr;
  66. PostProcessSettingsInterface* m_postProcessInterface = nullptr;
  67. PostFxLayerComponentConfig m_configuration;
  68. EntityId m_entityId;
  69. };
  70. }
  71. }