chipmunk 4.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README +60 -0
- data/Rakefile +47 -40
- data/ext/chipmunk/chipmunk.c +39 -3
- data/ext/chipmunk/cpArbiter.c +91 -80
- data/ext/chipmunk/cpArray.c +24 -10
- data/ext/chipmunk/cpBB.c +5 -4
- data/ext/chipmunk/cpBody.c +30 -22
- data/ext/chipmunk/cpCollision.c +54 -53
- data/ext/chipmunk/cpConstraint.c +54 -0
- data/ext/chipmunk/cpDampedRotarySpring.c +106 -0
- data/ext/chipmunk/cpDampedSpring.c +117 -0
- data/ext/chipmunk/cpGearJoint.c +114 -0
- data/ext/chipmunk/cpGrooveJoint.c +138 -0
- data/ext/chipmunk/cpHashSet.c +74 -40
- data/ext/chipmunk/cpPinJoint.c +117 -0
- data/ext/chipmunk/cpPivotJoint.c +114 -0
- data/ext/chipmunk/cpPolyShape.c +117 -15
- data/ext/chipmunk/cpRatchetJoint.c +128 -0
- data/ext/chipmunk/cpRotaryLimitJoint.c +122 -0
- data/ext/chipmunk/cpShape.c +174 -18
- data/ext/chipmunk/cpSimpleMotor.c +99 -0
- data/ext/chipmunk/cpSlideJoint.c +131 -0
- data/ext/chipmunk/cpSpace.c +584 -215
- data/ext/chipmunk/cpSpaceHash.c +191 -105
- data/ext/chipmunk/cpVect.c +18 -10
- data/ext/chipmunk/extconf.rb +34 -4
- data/ext/chipmunk/{chipmunk.h → include/chipmunk/chipmunk.h} +63 -6
- data/ext/chipmunk/include/chipmunk/chipmunk_ffi.h +42 -0
- data/ext/chipmunk/include/chipmunk/chipmunk_types.h +80 -0
- data/ext/chipmunk/include/chipmunk/chipmunk_unsafe.h +54 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpConstraint.h +92 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +46 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +53 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpGearJoint.h +41 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +44 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpPinJoint.h +43 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +42 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +40 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +39 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +37 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +44 -0
- data/ext/chipmunk/include/chipmunk/constraints/util.h +116 -0
- data/ext/chipmunk/{cpArbiter.h → include/chipmunk/cpArbiter.h} +66 -15
- data/ext/chipmunk/{cpArray.h → include/chipmunk/cpArray.h} +2 -1
- data/ext/chipmunk/{cpBB.h → include/chipmunk/cpBB.h} +21 -0
- data/ext/chipmunk/{cpBody.h → include/chipmunk/cpBody.h} +37 -9
- data/ext/chipmunk/{cpCollision.h → include/chipmunk/cpCollision.h} +1 -1
- data/ext/chipmunk/{cpHashSet.h → include/chipmunk/cpHashSet.h} +12 -9
- data/ext/chipmunk/{cpPolyShape.h → include/chipmunk/cpPolyShape.h} +13 -2
- data/ext/chipmunk/{cpShape.h → include/chipmunk/cpShape.h} +51 -18
- data/ext/chipmunk/include/chipmunk/cpSpace.h +180 -0
- data/ext/chipmunk/{cpSpaceHash.h → include/chipmunk/cpSpaceHash.h} +18 -9
- data/ext/chipmunk/{cpVect.h → include/chipmunk/cpVect.h} +61 -10
- data/ext/chipmunk/prime.h +32 -32
- data/ext/chipmunk/rb_chipmunk.c +125 -109
- data/ext/chipmunk/rb_chipmunk.h +96 -77
- data/ext/chipmunk/rb_cpArbiter.c +225 -0
- data/ext/chipmunk/rb_cpBB.c +174 -154
- data/ext/chipmunk/rb_cpBody.c +347 -239
- data/ext/chipmunk/rb_cpConstraint.c +346 -0
- data/ext/chipmunk/rb_cpShape.c +455 -292
- data/ext/chipmunk/rb_cpSpace.c +544 -330
- data/ext/chipmunk/rb_cpVect.c +321 -250
- data/lib/chipmunk.rb +28 -15
- data/lib/chipmunk/version.rb +3 -0
- metadata +74 -34
- data/ext/chipmunk/cpJoint.c +0 -553
- data/ext/chipmunk/cpJoint.h +0 -122
- data/ext/chipmunk/cpSpace.h +0 -120
- data/ext/chipmunk/rb_cpJoint.c +0 -136
data/ext/chipmunk/cpJoint.h
DELETED
@@ -1,122 +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_joint_bias_coef;
|
25
|
-
|
26
|
-
typedef enum cpJointType {
|
27
|
-
CP_PIN_JOINT,
|
28
|
-
CP_PIVOT_JOINT,
|
29
|
-
CP_SLIDE_JOINT,
|
30
|
-
CP_GROOVE_JOINT,
|
31
|
-
CP_CUSTOM_JOINT, // For user definable joint types.
|
32
|
-
} cpJointType;
|
33
|
-
|
34
|
-
struct cpJoint;
|
35
|
-
struct cpJointClass;
|
36
|
-
|
37
|
-
typedef struct cpJointClass {
|
38
|
-
cpJointType type;
|
39
|
-
|
40
|
-
void (*preStep)(struct cpJoint *joint, cpFloat dt_inv);
|
41
|
-
void (*applyImpulse)(struct cpJoint *joint);
|
42
|
-
} cpJointClass;
|
43
|
-
|
44
|
-
typedef struct cpJoint {
|
45
|
-
const cpJointClass *klass;
|
46
|
-
|
47
|
-
cpBody *a, *b;
|
48
|
-
} cpJoint;
|
49
|
-
|
50
|
-
void cpJointDestroy(cpJoint *joint);
|
51
|
-
void cpJointFree(cpJoint *joint);
|
52
|
-
|
53
|
-
|
54
|
-
typedef struct cpPinJoint {
|
55
|
-
cpJoint joint;
|
56
|
-
cpVect anchr1, anchr2;
|
57
|
-
cpFloat dist;
|
58
|
-
|
59
|
-
cpVect r1, r2;
|
60
|
-
cpVect n;
|
61
|
-
cpFloat nMass;
|
62
|
-
|
63
|
-
cpFloat jnAcc, jBias;
|
64
|
-
cpFloat bias;
|
65
|
-
} cpPinJoint;
|
66
|
-
|
67
|
-
cpPinJoint *cpPinJointAlloc(void);
|
68
|
-
cpPinJoint *cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
|
69
|
-
cpJoint *cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
|
70
|
-
|
71
|
-
|
72
|
-
typedef struct cpSlideJoint {
|
73
|
-
cpJoint joint;
|
74
|
-
cpVect anchr1, anchr2;
|
75
|
-
cpFloat min, max;
|
76
|
-
|
77
|
-
cpVect r1, r2;
|
78
|
-
cpVect n;
|
79
|
-
cpFloat nMass;
|
80
|
-
|
81
|
-
cpFloat jnAcc, jBias;
|
82
|
-
cpFloat bias;
|
83
|
-
} cpSlideJoint;
|
84
|
-
|
85
|
-
cpSlideJoint *cpSlideJointAlloc(void);
|
86
|
-
cpSlideJoint *cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max);
|
87
|
-
cpJoint *cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max);
|
88
|
-
|
89
|
-
|
90
|
-
typedef struct cpPivotJoint {
|
91
|
-
cpJoint joint;
|
92
|
-
cpVect anchr1, anchr2;
|
93
|
-
|
94
|
-
cpVect r1, r2;
|
95
|
-
cpVect k1, k2;
|
96
|
-
|
97
|
-
cpVect jAcc, jBias;
|
98
|
-
cpVect bias;
|
99
|
-
} cpPivotJoint;
|
100
|
-
|
101
|
-
cpPivotJoint *cpPivotJointAlloc(void);
|
102
|
-
cpPivotJoint *cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect pivot);
|
103
|
-
cpJoint *cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot);
|
104
|
-
|
105
|
-
|
106
|
-
typedef struct cpGrooveJoint {
|
107
|
-
cpJoint joint;
|
108
|
-
cpVect grv_n, grv_a, grv_b;
|
109
|
-
cpVect anchr2;
|
110
|
-
|
111
|
-
cpVect grv_tn;
|
112
|
-
cpFloat clamp;
|
113
|
-
cpVect r1, r2;
|
114
|
-
cpVect k1, k2;
|
115
|
-
|
116
|
-
cpVect jAcc, jBias;
|
117
|
-
cpVect bias;
|
118
|
-
} cpGrooveJoint;
|
119
|
-
|
120
|
-
cpGrooveJoint *cpGrooveJointAlloc(void);
|
121
|
-
cpGrooveJoint *cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
|
122
|
-
cpJoint *cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
|
data/ext/chipmunk/cpSpace.h
DELETED
@@ -1,120 +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
|
-
// Number of frames that contact information should persist.
|
23
|
-
extern int cp_contact_persistence;
|
24
|
-
|
25
|
-
// User collision pair function.
|
26
|
-
typedef int (*cpCollFunc)(cpShape *a, cpShape *b, cpContact *contacts, int numContacts, cpFloat normal_coef, void *data);
|
27
|
-
|
28
|
-
// Structure for holding collision pair function information.
|
29
|
-
// Used internally.
|
30
|
-
typedef struct cpCollPairFunc {
|
31
|
-
unsigned int a;
|
32
|
-
unsigned int b;
|
33
|
-
cpCollFunc func;
|
34
|
-
void *data;
|
35
|
-
} cpCollPairFunc;
|
36
|
-
|
37
|
-
typedef struct cpSpace{
|
38
|
-
// *** User definable fields
|
39
|
-
|
40
|
-
// Number of iterations to use in the impulse solver to solve contacts.
|
41
|
-
int iterations;
|
42
|
-
|
43
|
-
// Number of iterations to use in the impulse solver to solve elastic collisions.
|
44
|
-
int elasticIterations;
|
45
|
-
|
46
|
-
// Default gravity to supply when integrating rigid body motions.
|
47
|
-
cpVect gravity;
|
48
|
-
|
49
|
-
// Default damping to supply when integrating rigid body motions.
|
50
|
-
cpFloat damping;
|
51
|
-
|
52
|
-
// *** Internally Used Fields
|
53
|
-
|
54
|
-
// Time stamp. Is incremented on every call to cpSpaceStep().
|
55
|
-
int stamp;
|
56
|
-
|
57
|
-
// The static and active shape spatial hashes.
|
58
|
-
cpSpaceHash *staticShapes;
|
59
|
-
cpSpaceHash *activeShapes;
|
60
|
-
|
61
|
-
// List of bodies in the system.
|
62
|
-
cpArray *bodies;
|
63
|
-
// List of active arbiters for the impulse solver.
|
64
|
-
cpArray *arbiters;
|
65
|
-
// Persistant contact set.
|
66
|
-
cpHashSet *contactSet;
|
67
|
-
|
68
|
-
// List of joints in the system.
|
69
|
-
cpArray *joints;
|
70
|
-
|
71
|
-
// Set of collisionpair functions.
|
72
|
-
cpHashSet *collFuncSet;
|
73
|
-
// Default collision pair function.
|
74
|
-
cpCollPairFunc defaultPairFunc;
|
75
|
-
} cpSpace;
|
76
|
-
|
77
|
-
// Basic allocation/destruction functions.
|
78
|
-
cpSpace* cpSpaceAlloc(void);
|
79
|
-
cpSpace* cpSpaceInit(cpSpace *space);
|
80
|
-
cpSpace* cpSpaceNew(void);
|
81
|
-
|
82
|
-
void cpSpaceDestroy(cpSpace *space);
|
83
|
-
void cpSpaceFree(cpSpace *space);
|
84
|
-
|
85
|
-
// Convenience function. Frees all referenced entities. (bodies, shapes and joints)
|
86
|
-
void cpSpaceFreeChildren(cpSpace *space);
|
87
|
-
|
88
|
-
// Collision pair function management functions.
|
89
|
-
void cpSpaceAddCollisionPairFunc(cpSpace *space, unsigned int a, unsigned int b,
|
90
|
-
cpCollFunc func, void *data);
|
91
|
-
void cpSpaceRemoveCollisionPairFunc(cpSpace *space, unsigned int a, unsigned int b);
|
92
|
-
void cpSpaceSetDefaultCollisionPairFunc(cpSpace *space, cpCollFunc func, void *data);
|
93
|
-
|
94
|
-
// Add and remove entities from the system.
|
95
|
-
void cpSpaceAddShape(cpSpace *space, cpShape *shape);
|
96
|
-
void cpSpaceAddStaticShape(cpSpace *space, cpShape *shape);
|
97
|
-
void cpSpaceAddBody(cpSpace *space, cpBody *body);
|
98
|
-
void cpSpaceAddJoint(cpSpace *space, cpJoint *joint);
|
99
|
-
|
100
|
-
void cpSpaceRemoveShape(cpSpace *space, cpShape *shape);
|
101
|
-
void cpSpaceRemoveStaticShape(cpSpace *space, cpShape *shape);
|
102
|
-
void cpSpaceRemoveBody(cpSpace *space, cpBody *body);
|
103
|
-
void cpSpaceRemoveJoint(cpSpace *space, cpJoint *joint);
|
104
|
-
|
105
|
-
// Point query callback function
|
106
|
-
typedef void (*cpSpacePointQueryFunc)(cpShape *shape, void *data);
|
107
|
-
void cpSpaceShapePointQuery(cpSpace *space, cpVect point, cpSpacePointQueryFunc func, void *data);
|
108
|
-
void cpSpaceStaticShapePointQuery(cpSpace *space, cpVect point, cpSpacePointQueryFunc func, void *data);
|
109
|
-
|
110
|
-
// Iterator function for iterating the bodies in a space.
|
111
|
-
typedef void (*cpSpaceBodyIterator)(cpBody *body, void *data);
|
112
|
-
void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIterator func, void *data);
|
113
|
-
|
114
|
-
// Spatial hash management functions.
|
115
|
-
void cpSpaceResizeStaticHash(cpSpace *space, cpFloat dim, int count);
|
116
|
-
void cpSpaceResizeActiveHash(cpSpace *space, cpFloat dim, int count);
|
117
|
-
void cpSpaceRehashStatic(cpSpace *space);
|
118
|
-
|
119
|
-
// Update the space.
|
120
|
-
void cpSpaceStep(cpSpace *space, cpFloat dt);
|
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
|
-
}
|