b3ContactSolverInfo.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef B3_CONTACT_SOLVER_INFO
  14. #define B3_CONTACT_SOLVER_INFO
  15. #include "Bullet3Common/b3Scalar.h"
  16. enum b3SolverMode
  17. {
  18. B3_SOLVER_RANDMIZE_ORDER = 1,
  19. B3_SOLVER_FRICTION_SEPARATE = 2,
  20. B3_SOLVER_USE_WARMSTARTING = 4,
  21. B3_SOLVER_USE_2_FRICTION_DIRECTIONS = 16,
  22. B3_SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32,
  23. B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64,
  24. B3_SOLVER_CACHE_FRIENDLY = 128,
  25. B3_SOLVER_SIMD = 256,
  26. B3_SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512,
  27. B3_SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024
  28. };
  29. struct b3ContactSolverInfoData
  30. {
  31. b3Scalar m_tau;
  32. b3Scalar m_damping;//global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'.
  33. b3Scalar m_friction;
  34. b3Scalar m_timeStep;
  35. b3Scalar m_restitution;
  36. int m_numIterations;
  37. b3Scalar m_maxErrorReduction;
  38. b3Scalar m_sor;
  39. b3Scalar m_erp;//used as Baumgarte factor
  40. b3Scalar m_erp2;//used in Split Impulse
  41. b3Scalar m_globalCfm;//constraint force mixing
  42. int m_splitImpulse;
  43. b3Scalar m_splitImpulsePenetrationThreshold;
  44. b3Scalar m_splitImpulseTurnErp;
  45. b3Scalar m_linearSlop;
  46. b3Scalar m_warmstartingFactor;
  47. int m_solverMode;
  48. int m_restingContactRestitutionThreshold;
  49. int m_minimumSolverBatchSize;
  50. b3Scalar m_maxGyroscopicForce;
  51. b3Scalar m_singleAxisRollingFrictionThreshold;
  52. };
  53. struct b3ContactSolverInfo : public b3ContactSolverInfoData
  54. {
  55. inline b3ContactSolverInfo()
  56. {
  57. m_tau = b3Scalar(0.6);
  58. m_damping = b3Scalar(1.0);
  59. m_friction = b3Scalar(0.3);
  60. m_timeStep = b3Scalar(1.f/60.f);
  61. m_restitution = b3Scalar(0.);
  62. m_maxErrorReduction = b3Scalar(20.);
  63. m_numIterations = 10;
  64. m_erp = b3Scalar(0.2);
  65. m_erp2 = b3Scalar(0.8);
  66. m_globalCfm = b3Scalar(0.);
  67. m_sor = b3Scalar(1.);
  68. m_splitImpulse = true;
  69. m_splitImpulsePenetrationThreshold = -.04f;
  70. m_splitImpulseTurnErp = 0.1f;
  71. m_linearSlop = b3Scalar(0.0);
  72. m_warmstartingFactor=b3Scalar(0.85);
  73. //m_solverMode = B3_SOLVER_USE_WARMSTARTING | B3_SOLVER_SIMD | B3_SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION|B3_SOLVER_USE_2_FRICTION_DIRECTIONS|B3_SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;// | B3_SOLVER_RANDMIZE_ORDER;
  74. m_solverMode = B3_SOLVER_USE_WARMSTARTING | B3_SOLVER_SIMD;// | B3_SOLVER_RANDMIZE_ORDER;
  75. m_restingContactRestitutionThreshold = 2;//unused as of 2.81
  76. m_minimumSolverBatchSize = 128; //try to combine islands until the amount of constraints reaches this limit
  77. m_maxGyroscopicForce = 100.f; ///only used to clamp forces for bodies that have their B3_ENABLE_GYROPSCOPIC_FORCE flag set (using b3RigidBody::setFlag)
  78. m_singleAxisRollingFrictionThreshold = 1e30f;///if the velocity is above this threshold, it will use a single constraint row (axis), otherwise 3 rows.
  79. }
  80. };
  81. ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
  82. struct b3ContactSolverInfoDoubleData
  83. {
  84. double m_tau;
  85. double m_damping;//global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'.
  86. double m_friction;
  87. double m_timeStep;
  88. double m_restitution;
  89. double m_maxErrorReduction;
  90. double m_sor;
  91. double m_erp;//used as Baumgarte factor
  92. double m_erp2;//used in Split Impulse
  93. double m_globalCfm;//constraint force mixing
  94. double m_splitImpulsePenetrationThreshold;
  95. double m_splitImpulseTurnErp;
  96. double m_linearSlop;
  97. double m_warmstartingFactor;
  98. double m_maxGyroscopicForce;
  99. double m_singleAxisRollingFrictionThreshold;
  100. int m_numIterations;
  101. int m_solverMode;
  102. int m_restingContactRestitutionThreshold;
  103. int m_minimumSolverBatchSize;
  104. int m_splitImpulse;
  105. char m_padding[4];
  106. };
  107. ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
  108. struct b3ContactSolverInfoFloatData
  109. {
  110. float m_tau;
  111. float m_damping;//global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'.
  112. float m_friction;
  113. float m_timeStep;
  114. float m_restitution;
  115. float m_maxErrorReduction;
  116. float m_sor;
  117. float m_erp;//used as Baumgarte factor
  118. float m_erp2;//used in Split Impulse
  119. float m_globalCfm;//constraint force mixing
  120. float m_splitImpulsePenetrationThreshold;
  121. float m_splitImpulseTurnErp;
  122. float m_linearSlop;
  123. float m_warmstartingFactor;
  124. float m_maxGyroscopicForce;
  125. float m_singleAxisRollingFrictionThreshold;
  126. int m_numIterations;
  127. int m_solverMode;
  128. int m_restingContactRestitutionThreshold;
  129. int m_minimumSolverBatchSize;
  130. int m_splitImpulse;
  131. char m_padding[4];
  132. };
  133. #endif //B3_CONTACT_SOLVER_INFO