SkinRule.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <AzCore/RTTI/ReflectContext.h>
  9. #include <AzCore/Memory/SystemAllocator.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzCore/Serialization/EditContext.h>
  12. #include <SceneAPI/SceneData/Rules/SkinRule.h>
  13. namespace AZ
  14. {
  15. namespace SceneAPI
  16. {
  17. namespace SceneData
  18. {
  19. AZ_CLASS_ALLOCATOR_IMPL(SkinRule, AZ::SystemAllocator)
  20. SkinRule::SkinRule()
  21. {
  22. DataTypes::SkinRuleSettings defaultSettings = DataTypes::GetDefaultSkinRuleSettings();
  23. m_maxWeightsPerVertex = defaultSettings.m_maxInfluencesPerVertex;
  24. m_weightThreshold = defaultSettings.m_weightThreshold;
  25. }
  26. AZ::u32 SkinRule::GetMaxWeightsPerVertex() const
  27. {
  28. return m_maxWeightsPerVertex;
  29. }
  30. float SkinRule::GetWeightThreshold() const
  31. {
  32. return m_weightThreshold;
  33. }
  34. void SkinRule::Reflect(AZ::ReflectContext* context)
  35. {
  36. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  37. if (!serializeContext)
  38. {
  39. return;
  40. }
  41. serializeContext->Class<ISkinRule, AZ::SceneAPI::DataTypes::IRule>()->Version(1);
  42. serializeContext->Class<SkinRule, ISkinRule>()->Version(2)
  43. ->Field("maxWeightsPerVertex", &SkinRule::m_maxWeightsPerVertex)
  44. ->Field("weightThreshold", &SkinRule::m_weightThreshold);
  45. AZ::EditContext* editContext = serializeContext->GetEditContext();
  46. if (editContext)
  47. {
  48. editContext->Class<SkinRule>("Skin", "")
  49. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  50. ->Attribute("AutoExpand", true)
  51. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  52. ->DataElement(AZ::Edit::UIHandlers::Default, &SkinRule::m_maxWeightsPerVertex, "Max weights per vertex", "The maximum number of joints that can influence a single vertex.")
  53. ->Attribute(AZ::Edit::Attributes::Min, 1)
  54. ->Attribute(AZ::Edit::Attributes::Max, 32)
  55. ->DataElement(AZ::Edit::UIHandlers::Default, &SkinRule::m_weightThreshold, "Weight threshold", "Weight value less than this will be ignored during import.")
  56. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  57. ->Attribute(AZ::Edit::Attributes::Max, 0.01f)
  58. ->Attribute(AZ::Edit::Attributes::Step, 0.0001f)
  59. ->Attribute(AZ::Edit::Attributes::Decimals, 6)
  60. ->Attribute(AZ::Edit::Attributes::DisplayDecimals, 6);
  61. }
  62. }
  63. } // Rule
  64. } // Pipeline
  65. } // EMotionFX