ClothConfiguration.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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/RTTI/RTTI.h>
  10. #include <AzCore/Component/EntityId.h>
  11. #include <AzCore/Math/Vector3.h>
  12. #include <Utils/AssetHelper.h>
  13. namespace AZ
  14. {
  15. class ReflectContext;
  16. }
  17. namespace NvCloth
  18. {
  19. //! Configuration data for Cloth.
  20. struct ClothConfiguration
  21. {
  22. AZ_CLASS_ALLOCATOR(ClothConfiguration, AZ::SystemAllocator);
  23. AZ_TYPE_INFO(ClothConfiguration, "{96E2AF5E-3C98-4872-8F90-F56302A44F2A}");
  24. static void Reflect(AZ::ReflectContext* context);
  25. virtual ~ClothConfiguration() = default;
  26. bool IsUsingWorldBusGravity() const { return !m_useCustomGravity; }
  27. bool IsUsingWindBus() const { return !m_useCustomWindVelocity; }
  28. AZStd::string m_meshNode;
  29. // Mass and Gravity parameters
  30. float m_mass = 1.0f;
  31. bool m_useCustomGravity = false;
  32. AZ::Vector3 m_customGravity = AZ::Vector3(0.0f, 0.0f, -9.81f);
  33. float m_gravityScale = 1.0f;
  34. // Global stiffness frequency
  35. float m_stiffnessFrequency = 10.0f;
  36. // Motion constraints Parameters
  37. float m_motionConstraintsMaxDistance = 10.0f;
  38. float m_motionConstraintsScale = 1.0f;
  39. float m_motionConstraintsBias = 0.0f;
  40. float m_motionConstraintsStiffness = 1.0f;
  41. // Backstop Parameters
  42. float m_backstopRadius = 0.1f;
  43. float m_backstopBackOffset = 0.0f;
  44. float m_backstopFrontOffset = 0.0f;
  45. // Damping parameters
  46. AZ::Vector3 m_damping = AZ::Vector3(0.2f, 0.2f, 0.2f);
  47. AZ::Vector3 m_linearDrag = AZ::Vector3(0.2f, 0.2f, 0.2f);
  48. AZ::Vector3 m_angularDrag = AZ::Vector3(0.2f, 0.2f, 0.2f);
  49. // Inertia parameters
  50. AZ::Vector3 m_linearInteria = AZ::Vector3::CreateOne();
  51. AZ::Vector3 m_angularInteria = AZ::Vector3::CreateOne();
  52. AZ::Vector3 m_centrifugalInertia = AZ::Vector3::CreateOne();
  53. // Wind parameters
  54. bool m_useCustomWindVelocity = true;
  55. AZ::Vector3 m_windVelocity = AZ::Vector3(0.0f, 20.0f, 0.0f);
  56. float m_airDragCoefficient = 0.0f;
  57. float m_airLiftCoefficient = 0.0f;
  58. float m_fluidDensity = 1.0f;
  59. // Collision parameters
  60. float m_collisionFriction = 0.0f;
  61. float m_collisionMassScale = 0.0f;
  62. bool m_continuousCollisionDetection = false;
  63. bool m_collisionAffectsStaticParticles = false;
  64. // Self Collision parameters
  65. float m_selfCollisionDistance = 0.0f;
  66. float m_selfCollisionStiffness = 0.2f;
  67. // Tether Constraints parameters
  68. float m_tetherConstraintStiffness = 1.0f;
  69. float m_tetherConstraintScale = 1.0f;
  70. // Quality parameters
  71. float m_solverFrequency = 300.0f;
  72. uint32_t m_accelerationFilterIterations = 30;
  73. bool m_removeStaticTriangles = true;
  74. bool m_updateNormalsOfStaticParticles = false;
  75. // Fabric phases parameters
  76. float m_horizontalStiffness = 1.0f;
  77. float m_horizontalStiffnessMultiplier = 0.0f;
  78. float m_horizontalCompressionLimit = 0.0f;
  79. float m_horizontalStretchLimit = 0.0f;
  80. float m_verticalStiffness = 1.0f;
  81. float m_verticalStiffnessMultiplier = 0.0f;
  82. float m_verticalCompressionLimit = 0.0f;
  83. float m_verticalStretchLimit = 0.0f;
  84. float m_bendingStiffness = 1.0f;
  85. float m_bendingStiffnessMultiplier = 0.0f;
  86. float m_bendingCompressionLimit = 0.0f;
  87. float m_bendingStretchLimit = 0.0f;
  88. float m_shearingStiffness = 1.0f;
  89. float m_shearingStiffnessMultiplier = 0.0f;
  90. float m_shearingCompressionLimit = 0.0f;
  91. float m_shearingStretchLimit = 0.0f;
  92. private:
  93. // Making private functionality related with the Editor Context reflection,
  94. // it's unnecessary for the clients using ClothConfiguration.
  95. friend class EditorClothComponent;
  96. // Used by data elements in EditorClothComponent edit context.
  97. MeshNodeList m_meshNodeList;
  98. bool m_hasBackstopData = false;
  99. AZ::EntityId m_entityId;
  100. };
  101. } // namespace NvCloth