PhysicsSetupManipulators.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/Math/Transform.h>
  10. #include <Editor/Plugins/Ragdoll/PhysicsSetupManipulatorBus.h>
  11. namespace Physics
  12. {
  13. class CharacterColliderNodeConfiguration;
  14. } // namespace Physics
  15. namespace AzPhysics
  16. {
  17. struct JointConfiguration;
  18. } // namespace AzPhysics
  19. namespace EMotionFX
  20. {
  21. class Actor;
  22. class Node;
  23. class ObjectEditor;
  24. class ColliderContainerWidget;
  25. class RagdollJointLimitWidget;
  26. struct PhysicsSetupManipulatorData
  27. {
  28. bool HasColliders() const;
  29. bool HasCapsuleCollider() const;
  30. bool HasJointLimit() const;
  31. AZ::Transform GetJointParentFrameWorld() const;
  32. AZ::Transform m_nodeWorldTransform = AZ::Transform::CreateIdentity();
  33. AZ::Transform m_parentWorldTransform = AZ::Transform::CreateIdentity();
  34. Physics::CharacterColliderNodeConfiguration* m_colliderNodeConfiguration = nullptr;
  35. AzPhysics::JointConfiguration* m_jointConfiguration = nullptr;
  36. Actor* m_actor = nullptr;
  37. Node* m_node = nullptr;
  38. ColliderContainerWidget* m_collidersWidget = nullptr;
  39. RagdollJointLimitWidget* m_jointLimitWidget = nullptr;
  40. bool m_valid = false;
  41. };
  42. //! Base class for various manipulator modes, e.g. collider translation, collider orientation, etc.
  43. class PhysicsSetupManipulatorsBase
  44. {
  45. public:
  46. virtual ~PhysicsSetupManipulatorsBase() = default;
  47. //! Called when the manipulator mode is entered to initialize the mode.
  48. virtual void Setup(const PhysicsSetupManipulatorData& physicsSetupManipulatorData) = 0;
  49. //! Called when the manipulator mode needs to refresh its values.
  50. virtual void Refresh() = 0;
  51. //! Called when the manipulator mode exits to perform cleanup.
  52. virtual void Teardown() = 0;
  53. //! Called when reset hot key is pressed.
  54. //! Should reset values in the manipulator mode to sensible defaults.
  55. virtual void ResetValues() = 0;
  56. //! Causes values in associated property editor to refresh.
  57. virtual void InvalidateEditorValues()
  58. {
  59. }
  60. void SetViewportId(AZ::s32 viewportId);
  61. protected:
  62. AZ::s32 m_viewportId;
  63. };
  64. //! Used when null mode is selected.
  65. class PhysicsSetupManipulatorsNull
  66. : public PhysicsSetupManipulatorsBase
  67. {
  68. public:
  69. void Setup([[maybe_unused]] const PhysicsSetupManipulatorData& physicsSetupManipulatorData) override {};
  70. void Refresh() override {};
  71. void Teardown() override {};
  72. void ResetValues() override {};
  73. };
  74. } // namespace EMotionFX