chipmunk 5.3.4.5 → 6.1.3.0.rc1

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.
Files changed (73) hide show
  1. data/ext/chipmunk/chipmunk.c +199 -28
  2. data/ext/chipmunk/chipmunk.h +123 -68
  3. data/ext/chipmunk/chipmunk_ffi.h +129 -11
  4. data/ext/chipmunk/chipmunk_private.h +232 -16
  5. data/ext/chipmunk/chipmunk_types.h +94 -30
  6. data/ext/chipmunk/chipmunk_unsafe.h +12 -3
  7. data/ext/chipmunk/constraints/cpConstraint.h +90 -34
  8. data/ext/chipmunk/{cpDampedRotarySpring.h → constraints/cpDampedRotarySpring.h} +18 -8
  9. data/ext/chipmunk/{cpDampedSpring.h → constraints/cpDampedSpring.h} +27 -16
  10. data/ext/chipmunk/constraints/cpGearJoint.h +17 -7
  11. data/ext/chipmunk/constraints/cpGrooveJoint.h +19 -10
  12. data/ext/chipmunk/constraints/cpPinJoint.h +17 -8
  13. data/ext/chipmunk/constraints/cpPivotJoint.h +18 -9
  14. data/ext/chipmunk/constraints/cpRatchetJoint.h +17 -8
  15. data/ext/chipmunk/constraints/cpRotaryLimitJoint.h +16 -7
  16. data/ext/chipmunk/{cpSimpleMotor.h → constraints/cpSimpleMotor.h} +15 -6
  17. data/ext/chipmunk/constraints/cpSlideJoint.h +18 -9
  18. data/ext/chipmunk/constraints/util.h +36 -44
  19. data/ext/chipmunk/cpArbiter.c +159 -94
  20. data/ext/chipmunk/cpArbiter.h +135 -129
  21. data/ext/chipmunk/cpArray.c +37 -56
  22. data/ext/chipmunk/cpBB.c +1 -12
  23. data/ext/chipmunk/cpBB.h +80 -18
  24. data/ext/chipmunk/cpBBTree.c +891 -0
  25. data/ext/chipmunk/cpBody.c +185 -47
  26. data/ext/chipmunk/cpBody.h +156 -124
  27. data/ext/chipmunk/cpCollision.c +126 -115
  28. data/ext/chipmunk/cpConstraint.c +10 -6
  29. data/ext/chipmunk/cpDampedRotarySpring.c +26 -17
  30. data/ext/chipmunk/cpDampedSpring.c +25 -18
  31. data/ext/chipmunk/cpGearJoint.c +23 -17
  32. data/ext/chipmunk/cpGrooveJoint.c +26 -22
  33. data/ext/chipmunk/cpHashSet.c +51 -51
  34. data/ext/chipmunk/cpPinJoint.c +26 -19
  35. data/ext/chipmunk/cpPivotJoint.c +23 -19
  36. data/ext/chipmunk/cpPolyShape.c +93 -69
  37. data/ext/chipmunk/cpPolyShape.h +33 -69
  38. data/ext/chipmunk/cpRatchetJoint.c +26 -21
  39. data/ext/chipmunk/cpRotaryLimitJoint.c +28 -22
  40. data/ext/chipmunk/cpShape.c +122 -133
  41. data/ext/chipmunk/cpShape.h +146 -95
  42. data/ext/chipmunk/cpSimpleMotor.c +24 -17
  43. data/ext/chipmunk/cpSlideJoint.c +28 -26
  44. data/ext/chipmunk/cpSpace.c +251 -196
  45. data/ext/chipmunk/cpSpace.h +173 -103
  46. data/ext/chipmunk/cpSpaceComponent.c +236 -159
  47. data/ext/chipmunk/cpSpaceHash.c +259 -159
  48. data/ext/chipmunk/cpSpaceQuery.c +127 -59
  49. data/ext/chipmunk/cpSpaceStep.c +235 -197
  50. data/ext/chipmunk/cpSpatialIndex.c +69 -0
  51. data/ext/chipmunk/cpSpatialIndex.h +227 -0
  52. data/ext/chipmunk/cpSweep1D.c +254 -0
  53. data/ext/chipmunk/cpVect.c +11 -26
  54. data/ext/chipmunk/cpVect.h +76 -71
  55. data/ext/chipmunk/extconf.rb +4 -31
  56. data/ext/chipmunk/prime.h +1 -1
  57. data/ext/chipmunk/rb_chipmunk.c +36 -45
  58. data/ext/chipmunk/rb_chipmunk.h +6 -3
  59. data/ext/chipmunk/rb_cpArbiter.c +2 -2
  60. data/ext/chipmunk/rb_cpBB.c +116 -35
  61. data/ext/chipmunk/rb_cpBody.c +5 -12
  62. data/ext/chipmunk/rb_cpConstraint.c +144 -9
  63. data/ext/chipmunk/rb_cpShape.c +69 -78
  64. data/ext/chipmunk/rb_cpSpace.c +81 -76
  65. metadata +61 -61
  66. data/LICENSE +0 -22
  67. data/README +0 -110
  68. data/Rakefile +0 -102
  69. data/ext/chipmunk/cpArray.h +0 -49
  70. data/ext/chipmunk/cpCollision.h +0 -28
  71. data/ext/chipmunk/cpHashSet.h +0 -82
  72. data/ext/chipmunk/cpSpaceHash.h +0 -110
  73. 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
