annotate trunk/chipmunkd/constraints/cpGrooveJoint.d @ 28:4541ca17975b

use __gshared as chipmunk heavily relies on globals and D would otherwise make them TLS
author Extrawurst
date Mon, 13 Dec 2010 21:40:56 +0100
parents c03a41d47b60
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
1
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
2 // written in the D programming language
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
3
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
4 module chipmunkd.constraints.cpGrooveJoint;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
5
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
6 import chipmunkd.chipmunk;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
7 import chipmunkd.constraints.util;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
8
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
9 //const cpConstraintClass *cpGrooveJointGetClass();
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
10
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
11 struct cpGrooveJoint {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
12 cpConstraint constraint;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
13 cpVect grv_n, grv_a, grv_b;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
14 cpVect anchr2;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
15
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
16 cpVect grv_tn;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
17 cpFloat clamp;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
18 cpVect r1, r2;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
19 cpVect k1, k2;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
20
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
21 cpVect jAcc;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
22 cpFloat jMaxLen;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
23 cpVect bias;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
24 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
25
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
26 //cpGrooveJoint *cpGrooveJointAlloc(void);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
27 //cpGrooveJoint *cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
28 //cpConstraint *cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2);
13
c03a41d47b60 - finished all constraints properties
Extrawurst
parents: 7
diff changeset
29
c03a41d47b60 - finished all constraints properties
Extrawurst
parents: 7
diff changeset
30 mixin(CP_DefineConstraintGetter!("cpGrooveJoint", "cpVect", "grv_a", "GrooveA"));
6
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
31 //void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect value);
13
c03a41d47b60 - finished all constraints properties
Extrawurst
parents: 7
diff changeset
32 mixin(CP_DefineConstraintGetter!("cpGrooveJoint", "cpVect", "grv_b", "GrooveB"));
6
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
33 //void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect value);
13
c03a41d47b60 - finished all constraints properties
Extrawurst
parents: 7
diff changeset
34 mixin(CP_DefineConstraintProperty!("cpGrooveJoint", "cpVect", "anchr2", "Anchr2"));
6
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
35
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
36 // cpGrooveJoint.c ---------------------------------
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
37
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
38 static void
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
39 preStep(cpGrooveJoint *joint, cpFloat dt, cpFloat dt_inv)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
40 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
41 mixin(CONSTRAINT_BEGIN!("joint", "a", "b"));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
42
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
43 // calculate endpoints in worldspace
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
44 cpVect ta = cpBodyLocal2World(a, joint.grv_a);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
45 cpVect tb = cpBodyLocal2World(a, joint.grv_b);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
46
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
47 // calculate axis
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
48 cpVect n = cpvrotate(joint.grv_n, a.rot);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
49 cpFloat d = cpvdot(ta, n);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
50
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
51 joint.grv_tn = n;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
52 joint.r2 = cpvrotate(joint.anchr2, b.rot);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
53
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
54 // calculate tangential distance along the axis of r2
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
55 cpFloat td = cpvcross(cpvadd(b.p, joint.r2), n);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
56 // calculate clamping factor and r2
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
57 if(td <= cpvcross(ta, n)){
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
58 joint.clamp = 1.0f;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
59 joint.r1 = cpvsub(ta, a.p);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
60 } else if(td >= cpvcross(tb, n)){
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
61 joint.clamp = -1.0f;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
62 joint.r1 = cpvsub(tb, a.p);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
63 } else {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
64 joint.clamp = 0.0f;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
65 joint.r1 = cpvsub(cpvadd(cpvmult(cpvperp(n), -td), cpvmult(n, d)), a.p);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
66 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
67
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
68 // Calculate mass tensor
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
69 k_tensor(a, b, joint.r1, joint.r2, &joint.k1, &joint.k2);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
70
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
71 // compute max impulse
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
72 joint.jMaxLen = mixin(J_MAX!("joint", "dt"));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
73
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
74 // calculate bias velocity
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
75 cpVect delta = cpvsub(cpvadd(b.p, joint.r2), cpvadd(a.p, joint.r1));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
76 joint.bias = cpvclamp(cpvmult(delta, -joint.constraint.biasCoef*dt_inv), joint.constraint.maxBias);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
77
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
78 // apply accumulated impulse
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
79 apply_impulses(a, b, joint.r1, joint.r2, joint.jAcc);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
80 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
81
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
82 static cpVect
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
83 grooveConstrain(cpGrooveJoint *joint, cpVect j){
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
84 cpVect n = joint.grv_tn;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
85 cpVect jClamp = (joint.clamp*cpvcross(j, n) > 0.0f) ? j : cpvproject(j, n);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
86 return cpvclamp(jClamp, joint.jMaxLen);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
87 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
88
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
89 static void
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
90 applyImpulse(cpGrooveJoint *joint)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
91 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
92 mixin(CONSTRAINT_BEGIN!("joint", "a", "b"));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
93
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
94 cpVect r1 = joint.r1;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
95 cpVect r2 = joint.r2;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
96
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
97 // compute impulse
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
98 cpVect vr = relative_velocity(a, b, r1, r2);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
99
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
100 cpVect j = mult_k(cpvsub(joint.bias, vr), joint.k1, joint.k2);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
101 cpVect jOld = joint.jAcc;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
102 joint.jAcc = grooveConstrain(joint, cpvadd(jOld, j));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
103 j = cpvsub(joint.jAcc, jOld);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
104
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
105 // apply impulse
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
106 apply_impulses(a, b, joint.r1, joint.r2, j);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
107 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
108
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
109 static cpFloat
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
110 getImpulse(cpGrooveJoint *joint)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
111 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
112 return cpvlength(joint.jAcc);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
113 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
114
28
4541ca17975b use __gshared as chipmunk heavily relies on globals and D would otherwise make them TLS
Extrawurst
parents: 13
diff changeset
115 __gshared /+const+/ cpConstraintClass klass = {
6
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
116 cast(cpConstraintPreStepFunction)&preStep,
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
117 cast(cpConstraintApplyImpulseFunction)&applyImpulse,
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
118 cast(cpConstraintGetImpulseFunction)&getImpulse,
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
119 };
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
120 mixin(CP_DefineClassGetter!("cpGrooveJoint"));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
121
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
122 cpGrooveJoint *
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
123 cpGrooveJointAlloc()
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
124 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
125 return cast(cpGrooveJoint *)cpmalloc(cpGrooveJoint.sizeof);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
126 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
127
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
128 cpGrooveJoint *
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
129 cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
130 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
131 cpConstraintInit(cast(cpConstraint *)joint, &klass, a, b);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
132
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
133 joint.grv_a = groove_a;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
134 joint.grv_b = groove_b;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
135 joint.grv_n = cpvperp(cpvnormalize(cpvsub(groove_b, groove_a)));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
136 joint.anchr2 = anchr2;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
137
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
138 joint.jAcc = cpvzero;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
139
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
140 return joint;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
141 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
142
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
143 cpConstraint *
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
144 cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
145 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
146 return cast(cpConstraint *)cpGrooveJointInit(cpGrooveJointAlloc(), a, b, groove_a, groove_b, anchr2);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
147 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
148
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
149 void
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
150 cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect value)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
151 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
152 cpGrooveJoint *g = cast(cpGrooveJoint *)constraint;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
153 //TODO:
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
154 //cpConstraintCheckCast(constraint, cpGrooveJoint);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
155
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
156 g.grv_a = value;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
157 g.grv_n = cpvperp(cpvnormalize(cpvsub(g.grv_b, value)));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
158
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
159 cpConstraintActivateBodies(constraint);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
160 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
161
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
162 void
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
163 cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect value)
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
164 {
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
165 cpGrooveJoint *g = cast(cpGrooveJoint *)constraint;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
166 //TODO:
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
167 //cpConstraintCheckCast(constraint, cpGrooveJoint);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
168
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
169 g.grv_b = value;
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
170 g.grv_n = cpvperp(cpvnormalize(cpvsub(value, g.grv_a)));
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
171
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
172 cpConstraintActivateBodies(constraint);
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
173 }
707dd4e10c28 ported rest of the constraints (chipmunk 5.3.2)
Extrawurst
parents:
diff changeset
174