Box2D  2.4.0
A 2D physics engine for games
b2_settings.h
Go to the documentation of this file.
1 // MIT License
2 
3 // Copyright (c) 2019 Erin Catto
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef B2_SETTINGS_H
24 #define B2_SETTINGS_H
25 
26 #include <cstddef>
27 #include <cassert>
28 #include <cfloat>
29 
30 #include "b2_api.h"
31 
32 #if !defined(NDEBUG)
33  #define b2DEBUG
34 #endif
35 
36 #define B2_NOT_USED(x) ((void)(x))
37 #define b2Assert(A) assert(A)
38 
39 typedef signed char int8;
40 typedef signed short int16;
41 typedef signed int int32;
42 typedef unsigned char uint8;
43 typedef unsigned short uint16;
44 typedef unsigned int uint32;
45 
46 #define b2_maxFloat FLT_MAX
47 #define b2_epsilon FLT_EPSILON
48 #define b2_pi 3.14159265359f
49 
53 
54 // Collision
55 
58 #define b2_maxManifoldPoints 2
59 
62 #define b2_maxPolygonVertices 8
63 
67 #define b2_aabbExtension 0.1f
68 
72 #define b2_aabbMultiplier 4.0f
73 
76 #define b2_linearSlop 0.005f
77 
80 #define b2_angularSlop (2.0f / 180.0f * b2_pi)
81 
85 #define b2_polygonRadius (2.0f * b2_linearSlop)
86 
88 #define b2_maxSubSteps 8
89 
90 
91 // Dynamics
92 
94 #define b2_maxTOIContacts 32
95 
98 #define b2_velocityThreshold 1.0f
99 
102 #define b2_maxLinearCorrection 0.2f
103 
106 #define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi)
107 
110 #define b2_maxTranslation 2.0f
111 #define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation)
112 
115 #define b2_maxRotation (0.5f * b2_pi)
116 #define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation)
117 
121 #define b2_baumgarte 0.2f
122 #define b2_toiBaumgarte 0.75f
123 
124 
125 // Sleep
126 
128 #define b2_timeToSleep 0.5f
129 
131 #define b2_linearSleepTolerance 0.01f
132 
134 #define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
135 
136 // Memory Allocation
137 
139 B2_API void* b2Alloc(int32 size);
140 
142 B2_API void b2Free(void* mem);
143 
145 B2_API void b2Log(const char* string, ...);
146 
148 B2_API void b2OpenDump(const char* fileName);
149 B2_API void b2Dump(const char* string, ...);
150 B2_API void b2CloseDump();
151 
154 struct B2_API b2Version
155 {
156  int32 major;
157  int32 minor;
158  int32 revision;
159 };
160 
162 extern B2_API b2Version b2_version;
163 
164 #endif
b2Version::minor
int32 minor
incremental changes
Definition: b2_settings.h:157
b2Alloc
B2_API void * b2Alloc(int32 size)
Implement this function to use your own memory allocator.
b2Log
B2_API void b2Log(const char *string,...)
Logging function.
b2_version
B2_API b2Version b2_version
Current version.
b2Version::major
int32 major
significant changes
Definition: b2_settings.h:156
b2Free
B2_API void b2Free(void *mem)
If you implement b2Alloc, you should also implement this function.
b2Version
Definition: b2_settings.h:155
b2OpenDump
B2_API void b2OpenDump(const char *fileName)
Dump to a file. Only one dump file allowed at a time.
b2Version::revision
int32 revision
bug fixes
Definition: b2_settings.h:158