- // TODO: Comment me!
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 (*cpConstraintPreStepFunction)(struct cpConstraint *constraint, cpFloat dt, cpFloat dt_inv);
30
- typedef void (*cpConstraintApplyImpulseFunction)(struct cpConstraint *constraint);
31
- typedef cpFloat (*cpConstraintGetImpulseFunction)(struct cpConstraint *constraint);
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
- typedef struct cpConstraintClass {
34
- cpConstraintPreStepFunction preStep;
35
- cpConstraintApplyImpulseFunction applyImpulse;
36
- cpConstraintGetImpulseFunction getImpulse;
37
- } cpConstraintClass;
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
- typedef struct cpConstraint {
46
+ /// Opaque cpConstraint struct.
47
+ struct cpConstraint {
42
48
  CP_PRIVATE(const cpConstraintClass *klass);
43
49
 
44
- cpBody *a, *b;
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
- cpFloat biasCoef;
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
- } cpConstraint;
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
- static inline void
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
- static inline cpFloat
67
- cpConstraintGetImpulse(cpConstraint *constraint)
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
- #define cpConstraintCheckCast(constraint, struct) \
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
- cpDampedRotarySpring *cpDampedRotarySpringAlloc(void);
40
- cpDampedRotarySpring *cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping);
41
- cpConstraint *cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping);
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
- CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, restAngle, RestAngle);
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
- struct cpDampedSpring;
22
+ /// @defgroup cpDampedSpring cpDampedSpring
23
+ /// @{
23
24
 
24
- typedef cpFloat (*cpDampedSpringForceFunc)(struct cpConstraint *spring, cpFloat dist);
25
+ typedef struct cpDampedSpring cpDampedSpring;
25
26
 
26
- const cpConstraintClass *cpDampedSpringGetClass();
27
+ typedef cpFloat (*cpDampedSpringForceFunc)(cpConstraint *spring, cpFloat dist);
27
28
 
28
- typedef struct cpDampedSpring {
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
- } cpDampedSpring;
43
-
44
- cpDampedSpring *cpDampedSpringAlloc(void);
45
- cpDampedSpring *cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping);
46
- cpConstraint *cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping);
47
-
48
- CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr1, Anchr1);
49
- CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr2, Anchr2);
50
- CP_DefineConstraintProperty(cpDampedSpring, cpFloat, restLength, RestLength);
51
- CP_DefineConstraintProperty(cpDampedSpring, cpFloat, stiffness, Stiffness);
52
- CP_DefineConstraintProperty(cpDampedSpring, cpFloat, damping, Damping);
53
- CP_DefineConstraintProperty(cpDampedSpring, cpDampedSpringForceFunc, springForceFunc, SpringForceFunc);
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
- const cpConstraintClass *cpGearJointGetClass();
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, jMax;
36
+ cpFloat jAcc;
33
37
  } cpGearJoint;
34
38
 
35
- cpGearJoint *cpGearJointAlloc(void);
36
- cpGearJoint *cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio);
37
- cpConstraint *cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio);
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
- const cpConstraintClass *cpGrooveJointGetClass();
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
- cpVect k1, k2;
36
+ cpMat2x2 k;
33
37
 
34
38
  cpVect jAcc;
35
- cpFloat jMaxLen;
36
39
  cpVect bias;
37
40
  } cpGrooveJoint;
38
41
 
39
- cpGrooveJoint *cpGrooveJointAlloc(void);
40
- cpGrooveJoint *cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
41
- cpConstraint *cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
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
- const cpConstraintClass *cpPinJointGetClass();
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, jnMax;
37
+ cpFloat jnAcc;
34
38
  cpFloat bias;
35
39
  } cpPinJoint;
36
40
 
37
- cpPinJoint *cpPinJointAlloc(void);
38
- cpPinJoint *cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
39
- cpConstraint *cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
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
- CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr1, Anchr1);
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
- const cpConstraintClass *cpPivotJointGetClass();
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
- cpVect k1, k2;
33
+ cpMat2x2 k;
30
34
 
31
35
  cpVect jAcc;
32
- cpFloat jMaxLen;
33
36
  cpVect bias;
34
37
  } cpPivotJoint;
35
38
 
36
- cpPivotJoint *cpPivotJointAlloc(void);
37
- cpPivotJoint *cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
38
- cpConstraint *cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot);
39
- cpConstraint *cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2);
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
- CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr1, Anchr1);
42
- CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr2, Anchr2);
51
+ /// @}