Chipmunk2D Pro API Reference
6.2.1
Main Page
Related Pages
Modules
Classes
Files
File List
All
Classes
Functions
Variables
Typedefs
Properties
Groups
Pages
Chipmunk
include
chipmunk
chipmunk_types.h
1
#include <stdint.h>
2
#include <float.h>
3
4
#ifdef __APPLE__
5
#include "TargetConditionals.h"
6
#endif
7
8
#if ((TARGET_OS_IPHONE == 1) || (TARGET_OS_MAC == 1)) && (!defined CP_USE_CGPOINTS)
9
#define CP_USE_CGPOINTS 1
10
#endif
11
12
#if CP_USE_CGPOINTS == 1
13
#if TARGET_OS_IPHONE
14
#import <CoreGraphics/CGGeometry.h>
15
#elif TARGET_OS_MAC
16
#include <ApplicationServices/ApplicationServices.h>
17
#endif
18
19
#if defined(__LP64__) && __LP64__
20
#define CP_USE_DOUBLES 1
21
#else
22
#define CP_USE_DOUBLES 0
23
#endif
24
#endif
25
26
#ifndef CP_USE_DOUBLES
27
// use doubles by default for higher precision
28
#define CP_USE_DOUBLES 1
29
#endif
30
34
35
#if CP_USE_DOUBLES
36
37
38
typedef
double
cpFloat
;
39
#define cpfsqrt sqrt
40
#define cpfsin sin
41
#define cpfcos cos
42
#define cpfacos acos
43
#define cpfatan2 atan2
44
#define cpfmod fmod
45
#define cpfexp exp
46
#define cpfpow pow
47
#define cpffloor floor
48
#define cpfceil ceil
49
#define CPFLOAT_MIN DBL_MIN
50
#else
51
typedef
float
cpFloat
;
52
#define cpfsqrt sqrtf
53
#define cpfsin sinf
54
#define cpfcos cosf
55
#define cpfacos acosf
56
#define cpfatan2 atan2f
57
#define cpfmod fmodf
58
#define cpfexp expf
59
#define cpfpow powf
60
#define cpffloor floorf
61
#define cpfceil ceilf
62
#define CPFLOAT_MIN FLT_MIN
63
#endif
64
65
#ifndef INFINITY
66
#ifdef _MSC_VER
67
union
MSVC_EVIL_FLOAT_HACK
68
{
69
unsigned
__int8 Bytes[4];
70
float
Value;
71
};
72
static
union
MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
73
#define INFINITY (INFINITY_HACK.Value)
74
#endif
75
76
#ifdef __GNUC__
77
#define INFINITY (__builtin_inf())
78
#endif
79
80
#ifndef INFINITY
81
#define INFINITY (1e1000)
82
#endif
83
#endif
84
85
#ifndef M_PI
86
#define M_PI 3.14159265358979323846264338327950288
87
#endif
88
89
#ifndef M_E
90
#define M_E 2.71828182845904523536028747135266250
91
#endif
92
93
95
static
inline
cpFloat
cpfmax
(
cpFloat
a,
cpFloat
b)
96
{
97
return
(a > b) ? a : b;
98
}
99
101
static
inline
cpFloat
cpfmin
(
cpFloat
a,
cpFloat
b)
102
{
103
return
(a < b) ? a : b;
104
}
105
107
static
inline
cpFloat
cpfabs
(
cpFloat
f)
108
{
109
return
(f < 0) ? -f : f;
110
}
111
113
static
inline
cpFloat
cpfclamp
(
cpFloat
f,
cpFloat
min,
cpFloat
max)
114
{
115
return
cpfmin
(
cpfmax
(f, min), max);
116
}
117
119
static
inline
cpFloat
cpfclamp01
(
cpFloat
f)
120
{
121
return
cpfmax
(0.0f,
cpfmin
(f, 1.0f));
122
}
123
124
125
127
static
inline
cpFloat
cpflerp
(
cpFloat
f1,
cpFloat
f2,
cpFloat
t)
128
{
129
return
f1*(1.0f - t) + f2*t;
130
}
131
133
static
inline
cpFloat
cpflerpconst
(
cpFloat
f1,
cpFloat
f2,
cpFloat
d)
134
{
135
return
f1 +
cpfclamp
(f2 - f1, -d, d);
136
}
137
139
typedef
uintptr_t
cpHashValue
;
140
143
typedef
uint32_t
cpCollisionID
;
144
145
// Oh C, how we love to define our own boolean types to get compiler compatibility
147
#ifdef CP_BOOL_TYPE
148
typedef
CP_BOOL_TYPE
cpBool
;
149
#else
150
typedef
int
cpBool
;
151
#endif
152
153
#ifndef cpTrue
154
155
#define cpTrue 1
156
#endif
157
158
#ifndef cpFalse
159
160
#define cpFalse 0
161
#endif
162
163
#ifdef CP_DATA_POINTER_TYPE
164
typedef
CP_DATA_POINTER_TYPE
cpDataPointer
;
165
#else
166
167
typedef
void
*
cpDataPointer
;
168
#endif
169
170
#ifdef CP_COLLISION_TYPE_TYPE
171
typedef
CP_COLLISION_TYPE_TYPE
cpCollisionType
;
172
#else
173
174
typedef
uintptr_t
cpCollisionType
;
175
#endif
176
177
#ifdef CP_GROUP_TYPE
178
typedef
CP_GROUP_TYPE
cpGroup
;
179
#else
180
181
typedef
uintptr_t
cpGroup
;
182
#endif
183
184
#ifdef CP_LAYERS_TYPE
185
typedef
CP_LAYERS_TYPE
cpLayers
;
186
#else
187
188
typedef
unsigned
int
cpLayers
;
189
#endif
190
191
#ifdef CP_TIMESTAMP_TYPE
192
typedef
CP_TIMESTAMP_TYPE
cpTimestamp
;
193
#else
194
195
typedef
unsigned
int
cpTimestamp
;
196
#endif
197
198
#ifndef CP_NO_GROUP
199
200
#define CP_NO_GROUP ((cpGroup)0)
201
#endif
202
203
#ifndef CP_ALL_LAYERS
204
205
#define CP_ALL_LAYERS (~(cpLayers)0)
206
#endif
207
208
209
// CGPoints are structurally the same, and allow
210
// easy interoperability with other Cocoa libraries
211
#if CP_USE_CGPOINTS
212
typedef
CGPoint
cpVect
;
213
#else
214
215
216
typedef
struct
cpVect
{
cpFloat
x,y;}
cpVect
;
217
#endif
218
219
typedef
struct
cpMat2x2
{
220
// Row major [[a, b][c d]]
221
cpFloat
a, b, c, d;
222
}
cpMat2x2
;
Generated on Fri Jan 16 2015 15:54:52 for Chipmunk2D Pro API Reference by
1.8.3.1