JointLimitRotationManipulators.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/Component/TickBus.h>
  10. #include <AzToolsFramework/Manipulators/RotationManipulators.h>
  11. #include <Editor/Plugins/Ragdoll/PhysicsSetupManipulatorCommandCallback.h>
  12. #include <Editor/Plugins/Ragdoll/PhysicsSetupManipulators.h>
  13. #include <MCore/Source/MCoreCommandManager.h>
  14. namespace EMotionFX
  15. {
  16. enum class JointLimitFrame : AZ::u8
  17. {
  18. Parent,
  19. Child
  20. };
  21. //! Provides functionality for interactively editing character physics joint limit frame orientations in the Animation Editor Viewport.
  22. class JointLimitRotationManipulators
  23. : public PhysicsSetupManipulatorsBase
  24. , private AZ::TickBus::Handler
  25. , private PhysicsSetupManipulatorRequestBus::Handler
  26. {
  27. public:
  28. JointLimitRotationManipulators(JointLimitFrame jointLimitFrame);
  29. void Setup(const PhysicsSetupManipulatorData& physicsSetupManipulatorData) override;
  30. void Refresh() override;
  31. void Teardown() override;
  32. void ResetValues() override;
  33. void InvalidateEditorValues() override;
  34. private:
  35. // AZ::TickBus::Handler overrides ...
  36. void OnTick(float delta, AZ::ScriptTimePoint timePoint) override;
  37. // PhysicsSetupManipulatorRequestBus::Handler overrides ...
  38. void OnUnderlyingPropertiesChanged() override;
  39. void OnManipulatorMoved(const AZ::Quaternion& rotation);
  40. void BeginEditing();
  41. void EndEditing();
  42. AZ::Quaternion& GetLocalOrientation();
  43. const AZ::Quaternion& GetLocalOrientation() const;
  44. AzToolsFramework::RotationManipulators m_rotationManipulators =
  45. AzToolsFramework::RotationManipulators(AZ::Transform::CreateIdentity());
  46. PhysicsSetupManipulatorData m_physicsSetupManipulatorData;
  47. JointLimitFrame m_jointLimitFrame = JointLimitFrame::Parent;
  48. MCore::CommandGroup m_commandGroup;
  49. AZStd::unique_ptr<PhysicsSetupManipulatorCommandCallback> m_adjustJointLimitCallback;
  50. };
  51. void CreateCommandAdjustJointLimit(MCore::CommandGroup& commandGroup, const PhysicsSetupManipulatorData& physicsSetupManipulatorData);
  52. void ExecuteCommandAdjustJointLimit(MCore::CommandGroup& commandGroup, const PhysicsSetupManipulatorData& physicsSetupManipulatorData);
  53. } // namespace EMotionFX