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.

151 lines
5.3KB

  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 signed char int8;
  25. typedef signed short int16;
  26. typedef signed int int32;
  27. typedef unsigned char uint8;
  28. typedef unsigned short uint16;
  29. typedef unsigned int uint32;
  30. typedef float float32;
  31. typedef double float64;
  32. #define b2_maxFloat FLT_MAX
  33. #define b2_epsilon FLT_EPSILON
  34. #define b2_pi 3.14159265359f
  35. /// @file
  36. /// Global tuning constants based on meters-kilograms-seconds (MKS) units.
  37. ///
  38. // Collision
  39. /// The maximum number of contact points between two convex shapes. Do
  40. /// not change this value.
  41. #define b2_maxManifoldPoints 2
  42. /// The maximum number of vertices on a convex polygon. You cannot increase
  43. /// this too much because b2BlockAllocator has a maximum object size.
  44. #define b2_maxPolygonVertices 8
  45. /// This is used to fatten AABBs in the dynamic tree. This allows proxies
  46. /// to move by a small amount without triggering a tree adjustment.
  47. /// This is in meters.
  48. #define b2_aabbExtension 0.1f
  49. /// This is used to fatten AABBs in the dynamic tree. This is used to predict
  50. /// the future position based on the current displacement.
  51. /// This is a dimensionless multiplier.
  52. #define b2_aabbMultiplier 2.0f
  53. /// A small length used as a collision and constraint tolerance. Usually it is
  54. /// chosen to be numerically significant, but visually insignificant.
  55. #define b2_linearSlop 0.005f
  56. /// A small angle used as a collision and constraint tolerance. Usually it is
  57. /// chosen to be numerically significant, but visually insignificant.
  58. #define b2_angularSlop (2.0f / 180.0f * b2_pi)
  59. /// The radius of the polygon/edge shape skin. This should not be modified. Making
  60. /// this smaller means polygons will have an insufficient buffer for continuous collision.
  61. /// Making it larger may create artifacts for vertex collision.
  62. #define b2_polygonRadius (2.0f * b2_linearSlop)
  63. /// Maximum number of sub-steps per contact in continuous physics simulation.
  64. #define b2_maxSubSteps 8
  65. // Dynamics
  66. /// Maximum number of contacts to be handled to solve a TOI impact.
  67. #define b2_maxTOIContacts 32
  68. /// A velocity threshold for elastic collisions. Any collision with a relative linear
  69. /// velocity below this threshold will be treated as inelastic.
  70. #define b2_velocityThreshold 1.0f
  71. /// The maximum linear position correction used when solving constraints. This helps to
  72. /// prevent overshoot.
  73. #define b2_maxLinearCorrection 0.2f
  74. /// The maximum angular position correction used when solving constraints. This helps to
  75. /// prevent overshoot.
  76. #define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi)
  77. /// The maximum linear velocity of a body. This limit is very large and is used
  78. /// to prevent numerical problems. You shouldn't need to adjust this.
  79. #define b2_maxTranslation 2.0f
  80. #define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation)
  81. /// The maximum angular velocity of a body. This limit is very large and is used
  82. /// to prevent numerical problems. You shouldn't need to adjust this.
  83. #define b2_maxRotation (0.5f * b2_pi)
  84. #define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation)
  85. /// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so
  86. /// that overlap is removed in one time step. However using values close to 1 often lead
  87. /// to overshoot.
  88. #define b2_baumgarte 0.2f
  89. #define b2_toiBaugarte 0.75f
  90. // Sleep
  91. /// The time that a body must be still before it will go to sleep.
  92. #define b2_timeToSleep 0.5f
  93. /// A body cannot sleep if its linear velocity is above this tolerance.
  94. #define b2_linearSleepTolerance 0.01f
  95. /// A body cannot sleep if its angular velocity is above this tolerance.
  96. #define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
  97. // Memory Allocation
  98. /// Implement this function to use your own memory allocator.
  99. void* b2Alloc(int32 size);
  100. /// If you implement b2Alloc, you should also implement this function.
  101. void b2Free(void* mem);
  102. /// Logging function.
  103. void b2Log(const char* string, ...);
  104. /// Version numbering scheme.
  105. /// See http://en.wikipedia.org/wiki/Software_versioning
  106. struct b2Version
  107. {
  108. int32 major; ///< significant changes
  109. int32 minor; ///< incremental changes
  110. int32 revision; ///< bug fixes
  111. };
  112. /// Current version.
  113. extern b2Version b2_version;
  114. #endif