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