EditorTerrainMacroMaterialComponentMode.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <AzToolsFramework/ComponentMode/EditorBaseComponentMode.h>
  10. #include <AzToolsFramework/Manipulators/PaintBrushManipulator.h>
  11. #include <AzToolsFramework/PaintBrush/PaintBrushSubModeCluster.h>
  12. #include <AzToolsFramework/Undo/UndoSystem.h>
  13. #include <AzToolsFramework/ViewportUi/ViewportUiRequestBus.h>
  14. #include <TerrainRenderer/TerrainMacroMaterialBus.h>
  15. namespace Terrain
  16. {
  17. class PaintBrushUndoBuffer;
  18. class ImageTileBuffer;
  19. class EditorTerrainMacroMaterialComponentMode
  20. : public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode
  21. , private TerrainMacroColorModificationNotificationBus::Handler
  22. {
  23. public:
  24. AZ_TYPE_INFO(EditorTerrainMacroMaterialComponentMode, "{24B7280F-2344-4BB4-A0BC-4ADAD6715EE4}");
  25. AZ_CLASS_ALLOCATOR(EditorTerrainMacroMaterialComponentMode, AZ::SystemAllocator)
  26. EditorTerrainMacroMaterialComponentMode(const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType);
  27. ~EditorTerrainMacroMaterialComponentMode() override;
  28. // EditorBaseComponentMode
  29. void Refresh() override;
  30. AZStd::vector<AzToolsFramework::ActionOverride> PopulateActionsImpl() override;
  31. bool HandleMouseInteraction(const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction) override;
  32. AZStd::string GetComponentModeName() const override;
  33. AZ::Uuid GetComponentModeType() const override;
  34. protected:
  35. // TerrainMacroColorModificationNotificationBus overrides...
  36. void OnTerrainMacroColorBrushStrokeBegin() override;
  37. void OnTerrainMacroColorBrushStrokeEnd(
  38. AZStd::shared_ptr<ImageTileBuffer> changedDataBuffer, const AZ::Aabb& dirtyRegion) override;
  39. void BeginUndoBatch();
  40. void EndUndoBatch();
  41. private:
  42. //! The core paintbrush manipulator and painting logic.
  43. AZStd::shared_ptr<AzToolsFramework::PaintBrushManipulator> m_brushManipulator;
  44. //! The undo information for the in-progress painting brush stroke.
  45. AzToolsFramework::UndoSystem::URSequencePoint* m_undoBatch = nullptr;
  46. PaintBrushUndoBuffer* m_paintBrushUndoBuffer = nullptr;
  47. //! The paint brush cluster that manages switching between paint/smooth/eyedropper modes
  48. AzToolsFramework::PaintBrushSubModeCluster m_subModeCluster;
  49. };
  50. } // namespace Terrain