/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include #include #include #include #include #include #include #include #include #include namespace AZ { class EntityComponentIdPair; } namespace PhysX { //! Class responsible for managing component mode for joints. class JointsComponentMode final : public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode { public: AZ_CLASS_ALLOCATOR_DECL; JointsComponentMode(const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType); ~JointsComponentMode(); // EditorBaseComponentMode ... void Refresh() override; AZStd::vector PopulateActionsImpl() override; AZStd::vector PopulateViewportUiImpl() override; private: //! Used to identify the group of component modes. enum class ClusterGroups { Group1 = 0, //!< Position Joint, Rotate Joint, Snap Position, Snap Rotation. Group2, //!< Damping, Stiffness, Twist Limits, Swing Limits. Group3, //!< Max Force, Max Torque. GroupCount }; //! Used to track the cluster that a specific button is apart of. struct ButtonData { AzToolsFramework::ViewportUi::ClusterId m_clusterId; AzToolsFramework::ViewportUi::ButtonId m_buttonId; }; void SetCurrentMode(JointsComponentModeCommon::SubComponentModes::ModeType newMode, ButtonData& buttonData); bool HandleMouseInteraction(const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction) override; void SetupSubModes(const AZ::EntityComponentIdPair& entityComponentIdPair); void ResetCurrentMode(); void TeardownSubModes(); AzToolsFramework::ViewportUi::ClusterId GetClusterId(ClusterGroups group); AZStd::fixed_vector(ClusterGroups::GroupCount)> m_modeSelectionClusterIds; //!< List of the cluster ui's. The sub modes are split across 3 groups and each group is it's own cluster ui. AZStd::unordered_map m_buttonData; //!< Mapping of joint component modes to the button data. AZStd::fixed_vector::Handler, static_cast(ClusterGroups::GroupCount)> m_modeSelectionHandlers; //!< Input handlers for each cluster UI. ButtonData m_activeButton; //!< The current highlighted button data. JointsComponentModeCommon::SubComponentModes::ModeType m_subMode = JointsComponentModeCommon::SubComponentModes::ModeType::Translation; //!< The current component mode that is active. AZStd::unordered_map> m_subModes; //!< The logic handlers for each component mode. }; }