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.
Files changed (67) hide show
  1. data/LICENSE +21 -19
  2. data/README +67 -60
  3. data/Rakefile +85 -50
  4. data/ext/chipmunk/extconf.rb +42 -35
  5. data/ext/chipmunk/rb_chipmunk.c +250 -125
  6. data/ext/chipmunk/rb_chipmunk.h +105 -96
  7. data/ext/chipmunk/rb_cpArbiter.c +253 -225
  8. data/ext/chipmunk/rb_cpBB.c +210 -174
  9. data/ext/chipmunk/rb_cpBody.c +504 -347
  10. data/ext/chipmunk/rb_cpConstraint.c +336 -346
  11. data/ext/chipmunk/rb_cpShape.c +433 -455
  12. data/ext/chipmunk/rb_cpSpace.c +711 -544
  13. data/ext/chipmunk/rb_cpVect.c +346 -321
  14. data/lib/chipmunk.rb +183 -30
  15. metadata +12 -66
  16. data/ext/chipmunk/chipmunk.c +0 -105
  17. data/ext/chipmunk/cpArbiter.c +0 -274
  18. data/ext/chipmunk/cpArray.c +0 -128
  19. data/ext/chipmunk/cpBB.c +0 -47
  20. data/ext/chipmunk/cpBody.c +0 -188
  21. data/ext/chipmunk/cpCollision.c +0 -391
  22. data/ext/chipmunk/cpConstraint.c +0 -54
  23. data/ext/chipmunk/cpDampedRotarySpring.c +0 -106
  24. data/ext/chipmunk/cpDampedSpring.c +0 -117
  25. data/ext/chipmunk/cpGearJoint.c +0 -114
  26. data/ext/chipmunk/cpGrooveJoint.c +0 -138
  27. data/ext/chipmunk/cpHashSet.c +0 -253
  28. data/ext/chipmunk/cpPinJoint.c +0 -117
  29. data/ext/chipmunk/cpPivotJoint.c +0 -114
  30. data/ext/chipmunk/cpPolyShape.c +0 -241
  31. data/ext/chipmunk/cpRatchetJoint.c +0 -128
  32. data/ext/chipmunk/cpRotaryLimitJoint.c +0 -122
  33. data/ext/chipmunk/cpShape.c +0 -400
  34. data/ext/chipmunk/cpSimpleMotor.c +0 -99
  35. data/ext/chipmunk/cpSlideJoint.c +0 -131
  36. data/ext/chipmunk/cpSpace.c +0 -899
  37. data/ext/chipmunk/cpSpaceHash.c +0 -541
  38. data/ext/chipmunk/cpVect.c +0 -71
  39. data/ext/chipmunk/include/chipmunk/chipmunk.h +0 -148
  40. data/ext/chipmunk/include/chipmunk/chipmunk_ffi.h +0 -42
  41. data/ext/chipmunk/include/chipmunk/chipmunk_types.h +0 -80
  42. data/ext/chipmunk/include/chipmunk/chipmunk_unsafe.h +0 -54
  43. data/ext/chipmunk/include/chipmunk/constraints/cpConstraint.h +0 -92
  44. data/ext/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +0 -46
  45. data/ext/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +0 -53
  46. data/ext/chipmunk/include/chipmunk/constraints/cpGearJoint.h +0 -41
  47. data/ext/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +0 -44
  48. data/ext/chipmunk/include/chipmunk/constraints/cpPinJoint.h +0 -43
  49. data/ext/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +0 -42
  50. data/ext/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +0 -40
  51. data/ext/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +0 -39
  52. data/ext/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +0 -37
  53. data/ext/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +0 -44
  54. data/ext/chipmunk/include/chipmunk/constraints/util.h +0 -116
  55. data/ext/chipmunk/include/chipmunk/cpArbiter.h +0 -136
  56. data/ext/chipmunk/include/chipmunk/cpArray.h +0 -46
  57. data/ext/chipmunk/include/chipmunk/cpBB.h +0 -74
  58. data/ext/chipmunk/include/chipmunk/cpBody.h +0 -160
  59. data/ext/chipmunk/include/chipmunk/cpCollision.h +0 -23
  60. data/ext/chipmunk/include/chipmunk/cpHashSet.h +0 -82
  61. data/ext/chipmunk/include/chipmunk/cpPolyShape.h +0 -103
  62. data/ext/chipmunk/include/chipmunk/cpShape.h +0 -174
  63. data/ext/chipmunk/include/chipmunk/cpSpace.h +0 -180
  64. data/ext/chipmunk/include/chipmunk/cpSpaceHash.h +0 -109
  65. data/ext/chipmunk/include/chipmunk/cpVect.h +0 -157
  66. data/ext/chipmunk/prime.h +0 -68
  67. data/lib/chipmunk/version.rb +0 -3
