EditorDecalComponent.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <AzFramework/Entity/EntityDebugDisplayBus.h>
  10. #include <AzFramework/Visibility/BoundsBus.h>
  11. #include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
  12. #include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
  13. #include <AtomLyIntegration/CommonFeatures/Decals/DecalConstants.h>
  14. #include <Decals/DecalComponent.h>
  15. namespace AZ
  16. {
  17. namespace Render
  18. {
  19. class EditorDecalComponent final
  20. : public EditorRenderComponentAdapter<DecalComponentController, DecalComponent, DecalComponentConfig>
  21. , private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
  22. , private AzFramework::EntityDebugDisplayEventBus::Handler
  23. , public AzFramework::BoundsRequestBus::Handler
  24. {
  25. public:
  26. using BaseClass = EditorRenderComponentAdapter<DecalComponentController, DecalComponent, DecalComponentConfig>;
  27. AZ_EDITOR_COMPONENT(AZ::Render::EditorDecalComponent, EditorDecalComponentTypeId, BaseClass);
  28. static void Reflect(AZ::ReflectContext* context);
  29. EditorDecalComponent() = default;
  30. EditorDecalComponent(const DecalComponentConfig& config);
  31. void Activate() override;
  32. void Deactivate() override;
  33. // EntityDebugDisplayEventBus overrides ...
  34. void DisplayEntityViewport(
  35. const AzFramework::ViewportInfo& viewportInfo,
  36. AzFramework::DebugDisplayRequests& debugDisplay) override;
  37. // EditorComponentSelectionRequestsBus overrides ...
  38. bool SupportsEditorRayIntersect() override;
  39. // Returns true if the given ray hits the decal
  40. bool EditorSelectionIntersectRayViewport(const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& raySrc, const AZ::Vector3& rayDir, float& distance) override;
  41. // Returns a coarse AABB that surrounds the decal
  42. AZ::Aabb GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo) override;
  43. // BoundsRequestBus overrides ...
  44. AZ::Aabb GetWorldBounds() const override;
  45. AZ::Aabb GetLocalBounds() const override;
  46. private:
  47. // Returns the component transform which includes uniform-scale, rotation and translation
  48. AZ::Transform GetWorldTransform() const;
  49. // Returns the full transform, including both the uniform scale and non-uniform scale along with rotation and translation
  50. AZ::Matrix3x4 GetWorldTransformWithNonUniformScale() const;
  51. //! EditorRenderComponentAdapter overrides ...
  52. u32 OnConfigurationChanged() override;
  53. };
  54. } // namespace Render
  55. } // namespace AZ