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