chipmunk 5.2.2 → 5.3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -19
- data/README +67 -60
- data/Rakefile +85 -50
- data/ext/chipmunk/extconf.rb +42 -35
- data/ext/chipmunk/rb_chipmunk.c +250 -125
- data/ext/chipmunk/rb_chipmunk.h +105 -96
- data/ext/chipmunk/rb_cpArbiter.c +253 -225
- data/ext/chipmunk/rb_cpBB.c +210 -174
- data/ext/chipmunk/rb_cpBody.c +504 -347
- data/ext/chipmunk/rb_cpConstraint.c +336 -346
- data/ext/chipmunk/rb_cpShape.c +433 -455
- data/ext/chipmunk/rb_cpSpace.c +711 -544
- data/ext/chipmunk/rb_cpVect.c +346 -321
- data/lib/chipmunk.rb +183 -30
- metadata +12 -66
- data/ext/chipmunk/chipmunk.c +0 -105
- data/ext/chipmunk/cpArbiter.c +0 -274
- data/ext/chipmunk/cpArray.c +0 -128
- data/ext/chipmunk/cpBB.c +0 -47
- data/ext/chipmunk/cpBody.c +0 -188
- data/ext/chipmunk/cpCollision.c +0 -391
- data/ext/chipmunk/cpConstraint.c +0 -54
- data/ext/chipmunk/cpDampedRotarySpring.c +0 -106
- data/ext/chipmunk/cpDampedSpring.c +0 -117
- data/ext/chipmunk/cpGearJoint.c +0 -114
- data/ext/chipmunk/cpGrooveJoint.c +0 -138
- data/ext/chipmunk/cpHashSet.c +0 -253
- data/ext/chipmunk/cpPinJoint.c +0 -117
- data/ext/chipmunk/cpPivotJoint.c +0 -114
- data/ext/chipmunk/cpPolyShape.c +0 -241
- data/ext/chipmunk/cpRatchetJoint.c +0 -128
- data/ext/chipmunk/cpRotaryLimitJoint.c +0 -122
- data/ext/chipmunk/cpShape.c +0 -400
- data/ext/chipmunk/cpSimpleMotor.c +0 -99
- data/ext/chipmunk/cpSlideJoint.c +0 -131
- data/ext/chipmunk/cpSpace.c +0 -899
- data/ext/chipmunk/cpSpaceHash.c +0 -541
- data/ext/chipmunk/cpVect.c +0 -71
- data/ext/chipmunk/include/chipmunk/chipmunk.h +0 -148
- data/ext/chipmunk/include/chipmunk/chipmunk_ffi.h +0 -42
- data/ext/chipmunk/include/chipmunk/chipmunk_types.h +0 -80
- data/ext/chipmunk/include/chipmunk/chipmunk_unsafe.h +0 -54
- data/ext/chipmunk/include/chipmunk/constraints/cpConstraint.h +0 -92
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +0 -46
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +0 -53
- data/ext/chipmunk/include/chipmunk/constraints/cpGearJoint.h +0 -41
- data/ext/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +0 -44
- data/ext/chipmunk/include/chipmunk/constraints/cpPinJoint.h +0 -43
- data/ext/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +0 -42
- data/ext/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +0 -40
- data/ext/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +0 -39
- data/ext/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +0 -37
- data/ext/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +0 -44
- data/ext/chipmunk/include/chipmunk/constraints/util.h +0 -116
- data/ext/chipmunk/include/chipmunk/cpArbiter.h +0 -136
- data/ext/chipmunk/include/chipmunk/cpArray.h +0 -46
- data/ext/chipmunk/include/chipmunk/cpBB.h +0 -74
- data/ext/chipmunk/include/chipmunk/cpBody.h +0 -160
- data/ext/chipmunk/include/chipmunk/cpCollision.h +0 -23
- data/ext/chipmunk/include/chipmunk/cpHashSet.h +0 -82
- data/ext/chipmunk/include/chipmunk/cpPolyShape.h +0 -103
- data/ext/chipmunk/include/chipmunk/cpShape.h +0 -174
- data/ext/chipmunk/include/chipmunk/cpSpace.h +0 -180
- data/ext/chipmunk/include/chipmunk/cpSpaceHash.h +0 -109
- data/ext/chipmunk/include/chipmunk/cpVect.h +0 -157
- data/ext/chipmunk/prime.h +0 -68
- data/lib/chipmunk/version.rb +0 -3
data/ext/chipmunk/cpVect.c
DELETED
@@ -1,71 +0,0 @@
|
|
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
|
-
#include <stdio.h>
|
23
|
-
#include <math.h>
|
24
|
-
|
25
|
-
#include "chipmunk.h"
|
26
|
-
|
27
|
-
cpFloat
|
28
|
-
cpvlength(const cpVect v)
|
29
|
-
{
|
30
|
-
return cpfsqrt( cpvdot(v, v) );
|
31
|
-
}
|
32
|
-
|
33
|
-
inline cpVect
|
34
|
-
cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t)
|
35
|
-
{
|
36
|
-
cpFloat omega = cpfacos(cpvdot(v1, v2));
|
37
|
-
|
38
|
-
if(omega){
|
39
|
-
cpFloat denom = 1.0f/cpfsin(omega);
|
40
|
-
return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom));
|
41
|
-
} else {
|
42
|
-
return v1;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
cpVect
|
47
|
-
cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a)
|
48
|
-
{
|
49
|
-
cpFloat angle = cpfacos(cpvdot(v1, v2));
|
50
|
-
return cpvslerp(v1, v2, cpfmin(a, angle)/angle);
|
51
|
-
}
|
52
|
-
|
53
|
-
cpVect
|
54
|
-
cpvforangle(const cpFloat a)
|
55
|
-
{
|
56
|
-
return cpv(cpfcos(a), cpfsin(a));
|
57
|
-
}
|
58
|
-
|
59
|
-
cpFloat
|
60
|
-
cpvtoangle(const cpVect v)
|
61
|
-
{
|
62
|
-
return cpfatan2(v.y, v.x);
|
63
|
-
}
|
64
|
-
|
65
|
-
char*
|
66
|
-
cpvstr(const cpVect v)
|
67
|
-
{
|
68
|
-
static char str[256];
|
69
|
-
sprintf(str, "(% .3f, % .3f)", v.x, v.y);
|
70
|
-
return str;
|
71
|
-
}
|
@@ -1,148 +0,0 @@
|
|
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
|
-
void cpMessage(char *message, char *condition, char *file, int line, int isError);
|
30
|
-
#ifdef NDEBUG
|
31
|
-
#define cpAssertWarn(condition, message)
|
32
|
-
#else
|
33
|
-
#define cpAssertWarn(condition, message) if(!(condition)) cpMessage(message, #condition, __FILE__, __LINE__, 0)
|
34
|
-
#endif
|
35
|
-
|
36
|
-
#ifdef NDEBUG
|
37
|
-
#define cpAssert(condition, message)
|
38
|
-
#else
|
39
|
-
#define cpAssert(condition, message) if(!(condition)) cpMessage(message, #condition, __FILE__, __LINE__, 1)
|
40
|
-
#endif
|
41
|
-
|
42
|
-
#include "chipmunk_types.h"
|
43
|
-
|
44
|
-
static inline cpFloat
|
45
|
-
cpfmax(cpFloat a, cpFloat b)
|
46
|
-
{
|
47
|
-
return (a > b) ? a : b;
|
48
|
-
}
|
49
|
-
|
50
|
-
static inline cpFloat
|
51
|
-
cpfmin(cpFloat a, cpFloat b)
|
52
|
-
{
|
53
|
-
return (a < b) ? a : b;
|
54
|
-
}
|
55
|
-
|
56
|
-
static inline cpFloat
|
57
|
-
cpfabs(cpFloat n)
|
58
|
-
{
|
59
|
-
return (n < 0) ? -n : n;
|
60
|
-
}
|
61
|
-
|
62
|
-
static inline cpFloat
|
63
|
-
cpfclamp(cpFloat f, cpFloat min, cpFloat max)
|
64
|
-
{
|
65
|
-
return cpfmin(cpfmax(f, min), max);
|
66
|
-
}
|
67
|
-
|
68
|
-
static inline cpFloat
|
69
|
-
cpflerp(cpFloat f1, cpFloat f2, cpFloat t)
|
70
|
-
{
|
71
|
-
return f1*(1.0f - t) + f2*t;
|
72
|
-
}
|
73
|
-
|
74
|
-
static inline cpFloat
|
75
|
-
cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d)
|
76
|
-
{
|
77
|
-
return f1 + cpfclamp(f2 - f1, -d, d);
|
78
|
-
}
|
79
|
-
|
80
|
-
#ifndef INFINITY
|
81
|
-
#ifdef _MSC_VER
|
82
|
-
union MSVC_EVIL_FLOAT_HACK
|
83
|
-
{
|
84
|
-
unsigned __int8 Bytes[4];
|
85
|
-
float Value;
|
86
|
-
};
|
87
|
-
static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
|
88
|
-
#define INFINITY (INFINITY_HACK.Value)
|
89
|
-
#endif
|
90
|
-
|
91
|
-
#ifdef __GNUC__
|
92
|
-
#define INFINITY (__builtin_inf())
|
93
|
-
#endif
|
94
|
-
|
95
|
-
#ifndef INFINITY
|
96
|
-
#define INFINITY (1e1000)
|
97
|
-
#endif
|
98
|
-
#endif
|
99
|
-
|
100
|
-
// Maximum allocated size for various Chipmunk buffer sizes
|
101
|
-
#define CP_BUFFER_BYTES (32*1024)
|
102
|
-
|
103
|
-
#define cpmalloc malloc
|
104
|
-
#define cpcalloc calloc
|
105
|
-
#define cprealloc realloc
|
106
|
-
#define cpfree free
|
107
|
-
|
108
|
-
#include "cpVect.h"
|
109
|
-
#include "cpBB.h"
|
110
|
-
#include "cpBody.h"
|
111
|
-
#include "cpArray.h"
|
112
|
-
#include "cpHashSet.h"
|
113
|
-
#include "cpSpaceHash.h"
|
114
|
-
|
115
|
-
#include "cpShape.h"
|
116
|
-
#include "cpPolyShape.h"
|
117
|
-
|
118
|
-
#include "cpArbiter.h"
|
119
|
-
#include "cpCollision.h"
|
120
|
-
|
121
|
-
#include "constraints/cpConstraint.h"
|
122
|
-
|
123
|
-
#include "cpSpace.h"
|
124
|
-
|
125
|
-
#define CP_HASH_COEF (3344921057ul)
|
126
|
-
#define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF)
|
127
|
-
|
128
|
-
extern char *cpVersionString;
|
129
|
-
void cpInitChipmunk(void);
|
130
|
-
|
131
|
-
// Calculate the moment of inertia for a circle, r1 and r2 are the inner and outer diameters.
|
132
|
-
// (A solid circle has an inner diameter of 0)
|
133
|
-
cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset);
|
134
|
-
|
135
|
-
// Calculate the moment of inertia for a line segment. (beveling radius not supported)
|
136
|
-
cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b);
|
137
|
-
|
138
|
-
// Calculate the moment of inertia for a solid polygon shape.
|
139
|
-
cpFloat cpMomentForPoly(cpFloat m, int numVerts, cpVect *verts, cpVect offset);
|
140
|
-
|
141
|
-
// Calculate the moment of inertia for a solid box.
|
142
|
-
cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height);
|
143
|
-
|
144
|
-
#ifdef __cplusplus
|
145
|
-
}
|
146
|
-
#endif
|
147
|
-
|
148
|
-
#endif
|
@@ -1,42 +0,0 @@
|
|
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
|
-
#define MAKE_REF(name) __typeof__(name) *_##name = name
|
5
|
-
|
6
|
-
MAKE_REF(cpv); // makes a variable named _cpv that contains the function pointer for cpv()
|
7
|
-
MAKE_REF(cpvadd);
|
8
|
-
MAKE_REF(cpvneg);
|
9
|
-
MAKE_REF(cpvsub);
|
10
|
-
MAKE_REF(cpvmult);
|
11
|
-
MAKE_REF(cpvdot);
|
12
|
-
MAKE_REF(cpvcross);
|
13
|
-
MAKE_REF(cpvperp);
|
14
|
-
MAKE_REF(cpvrperp);
|
15
|
-
MAKE_REF(cpvproject);
|
16
|
-
MAKE_REF(cpvrotate);
|
17
|
-
MAKE_REF(cpvunrotate);
|
18
|
-
MAKE_REF(cpvlengthsq);
|
19
|
-
MAKE_REF(cpvlerp);
|
20
|
-
MAKE_REF(cpvnormalize);
|
21
|
-
MAKE_REF(cpvnormalize_safe);
|
22
|
-
MAKE_REF(cpvclamp);
|
23
|
-
MAKE_REF(cpvlerpconst);
|
24
|
-
MAKE_REF(cpvdist);
|
25
|
-
MAKE_REF(cpvnear);
|
26
|
-
MAKE_REF(cpvdistsq);
|
27
|
-
|
28
|
-
MAKE_REF(cpBBNew);
|
29
|
-
MAKE_REF(cpBBintersects);
|
30
|
-
MAKE_REF(cpBBcontainsBB);
|
31
|
-
MAKE_REF(cpBBcontainsVect);
|
32
|
-
MAKE_REF(cpBBmerge);
|
33
|
-
MAKE_REF(cpBBexpand);
|
34
|
-
|
35
|
-
MAKE_REF(cpBodyWorld2Local);
|
36
|
-
MAKE_REF(cpBodyLocal2World);
|
37
|
-
MAKE_REF(cpBodyApplyImpulse);
|
38
|
-
|
39
|
-
MAKE_REF(cpArbiterIsFirstContact);
|
40
|
-
MAKE_REF(cpArbiterGetShapes);
|
41
|
-
MAKE_REF(cpArbiterGetNormal);
|
42
|
-
MAKE_REF(cpArbiterGetPoint);
|
@@ -1,80 +0,0 @@
|
|
1
|
-
#ifdef __APPLE__
|
2
|
-
#import "TargetConditionals.h"
|
3
|
-
#endif
|
4
|
-
|
5
|
-
// Use single precision floats on the iPhone.
|
6
|
-
#if TARGET_OS_IPHONE==1
|
7
|
-
#define CP_USE_DOUBLES 0
|
8
|
-
#else
|
9
|
-
// use doubles by default for higher precision
|
10
|
-
#define CP_USE_DOUBLES 1
|
11
|
-
#endif
|
12
|
-
|
13
|
-
#if CP_USE_DOUBLES
|
14
|
-
typedef double cpFloat;
|
15
|
-
#define cpfsqrt sqrt
|
16
|
-
#define cpfsin sin
|
17
|
-
#define cpfcos cos
|
18
|
-
#define cpfacos acos
|
19
|
-
#define cpfatan2 atan2
|
20
|
-
#define cpfmod fmod
|
21
|
-
#define cpfexp exp
|
22
|
-
#define cpfpow pow
|
23
|
-
#define cpffloor floor
|
24
|
-
#define cpfceil ceil
|
25
|
-
#else
|
26
|
-
typedef float cpFloat;
|
27
|
-
#define cpfsqrt sqrtf
|
28
|
-
#define cpfsin sinf
|
29
|
-
#define cpfcos cosf
|
30
|
-
#define cpfacos acosf
|
31
|
-
#define cpfatan2 atan2f
|
32
|
-
#define cpfmod fmodf
|
33
|
-
#define cpfexp expf
|
34
|
-
#define cpfpow powf
|
35
|
-
#define cpffloor floorf
|
36
|
-
#define cpfceil ceilf
|
37
|
-
#endif
|
38
|
-
|
39
|
-
#if TARGET_OS_IPHONE
|
40
|
-
// CGPoints are structurally the same, and allow
|
41
|
-
// easy interoperability with other iPhone libraries
|
42
|
-
#import <CoreGraphics/CGGeometry.h>
|
43
|
-
typedef CGPoint cpVect;
|
44
|
-
#else
|
45
|
-
typedef struct cpVect{cpFloat x,y;} cpVect;
|
46
|
-
#endif
|
47
|
-
|
48
|
-
typedef unsigned int cpHashValue;
|
49
|
-
|
50
|
-
#ifdef CP_DATA_POINTER_TYPE
|
51
|
-
typedef CP_DATA_POINTER_TYPE cpDataPointer;
|
52
|
-
#else
|
53
|
-
typedef void * cpDataPointer;
|
54
|
-
#endif
|
55
|
-
|
56
|
-
#ifdef CP_COLLISION_TYPE_TYPE
|
57
|
-
typedef CP_COLLISION_TYPE_TYPE cpCollisionType;
|
58
|
-
#else
|
59
|
-
typedef unsigned int cpCollisionType;
|
60
|
-
#endif
|
61
|
-
|
62
|
-
#ifdef CP_GROUP_TYPE
|
63
|
-
typedef CP_GROUP_TYPE cpGroup;
|
64
|
-
#else
|
65
|
-
typedef unsigned int cpGroup;
|
66
|
-
#endif
|
67
|
-
|
68
|
-
#ifdef CP_LAYERS_TYPE
|
69
|
-
typedef CP_GROUP_TYPE cpLayers;
|
70
|
-
#else
|
71
|
-
typedef unsigned int cpLayers;
|
72
|
-
#endif
|
73
|
-
|
74
|
-
#ifndef CP_NO_GROUP
|
75
|
-
#define CP_NO_GROUP ((cpGroup)0)
|
76
|
-
#endif
|
77
|
-
|
78
|
-
#ifndef CP_ALL_LAYERS
|
79
|
-
#define CP_ALL_LAYERS (~(cpLayers)0)
|
80
|
-
#endif
|
@@ -1,54 +0,0 @@
|
|
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
|
@@ -1,92 +0,0 @@
|
|
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
|
-
// TODO: Comment me!
|
23
|
-
|
24
|
-
extern cpFloat cp_constraint_bias_coef;
|
25
|
-
|
26
|
-
struct cpConstraintClass;
|
27
|
-
struct cpConstraint;
|
28
|
-
|
29
|
-
typedef void (*cpConstraintPreStepFunction)(struct cpConstraint *constraint, cpFloat dt, cpFloat dt_inv);
|
30
|
-
typedef void (*cpConstraintApplyImpulseFunction)(struct cpConstraint *constraint);
|
31
|
-
typedef cpFloat (*cpConstraintGetImpulseFunction)(struct cpConstraint *constraint);
|
32
|
-
|
33
|
-
typedef struct cpConstraintClass {
|
34
|
-
cpConstraintPreStepFunction preStep;
|
35
|
-
cpConstraintApplyImpulseFunction applyImpulse;
|
36
|
-
cpConstraintGetImpulseFunction getImpulse;
|
37
|
-
} cpConstraintClass;
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
typedef struct cpConstraint {
|
42
|
-
const cpConstraintClass *klass;
|
43
|
-
|
44
|
-
cpBody *a, *b;
|
45
|
-
cpFloat maxForce;
|
46
|
-
cpFloat biasCoef;
|
47
|
-
cpFloat maxBias;
|
48
|
-
|
49
|
-
cpDataPointer data;
|
50
|
-
} cpConstraint;
|
51
|
-
|
52
|
-
#ifdef CP_USE_DEPRECATED_API_4
|
53
|
-
typedef cpConstraint cpJoint;
|
54
|
-
#endif
|
55
|
-
|
56
|
-
void cpConstraintDestroy(cpConstraint *constraint);
|
57
|
-
void cpConstraintFree(cpConstraint *constraint);
|
58
|
-
|
59
|
-
|
60
|
-
#define cpConstraintCheckCast(constraint, struct) \
|
61
|
-
cpAssert(constraint->klass == struct##GetClass(), "Constraint is not a "#struct);
|
62
|
-
|
63
|
-
|
64
|
-
#define CP_DefineConstraintGetter(struct, type, member, name) \
|
65
|
-
static inline type \
|
66
|
-
struct##Get##name(cpConstraint *constraint){ \
|
67
|
-
cpConstraintCheckCast(constraint, struct); \
|
68
|
-
return ((struct *)constraint)->member; \
|
69
|
-
} \
|
70
|
-
|
71
|
-
#define CP_DefineConstraintSetter(struct, type, member, name) \
|
72
|
-
static inline void \
|
73
|
-
struct##Set##name(cpConstraint *constraint, type value){ \
|
74
|
-
cpConstraintCheckCast(constraint, struct); \
|
75
|
-
((struct *)constraint)->member = value; \
|
76
|
-
} \
|
77
|
-
|
78
|
-
#define CP_DefineConstraintProperty(struct, type, member, name) \
|
79
|
-
CP_DefineConstraintGetter(struct, type, member, name) \
|
80
|
-
CP_DefineConstraintSetter(struct, type, member, name)
|
81
|
-
|
82
|
-
// Built in Joint types
|
83
|
-
#include "cpPinJoint.h"
|
84
|
-
#include "cpSlideJoint.h"
|
85
|
-
#include "cpPivotJoint.h"
|
86
|
-
#include "cpGrooveJoint.h"
|
87
|
-
#include "cpDampedSpring.h"
|
88
|
-
#include "cpDampedRotarySpring.h"
|
89
|
-
#include "cpRotaryLimitJoint.h"
|
90
|
-
#include "cpRatchetJoint.h"
|
91
|
-
#include "cpGearJoint.h"
|
92
|
-
#include "cpSimpleMotor.h"
|