chipmunk 5.3.4.5 → 6.1.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/chipmunk/chipmunk.c +199 -28
- data/ext/chipmunk/chipmunk.h +123 -68
- data/ext/chipmunk/chipmunk_ffi.h +129 -11
- data/ext/chipmunk/chipmunk_private.h +232 -16
- data/ext/chipmunk/chipmunk_types.h +94 -30
- data/ext/chipmunk/chipmunk_unsafe.h +12 -3
- data/ext/chipmunk/constraints/cpConstraint.h +90 -34
- data/ext/chipmunk/{cpDampedRotarySpring.h → constraints/cpDampedRotarySpring.h} +18 -8
- data/ext/chipmunk/{cpDampedSpring.h → constraints/cpDampedSpring.h} +27 -16
- data/ext/chipmunk/constraints/cpGearJoint.h +17 -7
- data/ext/chipmunk/constraints/cpGrooveJoint.h +19 -10
- data/ext/chipmunk/constraints/cpPinJoint.h +17 -8
- data/ext/chipmunk/constraints/cpPivotJoint.h +18 -9
- data/ext/chipmunk/constraints/cpRatchetJoint.h +17 -8
- data/ext/chipmunk/constraints/cpRotaryLimitJoint.h +16 -7
- data/ext/chipmunk/{cpSimpleMotor.h → constraints/cpSimpleMotor.h} +15 -6
- data/ext/chipmunk/constraints/cpSlideJoint.h +18 -9
- data/ext/chipmunk/constraints/util.h +36 -44
- data/ext/chipmunk/cpArbiter.c +159 -94
- data/ext/chipmunk/cpArbiter.h +135 -129
- data/ext/chipmunk/cpArray.c +37 -56
- data/ext/chipmunk/cpBB.c +1 -12
- data/ext/chipmunk/cpBB.h +80 -18
- data/ext/chipmunk/cpBBTree.c +891 -0
- data/ext/chipmunk/cpBody.c +185 -47
- data/ext/chipmunk/cpBody.h +156 -124
- data/ext/chipmunk/cpCollision.c +126 -115
- data/ext/chipmunk/cpConstraint.c +10 -6
- data/ext/chipmunk/cpDampedRotarySpring.c +26 -17
- data/ext/chipmunk/cpDampedSpring.c +25 -18
- data/ext/chipmunk/cpGearJoint.c +23 -17
- data/ext/chipmunk/cpGrooveJoint.c +26 -22
- data/ext/chipmunk/cpHashSet.c +51 -51
- data/ext/chipmunk/cpPinJoint.c +26 -19
- data/ext/chipmunk/cpPivotJoint.c +23 -19
- data/ext/chipmunk/cpPolyShape.c +93 -69
- data/ext/chipmunk/cpPolyShape.h +33 -69
- data/ext/chipmunk/cpRatchetJoint.c +26 -21
- data/ext/chipmunk/cpRotaryLimitJoint.c +28 -22
- data/ext/chipmunk/cpShape.c +122 -133
- data/ext/chipmunk/cpShape.h +146 -95
- data/ext/chipmunk/cpSimpleMotor.c +24 -17
- data/ext/chipmunk/cpSlideJoint.c +28 -26
- data/ext/chipmunk/cpSpace.c +251 -196
- data/ext/chipmunk/cpSpace.h +173 -103
- data/ext/chipmunk/cpSpaceComponent.c +236 -159
- data/ext/chipmunk/cpSpaceHash.c +259 -159
- data/ext/chipmunk/cpSpaceQuery.c +127 -59
- data/ext/chipmunk/cpSpaceStep.c +235 -197
- data/ext/chipmunk/cpSpatialIndex.c +69 -0
- data/ext/chipmunk/cpSpatialIndex.h +227 -0
- data/ext/chipmunk/cpSweep1D.c +254 -0
- data/ext/chipmunk/cpVect.c +11 -26
- data/ext/chipmunk/cpVect.h +76 -71
- data/ext/chipmunk/extconf.rb +4 -31
- data/ext/chipmunk/prime.h +1 -1
- data/ext/chipmunk/rb_chipmunk.c +36 -45
- data/ext/chipmunk/rb_chipmunk.h +6 -3
- data/ext/chipmunk/rb_cpArbiter.c +2 -2
- data/ext/chipmunk/rb_cpBB.c +116 -35
- data/ext/chipmunk/rb_cpBody.c +5 -12
- data/ext/chipmunk/rb_cpConstraint.c +144 -9
- data/ext/chipmunk/rb_cpShape.c +69 -78
- data/ext/chipmunk/rb_cpSpace.c +81 -76
- metadata +61 -61
- data/LICENSE +0 -22
- data/README +0 -110
- data/Rakefile +0 -102
- data/ext/chipmunk/cpArray.h +0 -49
- data/ext/chipmunk/cpCollision.h +0 -28
- data/ext/chipmunk/cpHashSet.h +0 -82
- data/ext/chipmunk/cpSpaceHash.h +0 -110
- data/lib/chipmunk.rb +0 -194
@@ -19,8 +19,6 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
23
|
-
|
24
22
|
/* This header defines a number of "unsafe" operations on Chipmunk objects.
|
25
23
|
* In this case "unsafe" is referring to operations which may reduce the
|
26
24
|
* physical accuracy or numerical stability of the simulation, but will not
|
@@ -32,6 +30,12 @@
|
|
32
30
|
* persistent velocities. Probably not what you meant, but perhaps close enough.
|
33
31
|
*/
|
34
32
|
|
33
|
+
/// @defgroup unsafe Chipmunk Unsafe Shape Operations
|
34
|
+
/// These functions are used for mutating collision shapes.
|
35
|
+
/// Chipmunk does not have any way to get velocity information on changing shapes,
|
36
|
+
/// so the results will be unrealistic. You must explicity include the chipmunk_unsafe.h header to use them.
|
37
|
+
/// @{
|
38
|
+
|
35
39
|
#ifndef CHIPMUNK_UNSAFE_HEADER
|
36
40
|
#define CHIPMUNK_UNSAFE_HEADER
|
37
41
|
|
@@ -39,16 +43,21 @@
|
|
39
43
|
extern "C" {
|
40
44
|
#endif
|
41
45
|
|
46
|
+
/// Set the radius of a circle shape.
|
42
47
|
void cpCircleShapeSetRadius(cpShape *shape, cpFloat radius);
|
48
|
+
/// Set the offset of a circle shape.
|
43
49
|
void cpCircleShapeSetOffset(cpShape *shape, cpVect offset);
|
44
50
|
|
51
|
+
/// Set the endpoints of a segment shape.
|
45
52
|
void cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b);
|
53
|
+
/// Set the radius of a segment shape.
|
46
54
|
void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius);
|
47
55
|
|
56
|
+
/// Set the vertexes of a poly shape.
|
48
57
|
void cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset);
|
49
58
|
|
50
59
|
#ifdef __cplusplus
|
51
60
|
}
|
52
61
|
#endif
|
53
|
-
|
54
62
|
#endif
|
63
|
+
/// @}
|
@@ -19,80 +19,136 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
extern cpFloat cp_constraint_bias_coef;
|
22
|
+
/// @defgroup cpConstraint cpConstraint
|
23
|
+
/// @{
|
25
24
|
|
26
|
-
struct cpConstraintClass;
|
27
|
-
struct cpConstraint;
|
25
|
+
typedef struct cpConstraintClass cpConstraintClass;
|
28
26
|
|
29
|
-
typedef void (*
|
30
|
-
typedef void (*
|
31
|
-
typedef
|
27
|
+
typedef void (*cpConstraintPreStepImpl)(cpConstraint *constraint, cpFloat dt);
|
28
|
+
typedef void (*cpConstraintApplyCachedImpulseImpl)(cpConstraint *constraint, cpFloat dt_coef);
|
29
|
+
typedef void (*cpConstraintApplyImpulseImpl)(cpConstraint *constraint, cpFloat dt);
|
30
|
+
typedef cpFloat (*cpConstraintGetImpulseImpl)(cpConstraint *constraint);
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
/// @private
|
33
|
+
struct cpConstraintClass {
|
34
|
+
cpConstraintPreStepImpl preStep;
|
35
|
+
cpConstraintApplyCachedImpulseImpl applyCachedImpulse;
|
36
|
+
cpConstraintApplyImpulseImpl applyImpulse;
|
37
|
+
cpConstraintGetImpulseImpl getImpulse;
|
38
|
+
};
|
38
39
|
|
40
|
+
/// Callback function type that gets called before solving a joint.
|
41
|
+
typedef void (*cpConstraintPreSolveFunc)(cpConstraint *constraint, cpSpace *space);
|
42
|
+
/// Callback function type that gets called after solving a joint.
|
43
|
+
typedef void (*cpConstraintPostSolveFunc)(cpConstraint *constraint, cpSpace *space);
|
39
44
|
|
40
45
|
|
41
|
-
|
46
|
+
/// Opaque cpConstraint struct.
|
47
|
+
struct cpConstraint {
|
42
48
|
CP_PRIVATE(const cpConstraintClass *klass);
|
43
49
|
|
44
|
-
|
50
|
+
/// The first body connected to this constraint.
|
51
|
+
cpBody *a;
|
52
|
+
/// The second body connected to this constraint.
|
53
|
+
cpBody *b;
|
54
|
+
|
55
|
+
CP_PRIVATE(cpSpace *space);
|
56
|
+
|
57
|
+
CP_PRIVATE(cpConstraint *next_a);
|
58
|
+
CP_PRIVATE(cpConstraint *next_b);
|
59
|
+
|
60
|
+
/// The maximum force that this constraint is allowed to use.
|
61
|
+
/// Defaults to infinity.
|
45
62
|
cpFloat maxForce;
|
46
|
-
|
63
|
+
/// The rate at which joint error is corrected.
|
64
|
+
/// Defaults to pow(1.0 - 0.1, 60.0) meaning that it will
|
65
|
+
/// correct 10% of the error every 1/60th of a second.
|
66
|
+
cpFloat errorBias;
|
67
|
+
/// The maximum rate at which joint error is corrected.
|
68
|
+
/// Defaults to infinity.
|
47
69
|
cpFloat maxBias;
|
48
70
|
|
71
|
+
/// Function called before the solver runs.
|
72
|
+
/// Animate your joint anchors, update your motor torque, etc.
|
73
|
+
cpConstraintPreSolveFunc preSolve;
|
74
|
+
|
75
|
+
/// Function called after the solver runs.
|
76
|
+
/// Use the applied impulse to perform effects like breakable joints.
|
77
|
+
cpConstraintPostSolveFunc postSolve;
|
78
|
+
|
79
|
+
/// User definable data pointer.
|
80
|
+
/// Generally this points to your the game object class so you can access it
|
81
|
+
/// when given a cpConstraint reference in a callback.
|
49
82
|
cpDataPointer data;
|
50
|
-
}
|
51
|
-
|
52
|
-
#ifdef CP_USE_DEPRECATED_API_4
|
53
|
-
typedef cpConstraint cpJoint;
|
54
|
-
#endif
|
83
|
+
};
|
55
84
|
|
85
|
+
/// Destroy a constraint.
|
56
86
|
void cpConstraintDestroy(cpConstraint *constraint);
|
87
|
+
/// Destroy and free a constraint.
|
57
88
|
void cpConstraintFree(cpConstraint *constraint);
|
58
89
|
|
59
|
-
|
60
|
-
cpConstraintActivateBodies(cpConstraint *constraint)
|
90
|
+
/// @private
|
91
|
+
static inline void cpConstraintActivateBodies(cpConstraint *constraint)
|
61
92
|
{
|
62
93
|
cpBody *a = constraint->a; if(a) cpBodyActivate(a);
|
63
94
|
cpBody *b = constraint->b; if(b) cpBodyActivate(b);
|
64
95
|
}
|
65
96
|
|
66
|
-
|
67
|
-
|
97
|
+
/// @private
|
98
|
+
#define CP_DefineConstraintStructGetter(type, member, name) \
|
99
|
+
static inline type cpConstraint##Get##name(const cpConstraint *constraint){return constraint->member;}
|
100
|
+
|
101
|
+
/// @private
|
102
|
+
#define CP_DefineConstraintStructSetter(type, member, name) \
|
103
|
+
static inline void cpConstraint##Set##name(cpConstraint *constraint, type value){ \
|
104
|
+
cpConstraintActivateBodies(constraint); \
|
105
|
+
constraint->member = value; \
|
106
|
+
}
|
107
|
+
|
108
|
+
/// @private
|
109
|
+
#define CP_DefineConstraintStructProperty(type, member, name) \
|
110
|
+
CP_DefineConstraintStructGetter(type, member, name) \
|
111
|
+
CP_DefineConstraintStructSetter(type, member, name)
|
112
|
+
|
113
|
+
CP_DefineConstraintStructGetter(cpSpace*, CP_PRIVATE(space), Space)
|
114
|
+
|
115
|
+
CP_DefineConstraintStructGetter(cpBody*, a, A)
|
116
|
+
CP_DefineConstraintStructGetter(cpBody*, b, B)
|
117
|
+
CP_DefineConstraintStructProperty(cpFloat, maxForce, MaxForce)
|
118
|
+
CP_DefineConstraintStructProperty(cpFloat, errorBias, ErrorBias)
|
119
|
+
CP_DefineConstraintStructProperty(cpFloat, maxBias, MaxBias)
|
120
|
+
CP_DefineConstraintStructProperty(cpConstraintPreSolveFunc, preSolve, PreSolveFunc)
|
121
|
+
CP_DefineConstraintStructProperty(cpConstraintPostSolveFunc, postSolve, PostSolveFunc)
|
122
|
+
CP_DefineConstraintStructProperty(cpDataPointer, data, UserData)
|
123
|
+
|
124
|
+
// Get the last impulse applied by this constraint.
|
125
|
+
static inline cpFloat cpConstraintGetImpulse(cpConstraint *constraint)
|
68
126
|
{
|
69
127
|
return constraint->CP_PRIVATE(klass)->getImpulse(constraint);
|
70
128
|
}
|
71
129
|
|
72
|
-
|
73
|
-
cpAssert(constraint->CP_PRIVATE(klass) == struct##GetClass(), "Constraint is not a "#struct);
|
130
|
+
/// @}
|
74
131
|
|
132
|
+
#define cpConstraintCheckCast(constraint, struct) \
|
133
|
+
cpAssertHard(constraint->CP_PRIVATE(klass) == struct##GetClass(), "Constraint is not a "#struct)
|
75
134
|
|
76
135
|
#define CP_DefineConstraintGetter(struct, type, member, name) \
|
77
|
-
static inline type \
|
78
|
-
struct##Get##name(const cpConstraint *constraint){ \
|
136
|
+
static inline type struct##Get##name(const cpConstraint *constraint){ \
|
79
137
|
cpConstraintCheckCast(constraint, struct); \
|
80
138
|
return ((struct *)constraint)->member; \
|
81
|
-
}
|
139
|
+
}
|
82
140
|
|
83
141
|
#define CP_DefineConstraintSetter(struct, type, member, name) \
|
84
|
-
static inline void \
|
85
|
-
struct##Set##name(cpConstraint *constraint, type value){ \
|
142
|
+
static inline void struct##Set##name(cpConstraint *constraint, type value){ \
|
86
143
|
cpConstraintCheckCast(constraint, struct); \
|
87
144
|
cpConstraintActivateBodies(constraint); \
|
88
145
|
((struct *)constraint)->member = value; \
|
89
|
-
}
|
146
|
+
}
|
90
147
|
|
91
148
|
#define CP_DefineConstraintProperty(struct, type, member, name) \
|
92
149
|
CP_DefineConstraintGetter(struct, type, member, name) \
|
93
150
|
CP_DefineConstraintSetter(struct, type, member, name)
|
94
151
|
|
95
|
-
// Built in Joint types
|
96
152
|
#include "cpPinJoint.h"
|
97
153
|
#include "cpSlideJoint.h"
|
98
154
|
#include "cpPivotJoint.h"
|
@@ -19,10 +19,14 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
+
/// @defgroup cpDampedRotarySpring cpDampedRotarySpring
|
23
|
+
/// @{
|
24
|
+
|
22
25
|
typedef cpFloat (*cpDampedRotarySpringTorqueFunc)(struct cpConstraint *spring, cpFloat relativeAngle);
|
23
26
|
|
24
|
-
const cpConstraintClass *cpDampedRotarySpringGetClass();
|
27
|
+
const cpConstraintClass *cpDampedRotarySpringGetClass(void);
|
25
28
|
|
29
|
+
/// @private
|
26
30
|
typedef struct cpDampedRotarySpring {
|
27
31
|
cpConstraint constraint;
|
28
32
|
cpFloat restAngle;
|
@@ -34,13 +38,19 @@ typedef struct cpDampedRotarySpring {
|
|
34
38
|
cpFloat w_coef;
|
35
39
|
|
36
40
|
cpFloat iSum;
|
41
|
+
cpFloat jAcc;
|
37
42
|
} cpDampedRotarySpring;
|
38
43
|
|
39
|
-
|
40
|
-
cpDampedRotarySpring
|
41
|
-
|
44
|
+
/// Allocate a damped rotary spring.
|
45
|
+
cpDampedRotarySpring* cpDampedRotarySpringAlloc(void);
|
46
|
+
/// Initialize a damped rotary spring.
|
47
|
+
cpDampedRotarySpring* cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping);
|
48
|
+
/// Allocate and initialize a damped rotary spring.
|
49
|
+
cpConstraint* cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping);
|
50
|
+
|
51
|
+
CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, restAngle, RestAngle)
|
52
|
+
CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, stiffness, Stiffness)
|
53
|
+
CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, damping, Damping)
|
54
|
+
CP_DefineConstraintProperty(cpDampedRotarySpring, cpDampedRotarySpringTorqueFunc, springTorqueFunc, SpringTorqueFunc)
|
42
55
|
|
43
|
-
|
44
|
-
CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, stiffness, Stiffness);
|
45
|
-
CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, damping, Damping);
|
46
|
-
CP_DefineConstraintProperty(cpDampedRotarySpring, cpDampedRotarySpringTorqueFunc, springTorqueFunc, SpringTorqueFunc);
|
56
|
+
/// @}
|
@@ -19,13 +19,17 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
22
|
+
/// @defgroup cpDampedSpring cpDampedSpring
|
23
|
+
/// @{
|
23
24
|
|
24
|
-
typedef
|
25
|
+
typedef struct cpDampedSpring cpDampedSpring;
|
25
26
|
|
26
|
-
|
27
|
+
typedef cpFloat (*cpDampedSpringForceFunc)(cpConstraint *spring, cpFloat dist);
|
27
28
|
|
28
|
-
|
29
|
+
const cpConstraintClass *cpDampedSpringGetClass(void);
|
30
|
+
|
31
|
+
/// @private
|
32
|
+
struct cpDampedSpring {
|
29
33
|
cpConstraint constraint;
|
30
34
|
cpVect anchr1, anchr2;
|
31
35
|
cpFloat restLength;
|
@@ -39,15 +43,22 @@ typedef struct cpDampedSpring {
|
|
39
43
|
cpVect r1, r2;
|
40
44
|
cpFloat nMass;
|
41
45
|
cpVect n;
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
CP_DefineConstraintProperty(cpDampedSpring,
|
46
|
+
|
47
|
+
cpFloat jAcc;
|
48
|
+
};
|
49
|
+
|
50
|
+
/// Allocate a damped spring.
|
51
|
+
cpDampedSpring* cpDampedSpringAlloc(void);
|
52
|
+
/// Initialize a damped spring.
|
53
|
+
cpDampedSpring* cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping);
|
54
|
+
/// Allocate and initialize a damped spring.
|
55
|
+
cpConstraint* cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping);
|
56
|
+
|
57
|
+
CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr1, Anchr1)
|
58
|
+
CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr2, Anchr2)
|
59
|
+
CP_DefineConstraintProperty(cpDampedSpring, cpFloat, restLength, RestLength)
|
60
|
+
CP_DefineConstraintProperty(cpDampedSpring, cpFloat, stiffness, Stiffness)
|
61
|
+
CP_DefineConstraintProperty(cpDampedSpring, cpFloat, damping, Damping)
|
62
|
+
CP_DefineConstraintProperty(cpDampedSpring, cpDampedSpringForceFunc, springForceFunc, SpringForceFunc)
|
63
|
+
|
64
|
+
/// @}
|
@@ -19,8 +19,12 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
22
|
+
/// @defgroup cpGearJoint cpGearJoint
|
23
|
+
/// @{
|
23
24
|
|
25
|
+
const cpConstraintClass *cpGearJointGetClass(void);
|
26
|
+
|
27
|
+
/// @private
|
24
28
|
typedef struct cpGearJoint {
|
25
29
|
cpConstraint constraint;
|
26
30
|
cpFloat phase, ratio;
|
@@ -29,13 +33,19 @@ typedef struct cpGearJoint {
|
|
29
33
|
cpFloat iSum;
|
30
34
|
|
31
35
|
cpFloat bias;
|
32
|
-
cpFloat jAcc
|
36
|
+
cpFloat jAcc;
|
33
37
|
} cpGearJoint;
|
34
38
|
|
35
|
-
|
36
|
-
cpGearJoint
|
37
|
-
|
39
|
+
/// Allocate a gear joint.
|
40
|
+
cpGearJoint* cpGearJointAlloc(void);
|
41
|
+
/// Initialize a gear joint.
|
42
|
+
cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio);
|
43
|
+
/// Allocate and initialize a gear joint.
|
44
|
+
cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio);
|
38
45
|
|
39
|
-
CP_DefineConstraintProperty(cpGearJoint, cpFloat, phase, Phase)
|
40
|
-
CP_DefineConstraintGetter(cpGearJoint, cpFloat, ratio, Ratio)
|
46
|
+
CP_DefineConstraintProperty(cpGearJoint, cpFloat, phase, Phase)
|
47
|
+
CP_DefineConstraintGetter(cpGearJoint, cpFloat, ratio, Ratio)
|
48
|
+
/// Set the ratio of a gear joint.
|
41
49
|
void cpGearJointSetRatio(cpConstraint *constraint, cpFloat value);
|
50
|
+
|
51
|
+
/// @}
|
@@ -19,8 +19,12 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
22
|
+
/// @defgroup cpGrooveJoint cpGrooveJoint
|
23
|
+
/// @{
|
23
24
|
|
25
|
+
const cpConstraintClass *cpGrooveJointGetClass(void);
|
26
|
+
|
27
|
+
/// @private
|
24
28
|
typedef struct cpGrooveJoint {
|
25
29
|
cpConstraint constraint;
|
26
30
|
cpVect grv_n, grv_a, grv_b;
|
@@ -29,20 +33,25 @@ typedef struct cpGrooveJoint {
|
|
29
33
|
cpVect grv_tn;
|
30
34
|
cpFloat clamp;
|
31
35
|
cpVect r1, r2;
|
32
|
-
|
36
|
+
cpMat2x2 k;
|
33
37
|
|
34
38
|
cpVect jAcc;
|
35
|
-
cpFloat jMaxLen;
|
36
39
|
cpVect bias;
|
37
40
|
} cpGrooveJoint;
|
38
41
|
|
39
|
-
|
40
|
-
cpGrooveJoint
|
41
|
-
|
42
|
-
|
42
|
+
/// Allocate a groove joint.
|
43
|
+
cpGrooveJoint* cpGrooveJointAlloc(void);
|
44
|
+
/// Initialize a groove joint.
|
45
|
+
cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
|
46
|
+
/// Allocate and initialize a groove joint.
|
47
|
+
cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
|
43
48
|
|
44
|
-
CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_a, GrooveA)
|
49
|
+
CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_a, GrooveA)
|
50
|
+
/// Set endpoint a of a groove joint's groove
|
45
51
|
void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect value);
|
46
|
-
CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_b, GrooveB)
|
52
|
+
CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_b, GrooveB)
|
53
|
+
/// Set endpoint b of a groove joint's groove
|
47
54
|
void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect value);
|
48
|
-
CP_DefineConstraintProperty(cpGrooveJoint, cpVect, anchr2, Anchr2)
|
55
|
+
CP_DefineConstraintProperty(cpGrooveJoint, cpVect, anchr2, Anchr2)
|
56
|
+
|
57
|
+
/// @}
|
@@ -19,8 +19,12 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
22
|
+
/// @defgroup cpPinJoint cpPinJoint
|
23
|
+
/// @{
|
23
24
|
|
25
|
+
const cpConstraintClass *cpPinJointGetClass(void);
|
26
|
+
|
27
|
+
/// @private
|
24
28
|
typedef struct cpPinJoint {
|
25
29
|
cpConstraint constraint;
|
26
30
|
cpVect anchr1, anchr2;
|
@@ -30,14 +34,19 @@ typedef struct cpPinJoint {
|
|
30
34
|
cpVect n;
|
31
35
|
cpFloat nMass;
|
32
36
|
|
33
|
-
cpFloat jnAcc
|
37
|
+
cpFloat jnAcc;
|
34
38
|
cpFloat bias;
|
35
39
|
} cpPinJoint;
|
36
40
|
|
37
|
-
|
38
|
-
cpPinJoint
|
39
|
-
|
41
|
+
/// Allocate a pin joint.
|
42
|
+
cpPinJoint* cpPinJointAlloc(void);
|
43
|
+
/// Initialize a pin joint.
|
44
|
+
cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
|
45
|
+
/// Allocate and initialize a pin joint.
|
46
|
+
cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
|
47
|
+
|
48
|
+
CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr1, Anchr1)
|
49
|
+
CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr2, Anchr2)
|
50
|
+
CP_DefineConstraintProperty(cpPinJoint, cpFloat, dist, Dist)
|
40
51
|
|
41
|
-
|
42
|
-
CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr2, Anchr2);
|
43
|
-
CP_DefineConstraintProperty(cpPinJoint, cpFloat, dist, Dist);
|
52
|
+
///@}
|
@@ -19,24 +19,33 @@
|
|
19
19
|
* SOFTWARE.
|
20
20
|
*/
|
21
21
|
|
22
|
-
|
22
|
+
/// @defgroup cpPivotJoint cpPivotJoint
|
23
|
+
/// @{
|
23
24
|
|
25
|
+
const cpConstraintClass *cpPivotJointGetClass(void);
|
26
|
+
|
27
|
+
/// @private
|
24
28
|
typedef struct cpPivotJoint {
|
25
29
|
cpConstraint constraint;
|
26
30
|
cpVect anchr1, anchr2;
|
27
31
|
|
28
32
|
cpVect r1, r2;
|
29
|
-
|
33
|
+
cpMat2x2 k;
|
30
34
|
|
31
35
|
cpVect jAcc;
|
32
|
-
cpFloat jMaxLen;
|
33
36
|
cpVect bias;
|
34
37
|
} cpPivotJoint;
|
35
38
|
|
36
|
-
|
37
|
-
cpPivotJoint
|
38
|
-
|
39
|
-
|
39
|
+
/// Allocate a pivot joint
|
40
|
+
cpPivotJoint* cpPivotJointAlloc(void);
|
41
|
+
/// Initialize a pivot joint.
|
42
|
+
cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
|
43
|
+
/// Allocate and initialize a pivot joint.
|
44
|
+
cpConstraint* cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot);
|
45
|
+
/// Allocate and initialize a pivot joint with specific anchors.
|
46
|
+
cpConstraint* cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
|
47
|
+
|
48
|
+
CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr1, Anchr1)
|
49
|
+
CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr2, Anchr2)
|
40
50
|
|
41
|
-
|
42
|
-
CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr2, Anchr2);
|
51
|
+
/// @}
|