@@ -1,46 +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 cpFloat (*cpDampedRotarySpringTorqueFunc)(struct cpConstraint *spring, cpFloat relativeAngle);
23
-
24
- const cpConstraintClass *cpDampedRotarySpringGetClass();
25
-
26
- typedef struct cpDampedRotarySpring {
27
- cpConstraint constraint;
28
- cpFloat restAngle;
29
- cpFloat stiffness;
30
- cpFloat damping;
31
- cpDampedRotarySpringTorqueFunc springTorqueFunc;
32
-
33
- cpFloat dt;
34
- cpFloat target_wrn;
35
-
36
- cpFloat iSum;
37
- } cpDampedRotarySpring;
38
-
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);
42
-
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);
@@ -1,53 +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
- struct cpDampedSpring;
23
-
24
- typedef cpFloat (*cpDampedSpringForceFunc)(struct cpConstraint *spring, cpFloat dist);
25
-
26
- const cpConstraintClass *cpDampedSpringGetClass();
27
-
28
- typedef struct cpDampedSpring {
29
- cpConstraint constraint;
30
- cpVect anchr1, anchr2;
31
- cpFloat restLength;
32
- cpFloat stiffness;
33
- cpFloat damping;
34
- cpDampedSpringForceFunc springForceFunc;
35
-
36
- cpFloat dt;
37
- cpFloat target_vrn;
38
-
39
- cpVect r1, r2;
40
- cpFloat nMass;
41
- 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);
@@ -1,41 +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
- const cpConstraintClass *cpGearJointGetClass();
23
-
24
- typedef struct cpGearJoint {
25
- cpConstraint constraint;
26
- cpFloat phase, ratio;
27
- cpFloat ratio_inv;
28
-
29
- cpFloat iSum;
30
-
31
- cpFloat bias;
32
- cpFloat jAcc, jMax;
33
- } cpGearJoint;
34
-
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);
38
-
39
- CP_DefineConstraintProperty(cpGearJoint, cpFloat, phase, Phase);
40
- CP_DefineConstraintGetter(cpGearJoint, cpFloat, ratio, Ratio);
41
- void cpGearJointSetRatio(cpConstraint *constraint, cpFloat value);
@@ -1,44 +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
- const cpConstraintClass *cpGrooveJointGetClass();
23
-
24
- typedef struct cpGrooveJoint {
25
- cpConstraint constraint;
26
- cpVect grv_n, grv_a, grv_b;
27
- cpVect anchr2;
28
-
29
- cpVect grv_tn;
30
- cpFloat clamp;
31
- cpVect r1, r2;
32
- cpVect k1, k2;
33
-
34
- cpVect jAcc;
35
- cpFloat jMaxLen;
36
- cpVect bias;
37
- } cpGrooveJoint;
38
-
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
-
43
- // TODO setters for the groove.
44
- CP_DefineConstraintProperty(cpGrooveJoint, cpVect, anchr2, Anchr2);
@@ -1,43 +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
- const cpConstraintClass *cpPinJointGetClass();
23
-
24
- typedef struct cpPinJoint {
25
- cpConstraint constraint;
26
- cpVect anchr1, anchr2;
27
- cpFloat dist;
28
-
29
- cpVect r1, r2;
30
- cpVect n;
31
- cpFloat nMass;
32
-
33
- cpFloat jnAcc, jnMax;
34
- cpFloat bias;
35
- } cpPinJoint;
36
-
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);
40
-
41
- CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr1, Anchr1);
42
- CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr2, Anchr2);
43
- CP_DefineConstraintProperty(cpPinJoint, cpFloat, dist, Dist);
@@ -1,42 +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
- const cpConstraintClass *cpPivotJointGetClass();
23
-
24
- typedef struct cpPivotJoint {
25
- cpConstraint constraint;
26
- cpVect anchr1, anchr2;
27
-
28
- cpVect r1, r2;
29
- cpVect k1, k2;
30
-
31
- cpVect jAcc;
32
- cpFloat jMaxLen;
33
- cpVect bias;
34
- } cpPivotJoint;
35
-
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);
40
-
41
- CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr1, Anchr1);
42
- CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr2, Anchr2);
@@ -1,40 +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
- const cpConstraintClass *cpRatchetJointGetClass();
23
-
24
- typedef struct cpRatchetJoint {
25
- cpConstraint constraint;
26
- cpFloat angle, phase, ratchet;
27
-
28
- cpFloat iSum;
29
-
30
- cpFloat bias;
31
- cpFloat jAcc, jMax;
32
- } cpRatchetJoint;
33
-
34
- cpRatchetJoint *cpRatchetJointAlloc(void);
35
- cpRatchetJoint *cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet);
36
- cpConstraint *cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet);
37
-
38
- CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, angle, Angle);
39
- CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, phase, Phase);
40
- CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, ratchet, Ratchet);
@@ -1,39 +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
- const cpConstraintClass *cpRotaryLimitJointGetClass();
23
-
24
- typedef struct cpRotaryLimitJoint {
25
- cpConstraint constraint;
26
- cpFloat min, max;
27
-
28
- cpFloat iSum;
29
-
30
- cpFloat bias;
31
- cpFloat jAcc, jMax;
32
- } cpRotaryLimitJoint;
33
-
34
- cpRotaryLimitJoint *cpRotaryLimitJointAlloc(void);
35
- cpRotaryLimitJoint *cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max);
36
- cpConstraint *cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max);
37
-
38
- CP_DefineConstraintProperty(cpRotaryLimitJoint, cpFloat, min, Min);
39
- CP_DefineConstraintProperty(cpRotaryLimitJoint, cpFloat, max, Max);
@@ -1,37 +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
- const cpConstraintClass *cpSimpleMotorGetClass();
23
-
24
- typedef struct cpSimpleMotor {
25
- cpConstraint constraint;
26
- cpFloat rate;
27
-
28
- cpFloat iSum;
29
-
30
- cpFloat jAcc, jMax;
31
- } cpSimpleMotor;
32
-
33
- cpSimpleMotor *cpSimpleMotorAlloc(void);
34
- cpSimpleMotor *cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate);
35
- cpConstraint *cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate);
36
-
37
- CP_DefineConstraintProperty(cpSimpleMotor, cpFloat, rate, Rate);
@@ -1,44 +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
- const cpConstraintClass *cpSlideJointGetClass();
23
-
24
- typedef struct cpSlideJoint {
25
- cpConstraint constraint;
26
- cpVect anchr1, anchr2;
27
- cpFloat min, max;
28
-
29
- cpVect r1, r2;
30
- cpVect n;
31
- cpFloat nMass;
32
-
33
- cpFloat jnAcc, jnMax;
34
- cpFloat bias;
35
- } cpSlideJoint;
36
-
37
- cpSlideJoint *cpSlideJointAlloc(void);
38
- cpSlideJoint *cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max);
39
- cpConstraint *cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max);
40
-
41
- CP_DefineConstraintProperty(cpSlideJoint, cpVect, anchr1, Anchr1);
42
- CP_DefineConstraintProperty(cpSlideJoint, cpVect, anchr2, Anchr2);
43
- CP_DefineConstraintProperty(cpSlideJoint, cpFloat, min, Min);
44
- CP_DefineConstraintProperty(cpSlideJoint, cpFloat, max, Max);
@@ -1,116 +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
- #define CP_DefineClassGetter(t) const cpConstraintClass * t##GetClass(){return (cpConstraintClass *)&klass;}
23
-
24
- void cpConstraintInit(cpConstraint *constraint, const cpConstraintClass *klass, cpBody *a, cpBody *b);
25
-
26
- #define J_MAX(constraint, dt) (((cpConstraint *)constraint)->maxForce*(dt))
27
-
28
- static inline cpVect
29
- relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2){
30
- cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w));
31
- cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w));
32
-
33
- return cpvsub(v2_sum, v1_sum);
34
- }
35
-
36
- static inline cpFloat
37
- normal_relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n){
38
- return cpvdot(relative_velocity(a, b, r1, r2), n);
39
- }
40
-
41
- static inline void
42
- apply_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j)
43
- {
44
- cpBodyApplyImpulse(a, cpvneg(j), r1);
45
- cpBodyApplyImpulse(b, j, r2);
46
- }
47
-
48
- static inline void
49
- apply_bias_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j)
50
- {
51
- cpBodyApplyBiasImpulse(a, cpvneg(j), r1);
52
- cpBodyApplyBiasImpulse(b, j, r2);
53
- }
54
-
55
- static inline cpVect
56
- clamp_vect(cpVect v, cpFloat len)
57
- {
58
- return cpvclamp(v, len);
59
- // return (cpvdot(v,v) > len*len) ? cpvmult(cpvnormalize(v), len) : v;
60
- }
61
-
62
- static inline cpFloat
63
- k_scalar(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n)
64
- {
65
- cpFloat mass_sum = a->m_inv + b->m_inv;
66
- cpFloat r1cn = cpvcross(r1, n);
67
- cpFloat r2cn = cpvcross(r2, n);
68
-
69
- cpFloat value = mass_sum + a->i_inv*r1cn*r1cn + b->i_inv*r2cn*r2cn;
70
- cpAssert(value != 0.0, "Unsolvable collision or constraint.");
71
-
72
- return value;
73
- }
74
-
75
- static inline void
76
- k_tensor(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect *k1, cpVect *k2)
77
- {
78
- // calculate mass matrix
79
- // If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross...
80
- cpFloat k11, k12, k21, k22;
81
- cpFloat m_sum = a->m_inv + b->m_inv;
82
-
83
- // start with I*m_sum
84
- k11 = m_sum; k12 = 0.0f;
85
- k21 = 0.0f; k22 = m_sum;
86
-
87
- // add the influence from r1
88
- cpFloat a_i_inv = a->i_inv;
89
- cpFloat r1xsq = r1.x * r1.x * a_i_inv;
90
- cpFloat r1ysq = r1.y * r1.y * a_i_inv;
91
- cpFloat r1nxy = -r1.x * r1.y * a_i_inv;
92
- k11 += r1ysq; k12 += r1nxy;
93
- k21 += r1nxy; k22 += r1xsq;
94
-
95
- // add the influnce from r2
96
- cpFloat b_i_inv = b->i_inv;
97
- cpFloat r2xsq = r2.x * r2.x * b_i_inv;
98
- cpFloat r2ysq = r2.y * r2.y * b_i_inv;
99
- cpFloat r2nxy = -r2.x * r2.y * b_i_inv;
100
- k11 += r2ysq; k12 += r2nxy;
101
- k21 += r2nxy; k22 += r2xsq;
102
-
103
- // invert
104
- cpFloat determinant = k11*k22 - k12*k21;
105
- cpAssert(determinant != 0.0, "Unsolvable constraint.");
106
-
107
- cpFloat det_inv = 1.0f/determinant;
108
- *k1 = cpv( k22*det_inv, -k12*det_inv);
109
- *k2 = cpv(-k21*det_inv, k11*det_inv);
110
- }
111
-
112
- static inline cpVect
113
- mult_k(cpVect vr, cpVect k1, cpVect k2)
114
- {
115
- return cpv(cpvdot(vr, k1), cpvdot(vr, k2));
116
- }