Box2D 2.4.1
A 2D physics engine for games
b2_common.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_COMMON_H
24#define B2_COMMON_H
25
26#include "b2_settings.h"
27
28#include <stddef.h>
29#include <assert.h>
30#include <float.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#define b2_maxFloat FLT_MAX
40#define b2_epsilon FLT_EPSILON
41#define b2_pi 3.14159265359f
42
46
47// Collision
48
51#define b2_maxManifoldPoints 2
52
56#define b2_aabbExtension (0.1f * b2_lengthUnitsPerMeter)
57
61#define b2_aabbMultiplier 4.0f
62
65#define b2_linearSlop (0.005f * b2_lengthUnitsPerMeter)
66
69#define b2_angularSlop (2.0f / 180.0f * b2_pi)
70
74#define b2_polygonRadius (2.0f * b2_linearSlop)
75
77#define b2_maxSubSteps 8
78
79
80// Dynamics
81
83#define b2_maxTOIContacts 32
84
87#define b2_maxLinearCorrection (0.2f * b2_lengthUnitsPerMeter)
88
91#define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi)
92
95#define b2_maxTranslation (2.0f * b2_lengthUnitsPerMeter)
96#define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation)
97
100#define b2_maxRotation (0.5f * b2_pi)
101#define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation)
102
106#define b2_baumgarte 0.2f
107#define b2_toiBaumgarte 0.75f
108
109
110// Sleep
111
113#define b2_timeToSleep 0.5f
114
116#define b2_linearSleepTolerance (0.01f * b2_lengthUnitsPerMeter)
117
119#define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
120
122void b2OpenDump(const char* fileName);
123void b2Dump(const char* string, ...);
124void b2CloseDump();
125
129{
130 int32 major;
131 int32 minor;
132 int32 revision;
133};
134
136extern B2_API b2Version b2_version;
137
138#endif
B2_API b2Version b2_version
Current version.
void b2OpenDump(const char *fileName)
Dump to a file. Only one dump file allowed at a time.
Definition: b2_common.h:129
int32 minor
incremental changes
Definition: b2_common.h:131
int32 revision
bug fixes
Definition: b2_common.h:132
int32 major
significant changes
Definition: b2_common.h:130