chipmunk 5.3.4.0-x86-mingw32 → 5.3.4.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README +33 -13
- data/Rakefile +20 -7
- data/ext/chipmunk/extconf.rb +55 -12
- data/ext/chipmunk/rb_chipmunk.c +92 -98
- data/ext/chipmunk/rb_chipmunk.h +44 -34
- data/ext/chipmunk/rb_cpArbiter.c +135 -98
- data/ext/chipmunk/rb_cpBB.c +84 -101
- data/ext/chipmunk/rb_cpBody.c +219 -241
- data/ext/chipmunk/rb_cpConstraint.c +173 -185
- data/ext/chipmunk/rb_cpShape.c +347 -251
- data/ext/chipmunk/rb_cpSpace.c +376 -408
- data/ext/chipmunk/rb_cpVect.c +132 -170
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/chipmunk.h +163 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/chipmunk_ffi.h +59 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/chipmunk_private.h +49 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/chipmunk_types.h +151 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/chipmunk_unsafe.h +54 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpConstraint.h +105 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpDampedRotarySpring.h +46 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpDampedSpring.h +53 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpGearJoint.h +41 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpGrooveJoint.h +48 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpPinJoint.h +43 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpPivotJoint.h +42 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpRatchetJoint.h +40 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpRotaryLimitJoint.h +39 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpSimpleMotor.h +37 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/cpSlideJoint.h +44 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/constraints/util.h +134 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpArbiter.h +188 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpArray.h +49 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpBB.h +74 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpBody.h +219 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpCollision.h +28 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpHashSet.h +82 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpPolyShape.h +103 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpShape.h +177 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpSpace.h +206 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpSpaceHash.h +110 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/include/chipmunk/cpVect.h +207 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/chipmunk.c +151 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpConstraint.c +54 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpDampedRotarySpring.c +105 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpDampedSpring.c +115 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpGearJoint.c +113 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpGrooveJoint.c +161 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpPinJoint.c +116 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpPivotJoint.c +114 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpRatchetJoint.c +126 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpRotaryLimitJoint.c +120 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpSimpleMotor.c +97 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/constraints/cpSlideJoint.c +129 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpArbiter.c +280 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpArray.c +143 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpBB.c +47 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpBody.c +192 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpCollision.c +411 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpHashSet.c +253 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpPolyShape.c +240 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpShape.c +405 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpSpace.c +499 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpSpaceComponent.c +279 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpSpaceHash.c +534 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpSpaceQuery.c +246 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpSpaceStep.c +398 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/cpVect.c +71 -0
- data/ext/chipmunk/vendor/chipmunk-5.3.4/src/prime.h +68 -0
- data/lib/1.9/chipmunk.so +0 -0
- data/lib/chipmunk.rb +19 -8
- metadata +84 -42
- data/lib/1.8/chipmunk.so +0 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
/* Copyright (c) 2007 Scott Lembcke
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to deal
|
5
|
+
* in the Software without restriction, including without limitation the rights
|
6
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
* copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
* SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#ifndef CHIPMUNK_HEADER
|
23
|
+
#define CHIPMUNK_HEADER
|
24
|
+
|
25
|
+
#ifdef __cplusplus
|
26
|
+
extern "C" {
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifndef CP_ALLOW_PRIVATE_ACCESS
|
30
|
+
#define CP_ALLOW_PRIVATE_ACCESS 1
|
31
|
+
#endif
|
32
|
+
|
33
|
+
#if CP_ALLOW_PRIVATE_ACCESS == 1
|
34
|
+
#define CP_PRIVATE(symbol) symbol
|
35
|
+
#else
|
36
|
+
#define CP_PRIVATE(symbol) symbol##_private
|
37
|
+
#endif
|
38
|
+
|
39
|
+
void cpMessage(const char *message, const char *condition, const char *file, int line, int isError);
|
40
|
+
#ifdef NDEBUG
|
41
|
+
#define cpAssertWarn(condition, message)
|
42
|
+
#else
|
43
|
+
#define cpAssertWarn(condition, message) if(!(condition)) cpMessage(message, #condition, __FILE__, __LINE__, 0)
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#ifdef NDEBUG
|
47
|
+
#define cpAssert(condition, message)
|
48
|
+
#else
|
49
|
+
#define cpAssert(condition, message) if(!(condition)) cpMessage(message, #condition, __FILE__, __LINE__, 1)
|
50
|
+
#endif
|
51
|
+
|
52
|
+
#include "chipmunk_types.h"
|
53
|
+
|
54
|
+
#ifndef INFINITY
|
55
|
+
#ifdef _MSC_VER
|
56
|
+
union MSVC_EVIL_FLOAT_HACK
|
57
|
+
{
|
58
|
+
unsigned __int8 Bytes[4];
|
59
|
+
float Value;
|
60
|
+
};
|
61
|
+
static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
|
62
|
+
#define INFINITY (INFINITY_HACK.Value)
|
63
|
+
#endif
|
64
|
+
|
65
|
+
#ifdef __GNUC__
|
66
|
+
#define INFINITY (__builtin_inf())
|
67
|
+
#endif
|
68
|
+
|
69
|
+
#ifndef INFINITY
|
70
|
+
#define INFINITY (1e1000)
|
71
|
+
#endif
|
72
|
+
#endif
|
73
|
+
|
74
|
+
// Maximum allocated size for various Chipmunk buffers
|
75
|
+
#define CP_BUFFER_BYTES (32*1024)
|
76
|
+
|
77
|
+
#define cpmalloc malloc
|
78
|
+
#define cpcalloc calloc
|
79
|
+
#define cprealloc realloc
|
80
|
+
#define cpfree free
|
81
|
+
|
82
|
+
#include "cpVect.h"
|
83
|
+
#include "cpBB.h"
|
84
|
+
#include "cpArray.h"
|
85
|
+
#include "cpHashSet.h"
|
86
|
+
#include "cpSpaceHash.h"
|
87
|
+
|
88
|
+
#include "cpBody.h"
|
89
|
+
#include "cpShape.h"
|
90
|
+
#include "cpPolyShape.h"
|
91
|
+
|
92
|
+
#include "cpArbiter.h"
|
93
|
+
#include "cpCollision.h"
|
94
|
+
|
95
|
+
#include "constraints/cpConstraint.h"
|
96
|
+
|
97
|
+
#include "cpSpace.h"
|
98
|
+
|
99
|
+
#define CP_HASH_COEF (3344921057ul)
|
100
|
+
#define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF)
|
101
|
+
|
102
|
+
extern const char *cpVersionString;
|
103
|
+
void cpInitChipmunk(void);
|
104
|
+
|
105
|
+
/**
|
106
|
+
Calculate the moment of inertia for a circle.
|
107
|
+
r1 and r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.
|
108
|
+
*/
|
109
|
+
cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset);
|
110
|
+
|
111
|
+
/**
|
112
|
+
Calculate area of a hollow circle.
|
113
|
+
*/
|
114
|
+
cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2);
|
115
|
+
|
116
|
+
/**
|
117
|
+
Calculate the moment of inertia for a line segment.
|
118
|
+
Beveling radius is not supported.
|
119
|
+
*/
|
120
|
+
cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b);
|
121
|
+
|
122
|
+
/**
|
123
|
+
Calculate the area of a fattened (capsule shaped) line segment.
|
124
|
+
*/
|
125
|
+
cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat r);
|
126
|
+
|
127
|
+
/**
|
128
|
+
Calculate the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex.
|
129
|
+
*/
|
130
|
+
cpFloat cpMomentForPoly(cpFloat m, int numVerts, const cpVect *verts, cpVect offset);
|
131
|
+
|
132
|
+
/**
|
133
|
+
Calculate the signed area of a polygon.
|
134
|
+
*/
|
135
|
+
cpFloat cpAreaForPoly(const int numVerts, const cpVect *verts);
|
136
|
+
|
137
|
+
/**
|
138
|
+
Calculate the natural centroid of a polygon.
|
139
|
+
*/
|
140
|
+
cpVect cpCentroidForPoly(const int numVerts, const cpVect *verts);
|
141
|
+
|
142
|
+
/**
|
143
|
+
Center the polygon on the origin. (Subtracts the centroid of the polygon from each vertex)
|
144
|
+
*/
|
145
|
+
void cpRecenterPoly(const int numVerts, cpVect *verts);
|
146
|
+
|
147
|
+
/**
|
148
|
+
Calculate the moment of inertia for a solid box.
|
149
|
+
*/
|
150
|
+
cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height);
|
151
|
+
|
152
|
+
#ifdef __cplusplus
|
153
|
+
}
|
154
|
+
|
155
|
+
static inline cpVect operator *(const cpVect v, const cpFloat s){return cpvmult(v, s);}
|
156
|
+
static inline cpVect operator +(const cpVect v1, const cpVect v2){return cpvadd(v1, v2);}
|
157
|
+
static inline cpVect operator -(const cpVect v1, const cpVect v2){return cpvsub(v1, v2);}
|
158
|
+
static inline cpBool operator ==(const cpVect v1, const cpVect v2){return cpveql(v1, v2);}
|
159
|
+
static inline cpVect operator -(const cpVect v){return cpvneg(v);}
|
160
|
+
|
161
|
+
#endif
|
162
|
+
|
163
|
+
#endif
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// Create non static inlined copies of Chipmunk functions, useful for working with dynamic FFIs
|
2
|
+
// This file should only be included in chipmunk.c
|
3
|
+
|
4
|
+
#ifdef _MSC_VER
|
5
|
+
#if _MSC_VER >= 1600
|
6
|
+
#define MAKE_REF(name) decltype(name) *_##name = name
|
7
|
+
#else
|
8
|
+
#define MAKE_REF(name)
|
9
|
+
#endif
|
10
|
+
#else
|
11
|
+
#define MAKE_REF(name) __typeof__(name) *_##name = name
|
12
|
+
#endif
|
13
|
+
|
14
|
+
MAKE_REF(cpv); // makes a variable named _cpv that contains the function pointer for cpv()
|
15
|
+
MAKE_REF(cpveql);
|
16
|
+
MAKE_REF(cpvadd);
|
17
|
+
MAKE_REF(cpvneg);
|
18
|
+
MAKE_REF(cpvsub);
|
19
|
+
MAKE_REF(cpvmult);
|
20
|
+
MAKE_REF(cpvdot);
|
21
|
+
MAKE_REF(cpvcross);
|
22
|
+
MAKE_REF(cpvperp);
|
23
|
+
MAKE_REF(cpvrperp);
|
24
|
+
MAKE_REF(cpvproject);
|
25
|
+
MAKE_REF(cpvrotate);
|
26
|
+
MAKE_REF(cpvunrotate);
|
27
|
+
MAKE_REF(cpvlengthsq);
|
28
|
+
MAKE_REF(cpvlerp);
|
29
|
+
MAKE_REF(cpvnormalize);
|
30
|
+
MAKE_REF(cpvnormalize_safe);
|
31
|
+
MAKE_REF(cpvclamp);
|
32
|
+
MAKE_REF(cpvlerpconst);
|
33
|
+
MAKE_REF(cpvdist);
|
34
|
+
MAKE_REF(cpvdistsq);
|
35
|
+
MAKE_REF(cpvnear);
|
36
|
+
|
37
|
+
MAKE_REF(cpBBNew);
|
38
|
+
MAKE_REF(cpBBintersects);
|
39
|
+
MAKE_REF(cpBBcontainsBB);
|
40
|
+
MAKE_REF(cpBBcontainsVect);
|
41
|
+
MAKE_REF(cpBBmerge);
|
42
|
+
MAKE_REF(cpBBexpand);
|
43
|
+
|
44
|
+
MAKE_REF(cpBodyWorld2Local);
|
45
|
+
MAKE_REF(cpBodyLocal2World);
|
46
|
+
MAKE_REF(cpBodyApplyImpulse);
|
47
|
+
MAKE_REF(cpBodyIsSleeping);
|
48
|
+
MAKE_REF(cpBodyIsRogue);
|
49
|
+
MAKE_REF(cpBodyKineticEnergy);
|
50
|
+
|
51
|
+
MAKE_REF(cpArbiterIsFirstContact);
|
52
|
+
MAKE_REF(cpArbiterGetShapes);
|
53
|
+
MAKE_REF(cpArbiterGetNormal);
|
54
|
+
MAKE_REF(cpArbiterGetPoint);
|
55
|
+
|
56
|
+
MAKE_REF(cpConstraintGetImpulse);
|
57
|
+
|
58
|
+
MAKE_REF(cpSegmentQueryHitPoint);
|
59
|
+
MAKE_REF(cpSegmentQueryHitDist);
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/* Copyright (c) 2007 Scott Lembcke
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to deal
|
5
|
+
* in the Software without restriction, including without limitation the rights
|
6
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
* copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
* SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#define CP_ALLOW_PRIVATE_ACCESS 1
|
23
|
+
#include "chipmunk.h"
|
24
|
+
|
25
|
+
void *cpSpaceGetPostStepData(cpSpace *space, void *obj);
|
26
|
+
|
27
|
+
void cpSpaceActivateBody(cpSpace *space, cpBody *body);
|
28
|
+
|
29
|
+
static inline void
|
30
|
+
cpSpaceLock(cpSpace *space)
|
31
|
+
{
|
32
|
+
space->locked++;
|
33
|
+
}
|
34
|
+
|
35
|
+
static inline void
|
36
|
+
cpSpaceUnlock(cpSpace *space)
|
37
|
+
{
|
38
|
+
space->locked--;
|
39
|
+
cpAssert(space->locked >= 0, "Internal error:Space lock underflow.");
|
40
|
+
|
41
|
+
if(!space->locked){
|
42
|
+
cpArray *waking = space->rousedBodies;
|
43
|
+
for(int i=0, count=waking->num; i<count; i++){
|
44
|
+
cpSpaceActivateBody(space, (cpBody *)waking->arr[i]);
|
45
|
+
}
|
46
|
+
|
47
|
+
waking->num = 0;
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,151 @@
|
|
1
|
+
#ifdef __APPLE__
|
2
|
+
#import "TargetConditionals.h"
|
3
|
+
#endif
|
4
|
+
|
5
|
+
#if (defined TARGET_OS_IPHONE) && (!defined CP_USE_CGPOINTS)
|
6
|
+
#define CP_USE_CGPOINTS
|
7
|
+
#endif
|
8
|
+
|
9
|
+
#ifdef CP_USE_CGPOINTS
|
10
|
+
#if TARGET_OS_IPHONE
|
11
|
+
#import <CoreGraphics/CGGeometry.h>
|
12
|
+
#elif TARGET_OS_MAC
|
13
|
+
#import <ApplicationServices/ApplicationServices.h>
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#if defined(__LP64__) && __LP64__
|
17
|
+
#define CP_USE_DOUBLES 1
|
18
|
+
#else
|
19
|
+
#define CP_USE_DOUBLES 0
|
20
|
+
#endif
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#ifndef CP_USE_DOUBLES
|
24
|
+
// use doubles by default for higher precision
|
25
|
+
#define CP_USE_DOUBLES 1
|
26
|
+
#endif
|
27
|
+
|
28
|
+
#if CP_USE_DOUBLES
|
29
|
+
typedef double cpFloat;
|
30
|
+
#define cpfsqrt sqrt
|
31
|
+
#define cpfsin sin
|
32
|
+
#define cpfcos cos
|
33
|
+
#define cpfacos acos
|
34
|
+
#define cpfatan2 atan2
|
35
|
+
#define cpfmod fmod
|
36
|
+
#define cpfexp exp
|
37
|
+
#define cpfpow pow
|
38
|
+
#define cpffloor floor
|
39
|
+
#define cpfceil ceil
|
40
|
+
#else
|
41
|
+
typedef float cpFloat;
|
42
|
+
#define cpfsqrt sqrtf
|
43
|
+
#define cpfsin sinf
|
44
|
+
#define cpfcos cosf
|
45
|
+
#define cpfacos acosf
|
46
|
+
#define cpfatan2 atan2f
|
47
|
+
#define cpfmod fmodf
|
48
|
+
#define cpfexp expf
|
49
|
+
#define cpfpow powf
|
50
|
+
#define cpffloor floorf
|
51
|
+
#define cpfceil ceilf
|
52
|
+
#endif
|
53
|
+
|
54
|
+
static inline cpFloat
|
55
|
+
cpfmax(cpFloat a, cpFloat b)
|
56
|
+
{
|
57
|
+
return (a > b) ? a : b;
|
58
|
+
}
|
59
|
+
|
60
|
+
static inline cpFloat
|
61
|
+
cpfmin(cpFloat a, cpFloat b)
|
62
|
+
{
|
63
|
+
return (a < b) ? a : b;
|
64
|
+
}
|
65
|
+
|
66
|
+
static inline cpFloat
|
67
|
+
cpfabs(cpFloat n)
|
68
|
+
{
|
69
|
+
return (n < 0) ? -n : n;
|
70
|
+
}
|
71
|
+
|
72
|
+
static inline cpFloat
|
73
|
+
cpfclamp(cpFloat f, cpFloat min, cpFloat max)
|
74
|
+
{
|
75
|
+
return cpfmin(cpfmax(f, min), max);
|
76
|
+
}
|
77
|
+
|
78
|
+
static inline cpFloat
|
79
|
+
cpflerp(cpFloat f1, cpFloat f2, cpFloat t)
|
80
|
+
{
|
81
|
+
return f1*(1.0f - t) + f2*t;
|
82
|
+
}
|
83
|
+
|
84
|
+
static inline cpFloat
|
85
|
+
cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d)
|
86
|
+
{
|
87
|
+
return f1 + cpfclamp(f2 - f1, -d, d);
|
88
|
+
}
|
89
|
+
|
90
|
+
// CGPoints are structurally the same, and allow
|
91
|
+
// easy interoperability with other Cocoa libraries
|
92
|
+
#ifdef CP_USE_CGPOINTS
|
93
|
+
typedef CGPoint cpVect;
|
94
|
+
#else
|
95
|
+
typedef struct cpVect{cpFloat x,y;} cpVect;
|
96
|
+
#endif
|
97
|
+
|
98
|
+
typedef unsigned int cpHashValue;
|
99
|
+
|
100
|
+
// Oh C, how we love to define our own boolean types to get compiler compatibility
|
101
|
+
#ifdef CP_BOOL_TYPE
|
102
|
+
typedef CP_BOOL_TYPE cpBool;
|
103
|
+
#else
|
104
|
+
typedef int cpBool;
|
105
|
+
#endif
|
106
|
+
|
107
|
+
#ifndef cpTrue
|
108
|
+
#define cpTrue 1
|
109
|
+
#endif
|
110
|
+
|
111
|
+
#ifndef cpFalse
|
112
|
+
#define cpFalse 0
|
113
|
+
#endif
|
114
|
+
|
115
|
+
#ifdef CP_DATA_POINTER_TYPE
|
116
|
+
typedef CP_DATA_POINTER_TYPE cpDataPointer;
|
117
|
+
#else
|
118
|
+
typedef void * cpDataPointer;
|
119
|
+
#endif
|
120
|
+
|
121
|
+
#ifdef CP_COLLISION_TYPE_TYPE
|
122
|
+
typedef CP_COLLISION_TYPE_TYPE cpCollisionType;
|
123
|
+
#else
|
124
|
+
typedef unsigned int cpCollisionType;
|
125
|
+
#endif
|
126
|
+
|
127
|
+
#ifdef CP_GROUP_TYPE
|
128
|
+
typedef CP_GROUP_TYPE cpGroup;
|
129
|
+
#else
|
130
|
+
typedef unsigned int cpGroup;
|
131
|
+
#endif
|
132
|
+
|
133
|
+
#ifdef CP_LAYERS_TYPE
|
134
|
+
typedef CP_GROUP_TYPE cpLayers;
|
135
|
+
#else
|
136
|
+
typedef unsigned int cpLayers;
|
137
|
+
#endif
|
138
|
+
|
139
|
+
#ifdef CP_TIMESTAMP_TYPE
|
140
|
+
typedef CP_TIMESTAMP_TYPE cpTimestamp;
|
141
|
+
#else
|
142
|
+
typedef unsigned int cpTimestamp;
|
143
|
+
#endif
|
144
|
+
|
145
|
+
#ifndef CP_NO_GROUP
|
146
|
+
#define CP_NO_GROUP ((cpGroup)0)
|
147
|
+
#endif
|
148
|
+
|
149
|
+
#ifndef CP_ALL_LAYERS
|
150
|
+
#define CP_ALL_LAYERS (~(cpLayers)0)
|
151
|
+
#endif
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/* Copyright (c) 2007 Scott Lembcke
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to deal
|
5
|
+
* in the Software without restriction, including without limitation the rights
|
6
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
* copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
* SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
/* This header defines a number of "unsafe" operations on Chipmunk objects.
|
25
|
+
* In this case "unsafe" is referring to operations which may reduce the
|
26
|
+
* physical accuracy or numerical stability of the simulation, but will not
|
27
|
+
* cause crashes.
|
28
|
+
*
|
29
|
+
* The prime example is mutating collision shapes. Chipmunk does not support
|
30
|
+
* this directly. Mutating shapes using this API will caused objects in contact
|
31
|
+
* to be pushed apart using Chipmunk's overlap solver, but not using real
|
32
|
+
* persistent velocities. Probably not what you meant, but perhaps close enough.
|
33
|
+
*/
|
34
|
+
|
35
|
+
#ifndef CHIPMUNK_UNSAFE_HEADER
|
36
|
+
#define CHIPMUNK_UNSAFE_HEADER
|
37
|
+
|
38
|
+
#ifdef __cplusplus
|
39
|
+
extern "C" {
|
40
|
+
#endif
|
41
|
+
|
42
|
+
void cpCircleShapeSetRadius(cpShape *shape, cpFloat radius);
|
43
|
+
void cpCircleShapeSetOffset(cpShape *shape, cpVect offset);
|
44
|
+
|
45
|
+
void cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b);
|
46
|
+
void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius);
|
47
|
+
|
48
|
+
void cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset);
|
49
|
+
|
50
|
+
#ifdef __cplusplus
|
51
|
+
}
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#endif
|