EditorReflectionProbeComponent.h 3.7 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/std/parallel/atomic.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  12. #include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
  13. #include <ReflectionProbe/ReflectionProbeComponent.h>
  14. #include <ReflectionProbe/ReflectionProbeComponentConstants.h>
  15. #include <CubeMapCapture/EditorCubeMapRenderer.h>
  16. #include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
  17. #include <AtomLyIntegration/CommonFeatures/ReflectionProbe/EditorReflectionProbeBus.h>
  18. namespace AZ
  19. {
  20. namespace Render
  21. {
  22. class EditorReflectionProbeComponent final
  23. : public EditorRenderComponentAdapter<ReflectionProbeComponentController, ReflectionProbeComponent, ReflectionProbeComponentConfig>
  24. , public EditorReflectionProbeBus::Handler
  25. , private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
  26. , private AzFramework::EntityDebugDisplayEventBus::Handler
  27. , private AZ::TickBus::Handler
  28. , private EditorCubeMapRenderer
  29. {
  30. public:
  31. using BaseClass = EditorRenderComponentAdapter<ReflectionProbeComponentController, ReflectionProbeComponent, ReflectionProbeComponentConfig>;
  32. AZ_EDITOR_COMPONENT(AZ::Render::EditorReflectionProbeComponent, EditorReflectionProbeComponentTypeId, BaseClass);
  33. static void Reflect(AZ::ReflectContext* context);
  34. EditorReflectionProbeComponent() = default;
  35. EditorReflectionProbeComponent(const ReflectionProbeComponentConfig& config);
  36. // AZ::Component overrides
  37. void Activate() override;
  38. void Deactivate() override;
  39. // AzFramework::EntityDebugDisplayEventBus::Handler overrides
  40. void DisplayEntityViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
  41. private:
  42. // AZ::TickBus overrides
  43. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  44. // validation
  45. AZ::Outcome<void, AZStd::string> OnUseBakedCubemapValidate(void* newValue, const AZ::Uuid& valueType);
  46. // change notifications
  47. AZ::u32 OnUseBakedCubemapChanged();
  48. AZ::u32 OnAuthoredCubemapChanged();
  49. AZ::u32 OnBakeExposureChanged();
  50. // retrieves visibility for baked or authored cubemap controls
  51. AZ::u32 GetBakedCubemapVisibilitySetting();
  52. AZ::u32 GetAuthoredCubemapVisibilitySetting();
  53. // initiate the reflection probe cubemap generation, returns the refresh value for the ChangeNotify UIElement attribute
  54. AZ::u32 BakeReflectionProbe() override;
  55. // EditorComponentSelectionRequestsBus overrides
  56. AZ::Aabb GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo) override;
  57. bool SupportsEditorRayIntersect() override;
  58. // UI settings
  59. // the user can select between a baked cubemap or an authored cubemap asset
  60. bool m_useBakedCubemap = true;
  61. CubeMapSpecularQualityLevel m_bakedCubeMapQualityLevel = CubeMapSpecularQualityLevel::Medium;
  62. AZStd::string m_bakedCubeMapRelativePath;
  63. Data::Asset<RPI::StreamingImageAsset> m_authoredCubeMapAsset;
  64. float m_bakeExposure = 0.0f;
  65. // handler for the inner extents being updated
  66. AZ::Event<bool>::Handler m_innerExtentsChangedHandler;
  67. };
  68. } // namespace Render
  69. } // namespace AZ