3
0

RagdollJointHandler.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <Editor/PropertyWidgets/PropertyWidgetAllocator.h>
  9. #include <Editor/PropertyWidgets/RagdollJointHandler.h>
  10. #include <Editor/JointSelectionDialog.h>
  11. #include <Editor/SkeletonSortFilterProxyModel.h>
  12. namespace EMotionFX
  13. {
  14. AZ_CLASS_ALLOCATOR_IMPL(RagdollMultiJointHandler, PropertyWidgetAllocator)
  15. AZ::u32 RagdollMultiJointHandler::GetHandlerName() const
  16. {
  17. return AZ_CRC("ActorRagdollJoints", 0xed1cae00);
  18. }
  19. QWidget* RagdollMultiJointHandler::CreateGUI(QWidget* parent)
  20. {
  21. ActorJointPicker* picker = aznew ActorJointPicker(false /*singleSelection*/, "Select Ragdoll Joints", "Select the ragdoll joints to be simulated", parent);
  22. picker->AddDefaultFilter(SkeletonSortFilterProxyModel::s_simulationCategory, SkeletonSortFilterProxyModel::s_ragdollNodesFilterName);
  23. connect(picker, &ActorJointPicker::SelectionChanged, this, [picker]()
  24. {
  25. AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
  26. &AzToolsFramework::PropertyEditorGUIMessages::Bus::Events::RequestWrite, picker);
  27. });
  28. return picker;
  29. }
  30. void RagdollMultiJointHandler::ConsumeAttribute(ActorJointPicker* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
  31. {
  32. if (attrib == AZ::Edit::Attributes::ReadOnly)
  33. {
  34. bool value;
  35. if (attrValue->Read<bool>(value))
  36. {
  37. GUI->setEnabled(!value);
  38. }
  39. }
  40. }
  41. void RagdollMultiJointHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, ActorJointPicker* GUI, property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
  42. {
  43. instance = GUI->GetJointNames();
  44. }
  45. bool RagdollMultiJointHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, ActorJointPicker* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
  46. {
  47. QSignalBlocker signalBlocker(GUI);
  48. GUI->SetJointNames(instance);
  49. return true;
  50. }
  51. } // namespace EMotionFX