Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.4 KiB

  1. //========== Copyright (c) Valve Corporation. All Rights Reserved. ============
  2. #ifndef MDLOBJECTS_CLOTHPROXYMESH_HDR
  3. #define MDLOBJECTS_CLOTHPROXYMESH_HDR
  4. class CVClothProxyMesh
  5. {
  6. public:
  7. CVClothProxyMesh()
  8. {
  9. m_meshName = "";
  10. m_meshFile = "";
  11. m_bMapUsingUVs = false;
  12. m_bBackSolveJoints = false;
  13. m_flBackSolveInfluenceThreshold = 0.05f;
  14. m_flEnvelope = 1000;
  15. m_flCollapseTinyEdges = 0.001f;
  16. m_bFlexClothBorders = false;
  17. //m_bEnableVolumetricSolve = false;
  18. }
  19. bool IsSharedMeshProcessing() const
  20. {
  21. return m_bMapUsingUVs == false
  22. && m_bBackSolveJoints == false
  23. && fabsf( m_flBackSolveInfluenceThreshold - 0.05f ) < 0.00001f
  24. && fabsf( m_flEnvelope - 1000 ) < 0.01f
  25. && fabsf( m_flCollapseTinyEdges - 0.001f ) < 0.000001f
  26. && m_bFlexClothBorders == false
  27. //&& m_bEnableVolumetricSolve == false
  28. ;
  29. }
  30. ~CVClothProxyMesh()
  31. {
  32. }
  33. bool operator==( const CVClothProxyMesh &mesh ) const
  34. {
  35. if ( m_meshName != mesh.m_meshName )
  36. return false;
  37. if ( m_meshFile != mesh.m_meshFile )
  38. return false;
  39. return true;
  40. }
  41. CUtlString m_meshName;
  42. CUtlString m_meshFile; // ProcessFilepath
  43. bool m_bMapUsingUVs;
  44. // Note: m_bBackSolveJoints is implicitly assumed to be true when m_bDriveMeshesWithBacksolvedJointsOnly is true
  45. bool m_bBackSolveJoints;
  46. //bool m_bEnableVolumetricSolve;
  47. bool m_bFlexClothBorders;
  48. float32 m_flBackSolveInfluenceThreshold;
  49. float32 m_flEnvelope;
  50. float32 m_flCollapseTinyEdges;
  51. };
  52. class CVClothProxyMeshOptions
  53. {
  54. public:
  55. CVClothProxyMeshOptions()
  56. {
  57. m_flClothEnableThreshold = 0.05f;
  58. m_bCreateStaticBone = false;
  59. m_nMaxBonesPerVertex = 4;
  60. m_bRemoveUnusedBonesEnabled = false;
  61. m_flMatchProxiesToMeshes = 1.0f;
  62. m_bDriveMeshesWithBacksolvedJointsOnly = true;
  63. m_flReservedFloat = 0;
  64. m_nReservedInt = 0;
  65. m_bReservedBool1 = false;
  66. m_bReservedBool2 = false;
  67. m_bReservedBool3 = false;
  68. m_bReservedBool4 = false;
  69. }
  70. bool IsDefault()const
  71. {
  72. return fabsf( m_flClothEnableThreshold - 0.05f ) < 0.0001f
  73. && m_bCreateStaticBone != false
  74. && m_nMaxBonesPerVertex != 4
  75. && m_bRemoveUnusedBonesEnabled == false
  76. && fabsf( m_flMatchProxiesToMeshes - 1.0f ) < 0.0001f
  77. && m_bDriveMeshesWithBacksolvedJointsOnly == true;
  78. }
  79. float m_flClothEnableThreshold;
  80. bool m_bCreateStaticBone;
  81. int m_nMaxBonesPerVertex;
  82. bool m_bRemoveUnusedBonesEnabled;
  83. // this will ignore cloth attributes in meshes if we back-solve, so that back-solved joints may drive meshes
  84. bool m_bDriveMeshesWithBacksolvedJointsOnly;
  85. float m_flMatchProxiesToMeshes;
  86. float m_flReservedFloat;
  87. int m_nReservedInt;
  88. bool m_bReservedBool1;
  89. bool m_bReservedBool2;
  90. bool m_bReservedBool3;
  91. bool m_bReservedBool4;
  92. };
  93. class CVClothProxyMeshList : public CVClothProxyMeshOptions
  94. {
  95. public:
  96. CVClothProxyMeshList()
  97. {
  98. }
  99. virtual ~CVClothProxyMeshList() {}
  100. CUtlVector< CVClothProxyMesh > m_clothProxyMeshList;
  101. bool IgnoreClothInMeshes() const
  102. {
  103. // Note: m_bBackSolveJoints is implicitly assumed to be true when m_bDriveMeshesWithBacksolvedJointsOnly is true
  104. return m_bDriveMeshesWithBacksolvedJointsOnly;
  105. }
  106. bool IsSharedMeshProcessing()const
  107. {
  108. if ( m_clothProxyMeshList.IsEmpty() )
  109. return true;
  110. if ( !IsDefault() )
  111. return false;
  112. for ( const CVClothProxyMesh &proxy : m_clothProxyMeshList )
  113. {
  114. if ( !proxy.IsSharedMeshProcessing() )
  115. {
  116. return false;
  117. }
  118. }
  119. return true;
  120. }
  121. };
  122. #endif // MDLOBJECTS_CLOTHPROXYMESH_HDR