chipmunk 4.1.0-x86-mswin32 → 5.3.4.0-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/{ext/chipmunk/cpCollision.h → LICENSE} +4 -5
- data/README +67 -0
- data/Rakefile +76 -29
- data/ext/chipmunk/extconf.rb +38 -0
- data/ext/chipmunk/rb_chipmunk.c +162 -21
- data/ext/chipmunk/rb_chipmunk.h +39 -11
- data/ext/chipmunk/rb_cpArbiter.c +253 -0
- data/ext/chipmunk/rb_cpBB.c +60 -4
- data/ext/chipmunk/rb_cpBody.c +282 -17
- data/ext/chipmunk/rb_cpConstraint.c +336 -0
- data/ext/chipmunk/rb_cpShape.c +145 -4
- data/ext/chipmunk/rb_cpSpace.c +438 -57
- data/ext/chipmunk/rb_cpVect.c +98 -2
- data/lib/1.8/chipmunk.so +0 -0
- data/lib/1.9/chipmunk.so +0 -0
- data/lib/chipmunk.rb +168 -0
- metadata +29 -41
- data/ext/chipmunk/chipmunk.c +0 -69
- data/ext/chipmunk/chipmunk.h +0 -91
- data/ext/chipmunk/cpArbiter.c +0 -263
- data/ext/chipmunk/cpArbiter.h +0 -85
- data/ext/chipmunk/cpArray.c +0 -114
- data/ext/chipmunk/cpArray.h +0 -45
- data/ext/chipmunk/cpBB.c +0 -46
- data/ext/chipmunk/cpBB.h +0 -53
- data/ext/chipmunk/cpBody.c +0 -180
- data/ext/chipmunk/cpBody.h +0 -132
- data/ext/chipmunk/cpCollision.c +0 -390
- data/ext/chipmunk/cpHashSet.c +0 -219
- data/ext/chipmunk/cpHashSet.h +0 -79
- data/ext/chipmunk/cpJoint.c +0 -553
- data/ext/chipmunk/cpJoint.h +0 -122
- data/ext/chipmunk/cpPolyShape.c +0 -139
- data/ext/chipmunk/cpPolyShape.h +0 -92
- data/ext/chipmunk/cpShape.c +0 -244
- data/ext/chipmunk/cpShape.h +0 -141
- data/ext/chipmunk/cpSpace.c +0 -530
- data/ext/chipmunk/cpSpace.h +0 -120
- data/ext/chipmunk/cpSpaceHash.c +0 -455
- data/ext/chipmunk/cpSpaceHash.h +0 -100
- data/ext/chipmunk/cpVect.c +0 -63
- data/ext/chipmunk/cpVect.h +0 -106
- data/ext/chipmunk/prime.h +0 -68
- data/ext/chipmunk/rb_cpJoint.c +0 -136
data/ext/chipmunk/cpSpaceHash.h
DELETED
@@ -1,100 +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
|
-
// The spatial hash is Chipmunk's default (and currently only) spatial index type.
|
23
|
-
// Based on a chained hash table.
|
24
|
-
|
25
|
-
// Used internally to track objects added to the hash
|
26
|
-
typedef struct cpHandle{
|
27
|
-
// Pointer to the object
|
28
|
-
void *obj;
|
29
|
-
// Retain count
|
30
|
-
int retain;
|
31
|
-
// Query stamp. Used to make sure two objects
|
32
|
-
// aren't identified twice in the same query.
|
33
|
-
int stamp;
|
34
|
-
} cpHandle;
|
35
|
-
|
36
|
-
// Linked list element for in the chains.
|
37
|
-
typedef struct cpSpaceHashBin{
|
38
|
-
cpHandle *handle;
|
39
|
-
struct cpSpaceHashBin *next;
|
40
|
-
} cpSpaceHashBin;
|
41
|
-
|
42
|
-
// BBox callback. Called whenever the hash needs a bounding box from an object.
|
43
|
-
typedef cpBB (*cpSpaceHashBBFunc)(void *obj);
|
44
|
-
|
45
|
-
typedef struct cpSpaceHash{
|
46
|
-
// Number of cells in the table.
|
47
|
-
int numcells;
|
48
|
-
// Dimentions of the cells.
|
49
|
-
cpFloat celldim;
|
50
|
-
|
51
|
-
// BBox callback.
|
52
|
-
cpSpaceHashBBFunc bbfunc;
|
53
|
-
|
54
|
-
// Hashset of all the handles.
|
55
|
-
cpHashSet *handleSet;
|
56
|
-
|
57
|
-
cpSpaceHashBin **table;
|
58
|
-
// List of recycled bins.
|
59
|
-
cpSpaceHashBin *bins;
|
60
|
-
|
61
|
-
// Incremented on each query. See cpHandle.stamp.
|
62
|
-
int stamp;
|
63
|
-
} cpSpaceHash;
|
64
|
-
|
65
|
-
//Basic allocation/destruction functions.
|
66
|
-
cpSpaceHash *cpSpaceHashAlloc(void);
|
67
|
-
cpSpaceHash *cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int cells, cpSpaceHashBBFunc bbfunc);
|
68
|
-
cpSpaceHash *cpSpaceHashNew(cpFloat celldim, int cells, cpSpaceHashBBFunc bbfunc);
|
69
|
-
|
70
|
-
void cpSpaceHashDestroy(cpSpaceHash *hash);
|
71
|
-
void cpSpaceHashFree(cpSpaceHash *hash);
|
72
|
-
|
73
|
-
// Resize the hashtable. (Does not rehash! You must call cpSpaceHashRehash() if needed.)
|
74
|
-
void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells);
|
75
|
-
|
76
|
-
// Add an object to the hash.
|
77
|
-
void cpSpaceHashInsert(cpSpaceHash *hash, void *obj, unsigned int id, cpBB bb);
|
78
|
-
// Remove an object from the hash.
|
79
|
-
void cpSpaceHashRemove(cpSpaceHash *hash, void *obj, unsigned int id);
|
80
|
-
|
81
|
-
// Iterator function
|
82
|
-
typedef void (*cpSpaceHashIterator)(void *obj, void *data);
|
83
|
-
// Iterate over the objects in the hash.
|
84
|
-
void cpSpaceHashEach(cpSpaceHash *hash, cpSpaceHashIterator func, void *data);
|
85
|
-
|
86
|
-
// Rehash the contents of the hash.
|
87
|
-
void cpSpaceHashRehash(cpSpaceHash *hash);
|
88
|
-
// Rehash only a specific object.
|
89
|
-
void cpSpaceHashRehashObject(cpSpaceHash *hash, void *obj, unsigned int id);
|
90
|
-
|
91
|
-
// Query callback.
|
92
|
-
typedef int (*cpSpaceHashQueryFunc)(void *obj1, void *obj2, void *data);
|
93
|
-
// Point query the hash. A reference to the query point is passed as obj1 to the query callback.
|
94
|
-
void cpSpaceHashPointQuery(cpSpaceHash *hash, cpVect point, cpSpaceHashQueryFunc func, void *data);
|
95
|
-
// Query the hash for a given BBox.
|
96
|
-
void cpSpaceHashQuery(cpSpaceHash *hash, void *obj, cpBB bb, cpSpaceHashQueryFunc func, void *data);
|
97
|
-
// Run a query for the object, then insert it. (Optimized case)
|
98
|
-
void cpSpaceHashQueryInsert(cpSpaceHash *hash, void *obj, cpBB bb, cpSpaceHashQueryFunc func, void *data);
|
99
|
-
// Rehashes while querying for each object. (Optimized case)
|
100
|
-
void cpSpaceHashQueryRehash(cpSpaceHash *hash, cpSpaceHashQueryFunc func, void *data);
|
data/ext/chipmunk/cpVect.c
DELETED
@@ -1,63 +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 sqrtf( cpvdot(v, v) );
|
31
|
-
}
|
32
|
-
|
33
|
-
cpFloat
|
34
|
-
cpvlengthsq(const cpVect v)
|
35
|
-
{
|
36
|
-
return cpvdot(v, v);
|
37
|
-
}
|
38
|
-
|
39
|
-
cpVect
|
40
|
-
cpvnormalize(const cpVect v)
|
41
|
-
{
|
42
|
-
return cpvmult( v, 1.0f/cpvlength(v) );
|
43
|
-
}
|
44
|
-
|
45
|
-
cpVect
|
46
|
-
cpvforangle(const cpFloat a)
|
47
|
-
{
|
48
|
-
return cpv(cos(a), sin(a));
|
49
|
-
}
|
50
|
-
|
51
|
-
cpFloat
|
52
|
-
cpvtoangle(const cpVect v)
|
53
|
-
{
|
54
|
-
return atan2(v.y, v.x);
|
55
|
-
}
|
56
|
-
|
57
|
-
char*
|
58
|
-
cpvstr(const cpVect v)
|
59
|
-
{
|
60
|
-
static char str[256];
|
61
|
-
sprintf(str, "(% .3f, % .3f)", v.x, v.y);
|
62
|
-
return str;
|
63
|
-
}
|
data/ext/chipmunk/cpVect.h
DELETED
@@ -1,106 +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
|
-
typedef struct cpVect{
|
23
|
-
cpFloat x,y;
|
24
|
-
} cpVect;
|
25
|
-
|
26
|
-
static const cpVect cpvzero={0.0f,0.0f};
|
27
|
-
|
28
|
-
static inline cpVect
|
29
|
-
cpv(const cpFloat x, const cpFloat y)
|
30
|
-
{
|
31
|
-
cpVect v = {x, y};
|
32
|
-
return v;
|
33
|
-
}
|
34
|
-
|
35
|
-
static inline cpVect
|
36
|
-
cpvadd(const cpVect v1, const cpVect v2)
|
37
|
-
{
|
38
|
-
return cpv(v1.x + v2.x, v1.y + v2.y);
|
39
|
-
}
|
40
|
-
|
41
|
-
static inline cpVect
|
42
|
-
cpvneg(const cpVect v)
|
43
|
-
{
|
44
|
-
return cpv(-v.x, -v.y);
|
45
|
-
}
|
46
|
-
|
47
|
-
static inline cpVect
|
48
|
-
cpvsub(const cpVect v1, const cpVect v2)
|
49
|
-
{
|
50
|
-
return cpv(v1.x - v2.x, v1.y - v2.y);
|
51
|
-
}
|
52
|
-
|
53
|
-
static inline cpVect
|
54
|
-
cpvmult(const cpVect v, const cpFloat s)
|
55
|
-
{
|
56
|
-
return cpv(v.x*s, v.y*s);
|
57
|
-
}
|
58
|
-
|
59
|
-
static inline cpFloat
|
60
|
-
cpvdot(const cpVect v1, const cpVect v2)
|
61
|
-
{
|
62
|
-
return v1.x*v2.x + v1.y*v2.y;
|
63
|
-
}
|
64
|
-
|
65
|
-
static inline cpFloat
|
66
|
-
cpvcross(const cpVect v1, const cpVect v2)
|
67
|
-
{
|
68
|
-
return v1.x*v2.y - v1.y*v2.x;
|
69
|
-
}
|
70
|
-
|
71
|
-
static inline cpVect
|
72
|
-
cpvperp(const cpVect v)
|
73
|
-
{
|
74
|
-
return cpv(-v.y, v.x);
|
75
|
-
}
|
76
|
-
|
77
|
-
static inline cpVect
|
78
|
-
cpvrperp(const cpVect v)
|
79
|
-
{
|
80
|
-
return cpv(v.y, -v.x);
|
81
|
-
}
|
82
|
-
|
83
|
-
static inline cpVect
|
84
|
-
cpvproject(const cpVect v1, const cpVect v2)
|
85
|
-
{
|
86
|
-
return cpvmult(v2, cpvdot(v1, v2)/cpvdot(v2, v2));
|
87
|
-
}
|
88
|
-
|
89
|
-
static inline cpVect
|
90
|
-
cpvrotate(const cpVect v1, const cpVect v2)
|
91
|
-
{
|
92
|
-
return cpv(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x);
|
93
|
-
}
|
94
|
-
|
95
|
-
static inline cpVect
|
96
|
-
cpvunrotate(const cpVect v1, const cpVect v2)
|
97
|
-
{
|
98
|
-
return cpv(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y);
|
99
|
-
}
|
100
|
-
|
101
|
-
cpFloat cpvlength(const cpVect v);
|
102
|
-
cpFloat cpvlengthsq(const cpVect v); // no sqrt() call
|
103
|
-
cpVect cpvnormalize(const cpVect v);
|
104
|
-
cpVect cpvforangle(const cpFloat a); // convert radians to a normalized vector
|
105
|
-
cpFloat cpvtoangle(const cpVect v); // convert a vector to radians
|
106
|
-
char *cpvstr(const cpVect v); // get a string representation of a vector
|
data/ext/chipmunk/prime.h
DELETED
@@ -1,68 +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
|
-
// Used for resizing hash tables.
|
23
|
-
// Values approximately double.
|
24
|
-
|
25
|
-
static int primes[] = {
|
26
|
-
5, //2^2 + 1
|
27
|
-
11, //2^3 + 3
|
28
|
-
17, //2^4 + 1
|
29
|
-
37, //2^5 + 5
|
30
|
-
67, //2^6 + 3
|
31
|
-
131, //2^7 + 3
|
32
|
-
257, //2^8 + 1
|
33
|
-
521, //2^9 + 9
|
34
|
-
1031, //2^10 + 7
|
35
|
-
2053, //2^11 + 5
|
36
|
-
4099, //2^12 + 3
|
37
|
-
8209, //2^13 + 17
|
38
|
-
16411, //2^14 + 27
|
39
|
-
32771, //2^15 + 3
|
40
|
-
65537, //2^16 + 1
|
41
|
-
131101, //2^17 + 29
|
42
|
-
262147, //2^18 + 3
|
43
|
-
524309, //2^19 + 21
|
44
|
-
1048583, //2^20 + 7
|
45
|
-
2097169, //2^21 + 17
|
46
|
-
4194319, //2^22 + 15
|
47
|
-
8388617, //2^23 + 9
|
48
|
-
16777259, //2^24 + 43
|
49
|
-
33554467, //2^25 + 35
|
50
|
-
67108879, //2^26 + 15
|
51
|
-
134217757, //2^27 + 29
|
52
|
-
268435459, //2^28 + 3
|
53
|
-
536870923, //2^29 + 11
|
54
|
-
1073741827, //2^30 + 3
|
55
|
-
0,
|
56
|
-
};
|
57
|
-
|
58
|
-
static int
|
59
|
-
next_prime(int n)
|
60
|
-
{
|
61
|
-
int i = 0;
|
62
|
-
while(n > primes[i]){
|
63
|
-
i++;
|
64
|
-
assert(primes[i]); // realistically this should never happen
|
65
|
-
}
|
66
|
-
|
67
|
-
return primes[i];
|
68
|
-
}
|
data/ext/chipmunk/rb_cpJoint.c
DELETED
@@ -1,136 +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 "chipmunk.h"
|
23
|
-
|
24
|
-
#include "ruby.h"
|
25
|
-
#include "rb_chipmunk.h"
|
26
|
-
|
27
|
-
VALUE m_cpJoint;
|
28
|
-
|
29
|
-
static VALUE
|
30
|
-
rb_cpPinJointAlloc(VALUE klass)
|
31
|
-
{
|
32
|
-
cpPinJoint *joint = cpPinJointAlloc();
|
33
|
-
VALUE self = Data_Wrap_Struct(klass, NULL, cpJointFree, joint);
|
34
|
-
|
35
|
-
return self;
|
36
|
-
}
|
37
|
-
|
38
|
-
static VALUE
|
39
|
-
rb_cpPinJointInit(VALUE self, VALUE a, VALUE b, VALUE anchr1, VALUE anchr2)
|
40
|
-
{
|
41
|
-
cpPinJoint *joint = (cpPinJoint *)JOINT(self);
|
42
|
-
cpPinJointInit(joint, BODY(a), BODY(b), *VGET(anchr1), *VGET(anchr2));
|
43
|
-
rb_iv_set(self, "body_a", a);
|
44
|
-
rb_iv_set(self, "body_b", b);
|
45
|
-
|
46
|
-
return self;
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
static VALUE
|
51
|
-
rb_cpSlideJointAlloc(VALUE klass)
|
52
|
-
{
|
53
|
-
cpSlideJoint *joint = cpSlideJointAlloc();
|
54
|
-
VALUE self = Data_Wrap_Struct(klass, NULL, cpJointFree, joint);
|
55
|
-
|
56
|
-
return self;
|
57
|
-
}
|
58
|
-
|
59
|
-
static VALUE
|
60
|
-
rb_cpSlideJointInit(VALUE self, VALUE a, VALUE b, VALUE anchr1, VALUE anchr2, VALUE min, VALUE max)
|
61
|
-
{
|
62
|
-
cpSlideJoint *joint = (cpSlideJoint *)JOINT(self);
|
63
|
-
cpSlideJointInit(joint, BODY(a), BODY(b), *VGET(anchr1), *VGET(anchr2), NUM2DBL(min), NUM2DBL(max));
|
64
|
-
rb_iv_set(self, "body_a", a);
|
65
|
-
rb_iv_set(self, "body_b", b);
|
66
|
-
|
67
|
-
return self;
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
static VALUE
|
72
|
-
rb_cpPivotJointAlloc(VALUE klass)
|
73
|
-
{
|
74
|
-
cpPivotJoint *joint = cpPivotJointAlloc();
|
75
|
-
VALUE self = Data_Wrap_Struct(klass, NULL, cpJointFree, joint);
|
76
|
-
|
77
|
-
return self;
|
78
|
-
}
|
79
|
-
|
80
|
-
static VALUE
|
81
|
-
rb_cpPivotJointInit(VALUE self, VALUE a, VALUE b, VALUE pivot)
|
82
|
-
{
|
83
|
-
cpPivotJoint *joint = (cpPivotJoint *)JOINT(self);
|
84
|
-
cpPivotJointInit(joint, BODY(a), BODY(b), *VGET(pivot));
|
85
|
-
rb_iv_set(self, "body_a", a);
|
86
|
-
rb_iv_set(self, "body_b", b);
|
87
|
-
|
88
|
-
return self;
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
static VALUE
|
93
|
-
rb_cpGrooveJointAlloc(VALUE klass)
|
94
|
-
{
|
95
|
-
cpGrooveJoint *joint = cpGrooveJointAlloc();
|
96
|
-
VALUE self = Data_Wrap_Struct(klass, NULL, cpJointFree, joint);
|
97
|
-
|
98
|
-
return self;
|
99
|
-
}
|
100
|
-
|
101
|
-
static VALUE
|
102
|
-
rb_cpGrooveJointInit(VALUE self, VALUE a, VALUE b, VALUE grv_a, VALUE grv_b, VALUE anchr2)
|
103
|
-
{
|
104
|
-
cpGrooveJoint *joint = (cpGrooveJoint *)JOINT(self);
|
105
|
-
cpGrooveJointInit(joint, BODY(a), BODY(b), *VGET(grv_a), *VGET(grv_b), *VGET(anchr2));
|
106
|
-
rb_iv_set(self, "body_a", a);
|
107
|
-
rb_iv_set(self, "body_b", b);
|
108
|
-
|
109
|
-
return self;
|
110
|
-
}
|
111
|
-
|
112
|
-
void
|
113
|
-
Init_cpJoint(void)
|
114
|
-
{
|
115
|
-
m_cpJoint = rb_define_module_under(m_Chipmunk, "Joint");
|
116
|
-
|
117
|
-
VALUE c_cpPinJoint = rb_define_class_under(m_cpJoint, "Pin", rb_cObject);
|
118
|
-
rb_include_module(c_cpPinJoint, m_cpJoint);
|
119
|
-
rb_define_alloc_func(c_cpPinJoint, rb_cpPinJointAlloc);
|
120
|
-
rb_define_method(c_cpPinJoint, "initialize", rb_cpPinJointInit, 4);
|
121
|
-
|
122
|
-
VALUE c_cpSlideJoint = rb_define_class_under(m_cpJoint, "Slide", rb_cObject);
|
123
|
-
rb_include_module(c_cpSlideJoint, m_cpJoint);
|
124
|
-
rb_define_alloc_func(c_cpSlideJoint, rb_cpSlideJointAlloc);
|
125
|
-
rb_define_method(c_cpSlideJoint, "initialize", rb_cpSlideJointInit, 6);
|
126
|
-
|
127
|
-
VALUE c_cpPivotJoint = rb_define_class_under(m_cpJoint, "Pivot", rb_cObject);
|
128
|
-
rb_include_module(c_cpPivotJoint, m_cpJoint);
|
129
|
-
rb_define_alloc_func(c_cpPivotJoint, rb_cpPivotJointAlloc);
|
130
|
-
rb_define_method(c_cpPivotJoint, "initialize", rb_cpPivotJointInit, 3);
|
131
|
-
|
132
|
-
VALUE c_cpGrooveJoint = rb_define_class_under(m_cpJoint, "Groove", rb_cObject);
|
133
|
-
rb_include_module(c_cpGrooveJoint, m_cpJoint);
|
134
|
-
rb_define_alloc_func(c_cpGrooveJoint, rb_cpGrooveJointAlloc);
|
135
|
-
rb_define_method(c_cpGrooveJoint, "initialize", rb_cpGrooveJointInit, 5);
|
136
|
-
}
|