3
0

WhiteBoxPolygonScaleModifier.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "Viewport/WhiteBoxModifierUtil.h"
  10. #include <AzCore/Component/ComponentBus.h>
  11. #include <AzToolsFramework/Manipulators/LinearManipulator.h>
  12. #include <WhiteBox/WhiteBoxToolApi.h>
  13. namespace WhiteBox
  14. {
  15. //! Provides manipulators for scaling a face on a white box mesh.
  16. class PolygonScaleModifier
  17. {
  18. public:
  19. AZ_CLASS_ALLOCATOR_DECL
  20. PolygonScaleModifier(
  21. const Api::PolygonHandle& polygonHandle, const AZ::EntityComponentIdPair& entityComponentIdPair);
  22. ~PolygonScaleModifier();
  23. void Refresh();
  24. Api::PolygonHandle GetPolygonHandle() const;
  25. void SetPolygonHandle(const Api::PolygonHandle& polygonHandle);
  26. private:
  27. void CreateManipulators();
  28. void DestroyManipulators();
  29. void OnMouseMove(const AzToolsFramework::LinearManipulator::Action& action);
  30. AZ::EntityComponentIdPair
  31. m_entityComponentIdPair; //!< The entity and component id this modifier is associated with.
  32. Api::PolygonHandle m_polygonHandle; //!< The polygon handle this modifier is responsible for.
  33. AZStd::vector<AZStd::shared_ptr<AzToolsFramework::LinearManipulator>>
  34. m_scaleManipulators; //!< Manipulators to handle corners of face to scale.
  35. AZStd::vector<AZ::Vector3>
  36. m_initialVertexPositions; //!< The initial position of all vertices when scaling begins.
  37. AZ::Vector3 m_midPoint; //!< The midpoint of the polygon when scaling first begins.
  38. AppendStage m_appendStage = AppendStage::None; //!< Are we in the process of appending a new polygon.
  39. float m_startingDistance =
  40. 0.0f; //!< The distance a manipulator is from the midpoint when an interaction first begins.
  41. float m_offsetWhenExtruded = 0.0f; //!< How far the manipulator has moved before an extrusion starts.
  42. };
  43. inline Api::PolygonHandle PolygonScaleModifier::GetPolygonHandle() const
  44. {
  45. return m_polygonHandle;
  46. }
  47. } // namespace WhiteBox