LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
b2Settings.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 * Copyright (c) 2013 Google, Inc.
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 * 2. Altered source versions must be plainly marked as such, and must not be
16 * misrepresented as being the original software.
17 * 3. This notice may not be removed or altered from any source distribution.
18 */
19 
20 #ifndef B2_SETTINGS_H
21 #define B2_SETTINGS_H
22 
23 #include <stddef.h>
24 #include <assert.h>
25 #include <float.h>
26 
27 #define B2_NOT_USED(x) ((void)(x))
28 #if DEBUG && !defined(NDEBUG)
29 #define b2Assert(A) assert(A)
30 #define B2_ASSERT_ENABLED 1
31 #else
32 #define b2Assert(A)
33 #define B2_ASSERT_ENABLED 0
34 #endif
35 
36 // Statement which is compiled out when DEBUG isn't defined.
37 #if DEBUG
38 #define B2_DEBUG_STATEMENT(A) A
39 #else
40 #define B2_DEBUG_STATEMENT(A)
41 #endif // DEBUG
42 
43 // Calculate the size of a static array.
44 #define B2_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
45 
46 typedef signed char int8;
47 typedef signed short int16;
48 typedef signed int int32;
49 typedef unsigned char uint8;
50 typedef unsigned short uint16;
51 typedef unsigned int uint32;
52 typedef float float32;
53 typedef double float64;
54 
55 #ifdef WIN32
56 typedef __int64 int64;
57 typedef unsigned __int64 uint64;
58 #else // !WIN32
59 typedef long long int64;
60 typedef unsigned long long uint64;
61 #endif
62 
63 #define b2_maxFloat FLT_MAX
64 #define b2_epsilon FLT_EPSILON
65 #define b2_pi 3.14159265359f
66 
67 #if !defined(b2Inline)
68 #if defined(__GNUC__)
69 #define b2Inline __attribute__((always_inline))
70 #else
71 #define b2Inline inline
72 #endif // defined(__GNUC__)
73 #endif // !defined(b2Inline)
74 
75 // We expand the API so that other languages (e.g. Java) can call into
76 // our C++ more easily. Only set if when the flag is not externally defined.
77 #if !defined(LIQUIDFUN_EXTERNAL_LANGUAGE_API)
78 #if SWIG || LIQUIDFUN_UNIT_TESTS
79 #define LIQUIDFUN_EXTERNAL_LANGUAGE_API 1
80 #else
81 #define LIQUIDFUN_EXTERNAL_LANGUAGE_API 0
82 #endif
83 #endif
84 
88 
89 // Collision
90 
93 #define b2_maxManifoldPoints 2
94 
97 #define b2_maxPolygonVertices 8
98 
102 #define b2_aabbExtension 0.1f
103 
107 #define b2_aabbMultiplier 2.0f
108 
111 #define b2_linearSlop 0.005f
112 
115 #define b2_angularSlop (2.0f / 180.0f * b2_pi)
116 
120 #define b2_polygonRadius (2.0f * b2_linearSlop)
121 
123 #define b2_maxSubSteps 8
124 
125 
126 // Dynamics
127 
129 #define b2_maxTOIContacts 32
130 
133 #define b2_velocityThreshold 1.0f
134 
137 #define b2_maxLinearCorrection 0.2f
138 
141 #define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi)
142 
145 #define b2_maxTranslation 2.0f
146 #define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation)
147 
150 #define b2_maxRotation (0.5f * b2_pi)
151 #define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation)
152 
156 #define b2_baumgarte 0.2f
157 #define b2_toiBaugarte 0.75f
158 
159 
160 // Particle
161 
163 #if !defined(B2_USE_16_BIT_PARTICLE_INDICES) && defined(LIQUIDFUN_SIMD_NEON)
164 #define B2_USE_16_BIT_PARTICLE_INDICES
165 #endif
166 
168 #define b2_invalidParticleIndex (-1)
169 
170 #ifdef B2_USE_16_BIT_PARTICLE_INDICES
171 #define b2_maxParticleIndex 0x7FFF
172 #else
173 #define b2_maxParticleIndex 0x7FFFFFFF
174 #endif
175 
177 #define b2_particleStride 0.75f
178 
180 #define b2_minParticleWeight 1.0f
181 
183 #define b2_maxParticlePressure 0.25f
184 
186 #define b2_maxParticleForce 0.5f
187 
190 #define b2_maxTriadDistance 2
191 #define b2_maxTriadDistanceSquared (b2_maxTriadDistance * b2_maxTriadDistance)
192 
194 #define b2_minParticleSystemBufferCapacity 256
195 
197 #define b2_barrierCollisionTime 2.5f
198 
199 // Sleep
200 
202 #define b2_timeToSleep 0.5f
203 
205 #define b2_linearSleepTolerance 0.01f
206 
208 #define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
209 
210 // Memory Allocation
211 
213 void* b2Alloc(int32 size);
214 
216 void b2Free(void* mem);
217 
219 typedef void* (*b2AllocFunction)(int32 size, void* callbackData);
221 typedef void (*b2FreeFunction)(void* mem, void* callbackData);
222 
227 void b2SetAllocFreeCallbacks(b2AllocFunction allocCallback,
228  b2FreeFunction freeCallback,
229  void* callbackData);
230 
234 void b2SetNumAllocs(const int32 numAllocs);
235 
237 int32 b2GetNumAllocs();
238 
240 void b2Log(const char* string, ...);
241 
244 struct b2Version
245 {
246  int32 major;
247  int32 minor;
248  int32 revision;
249 };
250 
253 extern b2Version b2_version;
254 
256 extern const b2Version b2_liquidFunVersion;
265 extern const char *b2_liquidFunVersionString;
266 
267 #endif
void b2Log(const char *string,...)
Logging function.
Definition: b2Settings.cpp:116
void(* b2FreeFunction)(void *mem, void *callbackData)
Use this function to override b2Free() without recompiling this library.
Definition: b2Settings.h:221
int32 minor
incremental changes
Definition: b2Settings.h:247
void b2Free(void *mem)
If you implement b2Alloc, you should also implement this function.
Definition: b2Settings.cpp:99
void * b2Alloc(int32 size)
Implement this function to use your own memory allocator.
Definition: b2Settings.cpp:93
void *(* b2AllocFunction)(int32 size, void *callbackData)
Use this function to override b2Alloc() without recompiling this library.
Definition: b2Settings.h:219
b2Version b2_version
Definition: b2Settings.cpp:25
Definition: b2Settings.h:244
const char * b2_liquidFunVersionString
Definition: b2Settings.cpp:41
int32 major
significant changes
Definition: b2Settings.h:246
int32 b2GetNumAllocs()
Get number of calls to b2Alloc minus number of calls to b2Free.
Definition: b2Settings.cpp:110
const b2Version b2_liquidFunVersion
Global variable is used to identify the version of LiquidFun.
Definition: b2Settings.cpp:36
void b2SetNumAllocs(const int32 numAllocs)
Definition: b2Settings.cpp:105
void b2SetAllocFreeCallbacks(b2AllocFunction allocCallback, b2FreeFunction freeCallback, void *callbackData)
Definition: b2Settings.cpp:72
int32 revision
bug fixes
Definition: b2Settings.h:248