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