The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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
5.1KB

  1. /*
  2. * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. * Permission is granted to anyone to use this software for any purpose,
  8. * including commercial applications, and to alter it and redistribute it
  9. * freely, subject to the following restrictions:
  10. * 1. The origin of this software must not be misrepresented; you must not
  11. * claim that you wrote the original software. If you use this software
  12. * in a product, an acknowledgment in the product documentation would be
  13. * appreciated but is not required.
  14. * 2. Altered source versions must be plainly marked as such, and must not be
  15. * misrepresented as being the original software.
  16. * 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef B2_SETTINGS_H
  19. #define B2_SETTINGS_H
  20. #include <cassert>
  21. #include <cmath>
  22. #define B2_NOT_USED(x) ((void)(x))
  23. #define b2Assert(A) assert(A)
  24. typedef float float32;
  25. typedef double float64;
  26. #define b2_maxFloat FLT_MAX
  27. #define b2_epsilon FLT_EPSILON
  28. #define b2_pi 3.14159265359f
  29. /// @file
  30. /// Global tuning constants based on meters-kilograms-seconds (MKS) units.
  31. ///
  32. // Collision
  33. /// The maximum number of contact points between two convex shapes. Do
  34. /// not change this value.
  35. #define b2_maxManifoldPoints 2
  36. /// The maximum number of vertices on a convex polygon. You cannot increase
  37. /// this too much because b2BlockAllocator has a maximum object size.
  38. #define b2_maxPolygonVertices 8
  39. /// This is used to fatten AABBs in the dynamic tree. This allows proxies
  40. /// to move by a small amount without triggering a tree adjustment.
  41. /// This is in meters.
  42. #define b2_aabbExtension 0.1f
  43. /// This is used to fatten AABBs in the dynamic tree. This is used to predict
  44. /// the future position based on the current displacement.
  45. /// This is a dimensionless multiplier.
  46. #define b2_aabbMultiplier 2.0f
  47. /// A small length used as a collision and constraint tolerance. Usually it is
  48. /// chosen to be numerically significant, but visually insignificant.
  49. #define b2_linearSlop 0.005f
  50. /// A small angle used as a collision and constraint tolerance. Usually it is
  51. /// chosen to be numerically significant, but visually insignificant.
  52. #define b2_angularSlop (2.0f / 180.0f * b2_pi)
  53. /// The radius of the polygon/edge shape skin. This should not be modified. Making
  54. /// this smaller means polygons will have an insufficient buffer for continuous collision.
  55. /// Making it larger may create artifacts for vertex collision.
  56. #define b2_polygonRadius (2.0f * b2_linearSlop)
  57. /// Maximum number of sub-steps per contact in continuous physics simulation.
  58. #define b2_maxSubSteps 8
  59. // Dynamics
  60. /// Maximum number of contacts to be handled to solve a TOI impact.
  61. #define b2_maxTOIContacts 32
  62. /// A velocity threshold for elastic collisions. Any collision with a relative linear
  63. /// velocity below this threshold will be treated as inelastic.
  64. #define b2_velocityThreshold 1.0f
  65. /// The maximum linear position correction used when solving constraints. This helps to
  66. /// prevent overshoot.
  67. #define b2_maxLinearCorrection 0.2f
  68. /// The maximum angular position correction used when solving constraints. This helps to
  69. /// prevent overshoot.
  70. #define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi)
  71. /// The maximum linear velocity of a body. This limit is very large and is used
  72. /// to prevent numerical problems. You shouldn't need to adjust this.
  73. #define b2_maxTranslation 2.0f
  74. #define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation)
  75. /// The maximum angular velocity of a body. This limit is very large and is used
  76. /// to prevent numerical problems. You shouldn't need to adjust this.
  77. #define b2_maxRotation (0.5f * b2_pi)
  78. #define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation)
  79. /// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so
  80. /// that overlap is removed in one time step. However using values close to 1 often lead
  81. /// to overshoot.
  82. #define b2_baumgarte 0.2f
  83. #define b2_toiBaugarte 0.75f
  84. // Sleep
  85. /// The time that a body must be still before it will go to sleep.
  86. #define b2_timeToSleep 0.5f
  87. /// A body cannot sleep if its linear velocity is above this tolerance.
  88. #define b2_linearSleepTolerance 0.01f
  89. /// A body cannot sleep if its angular velocity is above this tolerance.
  90. #define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
  91. // Memory Allocation
  92. /// Implement this function to use your own memory allocator.
  93. void* b2Alloc(juce::int32 size);
  94. /// If you implement b2Alloc, you should also implement this function.
  95. void b2Free(void* mem);
  96. /// Logging function.
  97. void b2Log(const char* string, ...);
  98. /// Version numbering scheme.
  99. /// See http://en.wikipedia.org/wiki/Software_versioning
  100. struct b2Version
  101. {
  102. juce::int32 major; ///< significant changes
  103. juce::int32 minor; ///< incremental changes
  104. juce::int32 revision; ///< bug fixes
  105. };
  106. /// Current version.
  107. extern b2Version b2_version;
  108. #endif