pbox2d 0.6.0-java → 0.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +8 -0
- data/.mvn/wrapper/maven-wrapper.properties +1 -0
- data/.travis.yml +23 -0
- data/CHANGELOG.md +8 -0
- data/README.md +7 -7
- data/Rakefile +1 -2
- data/lib/box2d.jar +0 -0
- data/lib/pbox2d/version.rb +1 -1
- data/lib/pbox2d.rb +1 -0
- data/pbox2d.gemspec +6 -11
- data/pom.rb +59 -0
- data/pom.xml +82 -73
- data/src/org/jbox2d/JBox2D.gwt.xml +12 -0
- data/src/org/jbox2d/callbacks/ContactAdaptor.java +27 -0
- data/src/org/jbox2d/callbacks/ContactFilter.java +59 -0
- data/src/org/jbox2d/callbacks/ContactImpulse.java +42 -0
- data/src/org/jbox2d/callbacks/ContactListener.java +87 -0
- data/src/org/jbox2d/callbacks/DebugDraw.java +297 -0
- data/src/org/jbox2d/callbacks/DestructionListener.java +53 -0
- data/src/org/jbox2d/callbacks/PairCallback.java +29 -0
- data/src/org/jbox2d/callbacks/ParticleDestructionListener.java +20 -0
- data/src/org/jbox2d/callbacks/ParticleQueryCallback.java +19 -0
- data/src/org/jbox2d/callbacks/ParticleRaycastCallback.java +19 -0
- data/src/org/jbox2d/callbacks/QueryCallback.java +45 -0
- data/src/org/jbox2d/callbacks/RayCastCallback.java +55 -0
- data/src/org/jbox2d/callbacks/TreeCallback.java +42 -0
- data/src/org/jbox2d/callbacks/TreeRayCastCallback.java +44 -0
- data/src/org/jbox2d/collision/AABB.java +338 -0
- data/src/org/jbox2d/collision/Collision.java +1444 -0
- data/src/org/jbox2d/collision/ContactID.java +106 -0
- data/src/org/jbox2d/collision/Distance.java +773 -0
- data/src/org/jbox2d/collision/DistanceInput.java +41 -0
- data/src/org/jbox2d/collision/DistanceOutput.java +43 -0
- data/src/org/jbox2d/collision/Manifold.java +116 -0
- data/src/org/jbox2d/collision/ManifoldPoint.java +104 -0
- data/src/org/jbox2d/collision/RayCastInput.java +47 -0
- data/src/org/jbox2d/collision/RayCastOutput.java +46 -0
- data/src/org/jbox2d/collision/TimeOfImpact.java +526 -0
- data/src/org/jbox2d/collision/WorldManifold.java +200 -0
- data/src/org/jbox2d/collision/broadphase/BroadPhase.java +92 -0
- data/src/org/jbox2d/collision/broadphase/BroadPhaseStrategy.java +88 -0
- data/src/org/jbox2d/collision/broadphase/DefaultBroadPhaseBuffer.java +268 -0
- data/src/org/jbox2d/collision/broadphase/DynamicTree.java +883 -0
- data/src/org/jbox2d/collision/broadphase/DynamicTreeFlatNodes.java +873 -0
- data/src/org/jbox2d/collision/broadphase/DynamicTreeNode.java +54 -0
- data/src/org/jbox2d/collision/broadphase/Pair.java +46 -0
- data/src/org/jbox2d/collision/shapes/ChainShape.java +264 -0
- data/src/org/jbox2d/collision/shapes/CircleShape.java +207 -0
- data/src/org/jbox2d/collision/shapes/EdgeShape.java +254 -0
- data/src/org/jbox2d/collision/shapes/MassData.java +105 -0
- data/src/org/jbox2d/collision/shapes/PolygonShape.java +718 -0
- data/src/org/jbox2d/collision/shapes/Shape.java +136 -0
- data/src/org/jbox2d/collision/shapes/ShapeType.java +32 -0
- data/src/org/jbox2d/common/BufferUtils.java +209 -0
- data/src/org/jbox2d/common/Color3f.java +88 -0
- data/src/org/jbox2d/common/IViewportTransform.java +133 -0
- data/src/org/jbox2d/common/Mat22.java +609 -0
- data/src/org/jbox2d/common/Mat33.java +290 -0
- data/src/org/jbox2d/common/MathUtils.java +335 -0
- data/src/org/jbox2d/common/OBBViewportTransform.java +174 -0
- data/src/org/jbox2d/common/PlatformMathUtils.java +46 -0
- data/src/org/jbox2d/common/RaycastResult.java +37 -0
- data/src/org/jbox2d/common/Rot.java +150 -0
- data/src/org/jbox2d/common/Settings.java +246 -0
- data/src/org/jbox2d/common/Sweep.java +116 -0
- data/src/org/jbox2d/common/Timer.java +46 -0
- data/src/org/jbox2d/common/Transform.java +203 -0
- data/src/org/jbox2d/common/Vec2.java +388 -0
- data/src/org/jbox2d/common/Vec3.java +170 -0
- data/src/org/jbox2d/dynamics/Body.java +1246 -0
- data/src/org/jbox2d/dynamics/BodyDef.java +382 -0
- data/src/org/jbox2d/dynamics/BodyType.java +41 -0
- data/src/org/jbox2d/dynamics/ContactManager.java +293 -0
- data/src/org/jbox2d/dynamics/Filter.java +62 -0
- data/src/org/jbox2d/dynamics/Fixture.java +454 -0
- data/src/org/jbox2d/dynamics/FixtureDef.java +214 -0
- data/src/org/jbox2d/dynamics/FixtureProxy.java +38 -0
- data/src/org/jbox2d/dynamics/Island.java +602 -0
- data/src/org/jbox2d/dynamics/Profile.java +97 -0
- data/src/org/jbox2d/dynamics/SolverData.java +33 -0
- data/src/org/jbox2d/dynamics/TimeStep.java +46 -0
- data/src/org/jbox2d/dynamics/World.java +2075 -0
- data/src/org/jbox2d/dynamics/contacts/ChainAndCircleContact.java +57 -0
- data/src/org/jbox2d/dynamics/contacts/ChainAndPolygonContact.java +57 -0
- data/src/org/jbox2d/dynamics/contacts/CircleContact.java +50 -0
- data/src/org/jbox2d/dynamics/contacts/Contact.java +365 -0
- data/src/org/jbox2d/dynamics/contacts/ContactCreator.java +35 -0
- data/src/org/jbox2d/dynamics/contacts/ContactEdge.java +56 -0
- data/src/org/jbox2d/dynamics/contacts/ContactPositionConstraint.java +49 -0
- data/src/org/jbox2d/dynamics/contacts/ContactRegister.java +31 -0
- data/src/org/jbox2d/dynamics/contacts/ContactSolver.java +1104 -0
- data/src/org/jbox2d/dynamics/contacts/ContactVelocityConstraint.java +60 -0
- data/src/org/jbox2d/dynamics/contacts/EdgeAndCircleContact.java +52 -0
- data/src/org/jbox2d/dynamics/contacts/EdgeAndPolygonContact.java +52 -0
- data/src/org/jbox2d/dynamics/contacts/PolygonAndCircleContact.java +51 -0
- data/src/org/jbox2d/dynamics/contacts/PolygonContact.java +50 -0
- data/src/org/jbox2d/dynamics/contacts/Position.java +31 -0
- data/src/org/jbox2d/dynamics/contacts/Velocity.java +31 -0
- data/src/org/jbox2d/dynamics/joints/ConstantVolumeJoint.java +258 -0
- data/src/org/jbox2d/dynamics/joints/ConstantVolumeJointDef.java +75 -0
- data/src/org/jbox2d/dynamics/joints/DistanceJoint.java +356 -0
- data/src/org/jbox2d/dynamics/joints/DistanceJointDef.java +106 -0
- data/src/org/jbox2d/dynamics/joints/FrictionJoint.java +294 -0
- data/src/org/jbox2d/dynamics/joints/FrictionJointDef.java +78 -0
- data/src/org/jbox2d/dynamics/joints/GearJoint.java +520 -0
- data/src/org/jbox2d/dynamics/joints/GearJointDef.java +58 -0
- data/src/org/jbox2d/dynamics/joints/Jacobian.java +32 -0
- data/src/org/jbox2d/dynamics/joints/Joint.java +235 -0
- data/src/org/jbox2d/dynamics/joints/JointDef.java +65 -0
- data/src/org/jbox2d/dynamics/joints/JointEdge.java +57 -0
- data/src/org/jbox2d/dynamics/joints/JointType.java +28 -0
- data/src/org/jbox2d/dynamics/joints/LimitState.java +28 -0
- data/src/org/jbox2d/dynamics/joints/MotorJoint.java +339 -0
- data/src/org/jbox2d/dynamics/joints/MotorJointDef.java +55 -0
- data/src/org/jbox2d/dynamics/joints/MouseJoint.java +262 -0
- data/src/org/jbox2d/dynamics/joints/MouseJointDef.java +62 -0
- data/src/org/jbox2d/dynamics/joints/PrismaticJoint.java +808 -0
- data/src/org/jbox2d/dynamics/joints/PrismaticJointDef.java +120 -0
- data/src/org/jbox2d/dynamics/joints/PulleyJoint.java +393 -0
- data/src/org/jbox2d/dynamics/joints/PulleyJointDef.java +105 -0
- data/src/org/jbox2d/dynamics/joints/RevoluteJoint.java +554 -0
- data/src/org/jbox2d/dynamics/joints/RevoluteJointDef.java +137 -0
- data/src/org/jbox2d/dynamics/joints/RopeJoint.java +276 -0
- data/src/org/jbox2d/dynamics/joints/RopeJointDef.java +34 -0
- data/src/org/jbox2d/dynamics/joints/WeldJoint.java +424 -0
- data/src/org/jbox2d/dynamics/joints/WeldJointDef.java +85 -0
- data/src/org/jbox2d/dynamics/joints/WheelJoint.java +498 -0
- data/src/org/jbox2d/dynamics/joints/WheelJointDef.java +98 -0
- data/src/org/jbox2d/particle/ParticleBodyContact.java +17 -0
- data/src/org/jbox2d/particle/ParticleColor.java +52 -0
- data/src/org/jbox2d/particle/ParticleContact.java +14 -0
- data/src/org/jbox2d/particle/ParticleDef.java +24 -0
- data/src/org/jbox2d/particle/ParticleGroup.java +154 -0
- data/src/org/jbox2d/particle/ParticleGroupDef.java +62 -0
- data/src/org/jbox2d/particle/ParticleGroupType.java +8 -0
- data/src/org/jbox2d/particle/ParticleSystem.java +2172 -0
- data/src/org/jbox2d/particle/ParticleType.java +28 -0
- data/src/org/jbox2d/particle/StackQueue.java +44 -0
- data/src/org/jbox2d/particle/VoronoiDiagram.java +209 -0
- data/src/org/jbox2d/pooling/IDynamicStack.java +47 -0
- data/src/org/jbox2d/pooling/IOrderedStack.java +57 -0
- data/src/org/jbox2d/pooling/IWorldPool.java +101 -0
- data/src/org/jbox2d/pooling/arrays/FloatArray.java +50 -0
- data/src/org/jbox2d/pooling/arrays/GeneratorArray.java +33 -0
- data/src/org/jbox2d/pooling/arrays/IntArray.java +53 -0
- data/src/org/jbox2d/pooling/arrays/Vec2Array.java +57 -0
- data/src/org/jbox2d/pooling/normal/CircleStack.java +77 -0
- data/src/org/jbox2d/pooling/normal/DefaultWorldPool.java +331 -0
- data/src/org/jbox2d/pooling/normal/MutableStack.java +72 -0
- data/src/org/jbox2d/pooling/normal/OrderedStack.java +73 -0
- data/src/org/jbox2d/pooling/stacks/DynamicIntStack.java +60 -0
- metadata +161 -14
- data/lib/jbox2d-library-2.3.1-SNAPSHOT.jar +0 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
package org.jbox2d.dynamics.joints;
|
2
|
+
|
3
|
+
import org.jbox2d.common.MathUtils;
|
4
|
+
import org.jbox2d.common.Rot;
|
5
|
+
import org.jbox2d.common.Settings;
|
6
|
+
import org.jbox2d.common.Vec2;
|
7
|
+
import org.jbox2d.dynamics.SolverData;
|
8
|
+
import org.jbox2d.pooling.IWorldPool;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* A rope joint enforces a maximum distance between two points on two bodies. It has no other
|
12
|
+
* effect. Warning: if you attempt to change the maximum length during the simulation you will get
|
13
|
+
* some non-physical behavior. A model that would allow you to dynamically modify the length would
|
14
|
+
* have some sponginess, so I chose not to implement it that way. See DistanceJoint if you want to
|
15
|
+
* dynamically control length.
|
16
|
+
*
|
17
|
+
* @author Daniel Murphy
|
18
|
+
*/
|
19
|
+
public class RopeJoint extends Joint {
|
20
|
+
// Solver shared
|
21
|
+
private final Vec2 m_localAnchorA = new Vec2();
|
22
|
+
private final Vec2 m_localAnchorB = new Vec2();
|
23
|
+
private float m_maxLength;
|
24
|
+
private float m_length;
|
25
|
+
private float m_impulse;
|
26
|
+
|
27
|
+
// Solver temp
|
28
|
+
private int m_indexA;
|
29
|
+
private int m_indexB;
|
30
|
+
private final Vec2 m_u = new Vec2();
|
31
|
+
private final Vec2 m_rA = new Vec2();
|
32
|
+
private final Vec2 m_rB = new Vec2();
|
33
|
+
private final Vec2 m_localCenterA = new Vec2();
|
34
|
+
private final Vec2 m_localCenterB = new Vec2();
|
35
|
+
private float m_invMassA;
|
36
|
+
private float m_invMassB;
|
37
|
+
private float m_invIA;
|
38
|
+
private float m_invIB;
|
39
|
+
private float m_mass;
|
40
|
+
private LimitState m_state;
|
41
|
+
|
42
|
+
protected RopeJoint(IWorldPool worldPool, RopeJointDef def) {
|
43
|
+
super(worldPool, def);
|
44
|
+
m_localAnchorA.set(def.localAnchorA);
|
45
|
+
m_localAnchorB.set(def.localAnchorB);
|
46
|
+
|
47
|
+
m_maxLength = def.maxLength;
|
48
|
+
|
49
|
+
m_mass = 0.0f;
|
50
|
+
m_impulse = 0.0f;
|
51
|
+
m_state = LimitState.INACTIVE;
|
52
|
+
m_length = 0.0f;
|
53
|
+
}
|
54
|
+
|
55
|
+
@Override
|
56
|
+
public void initVelocityConstraints(final SolverData data) {
|
57
|
+
m_indexA = m_bodyA.m_islandIndex;
|
58
|
+
m_indexB = m_bodyB.m_islandIndex;
|
59
|
+
m_localCenterA.set(m_bodyA.m_sweep.localCenter);
|
60
|
+
m_localCenterB.set(m_bodyB.m_sweep.localCenter);
|
61
|
+
m_invMassA = m_bodyA.m_invMass;
|
62
|
+
m_invMassB = m_bodyB.m_invMass;
|
63
|
+
m_invIA = m_bodyA.m_invI;
|
64
|
+
m_invIB = m_bodyB.m_invI;
|
65
|
+
|
66
|
+
Vec2 cA = data.positions[m_indexA].c;
|
67
|
+
float aA = data.positions[m_indexA].a;
|
68
|
+
Vec2 vA = data.velocities[m_indexA].v;
|
69
|
+
float wA = data.velocities[m_indexA].w;
|
70
|
+
|
71
|
+
Vec2 cB = data.positions[m_indexB].c;
|
72
|
+
float aB = data.positions[m_indexB].a;
|
73
|
+
Vec2 vB = data.velocities[m_indexB].v;
|
74
|
+
float wB = data.velocities[m_indexB].w;
|
75
|
+
|
76
|
+
final Rot qA = pool.popRot();
|
77
|
+
final Rot qB = pool.popRot();
|
78
|
+
final Vec2 temp = pool.popVec2();
|
79
|
+
|
80
|
+
qA.set(aA);
|
81
|
+
qB.set(aB);
|
82
|
+
|
83
|
+
// Compute the effective masses.
|
84
|
+
Rot.mulToOutUnsafe(qA, temp.set(m_localAnchorA).subLocal(m_localCenterA), m_rA);
|
85
|
+
Rot.mulToOutUnsafe(qB, temp.set(m_localAnchorB).subLocal(m_localCenterB), m_rB);
|
86
|
+
|
87
|
+
m_u.set(cB).addLocal(m_rB).subLocal(cA).subLocal(m_rA);
|
88
|
+
|
89
|
+
m_length = m_u.length();
|
90
|
+
|
91
|
+
float C = m_length - m_maxLength;
|
92
|
+
if (C > 0.0f) {
|
93
|
+
m_state = LimitState.AT_UPPER;
|
94
|
+
} else {
|
95
|
+
m_state = LimitState.INACTIVE;
|
96
|
+
}
|
97
|
+
|
98
|
+
if (m_length > Settings.linearSlop) {
|
99
|
+
m_u.mulLocal(1.0f / m_length);
|
100
|
+
} else {
|
101
|
+
m_u.setZero();
|
102
|
+
m_mass = 0.0f;
|
103
|
+
m_impulse = 0.0f;
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
// Compute effective mass.
|
108
|
+
float crA = Vec2.cross(m_rA, m_u);
|
109
|
+
float crB = Vec2.cross(m_rB, m_u);
|
110
|
+
float invMass = m_invMassA + m_invIA * crA * crA + m_invMassB + m_invIB * crB * crB;
|
111
|
+
|
112
|
+
m_mass = invMass != 0.0f ? 1.0f / invMass : 0.0f;
|
113
|
+
|
114
|
+
if (data.step.warmStarting) {
|
115
|
+
// Scale the impulse to support a variable time step.
|
116
|
+
m_impulse *= data.step.dtRatio;
|
117
|
+
|
118
|
+
float Px = m_impulse * m_u.x;
|
119
|
+
float Py = m_impulse * m_u.y;
|
120
|
+
vA.x -= m_invMassA * Px;
|
121
|
+
vA.y -= m_invMassA * Py;
|
122
|
+
wA -= m_invIA * (m_rA.x * Py - m_rA.y * Px);
|
123
|
+
|
124
|
+
vB.x += m_invMassB * Px;
|
125
|
+
vB.y += m_invMassB * Py;
|
126
|
+
wB += m_invIB * (m_rB.x * Py - m_rB.y * Px);
|
127
|
+
} else {
|
128
|
+
m_impulse = 0.0f;
|
129
|
+
}
|
130
|
+
|
131
|
+
pool.pushRot(2);
|
132
|
+
pool.pushVec2(1);
|
133
|
+
|
134
|
+
// data.velocities[m_indexA].v = vA;
|
135
|
+
data.velocities[m_indexA].w = wA;
|
136
|
+
// data.velocities[m_indexB].v = vB;
|
137
|
+
data.velocities[m_indexB].w = wB;
|
138
|
+
}
|
139
|
+
|
140
|
+
@Override
|
141
|
+
public void solveVelocityConstraints(final SolverData data) {
|
142
|
+
Vec2 vA = data.velocities[m_indexA].v;
|
143
|
+
float wA = data.velocities[m_indexA].w;
|
144
|
+
Vec2 vB = data.velocities[m_indexB].v;
|
145
|
+
float wB = data.velocities[m_indexB].w;
|
146
|
+
|
147
|
+
// Cdot = dot(u, v + cross(w, r))
|
148
|
+
Vec2 vpA = pool.popVec2();
|
149
|
+
Vec2 vpB = pool.popVec2();
|
150
|
+
Vec2 temp = pool.popVec2();
|
151
|
+
|
152
|
+
Vec2.crossToOutUnsafe(wA, m_rA, vpA);
|
153
|
+
vpA.addLocal(vA);
|
154
|
+
Vec2.crossToOutUnsafe(wB, m_rB, vpB);
|
155
|
+
vpB.addLocal(vB);
|
156
|
+
|
157
|
+
float C = m_length - m_maxLength;
|
158
|
+
float Cdot = Vec2.dot(m_u, temp.set(vpB).subLocal(vpA));
|
159
|
+
|
160
|
+
// Predictive constraint.
|
161
|
+
if (C < 0.0f) {
|
162
|
+
Cdot += data.step.inv_dt * C;
|
163
|
+
}
|
164
|
+
|
165
|
+
float impulse = -m_mass * Cdot;
|
166
|
+
float oldImpulse = m_impulse;
|
167
|
+
m_impulse = MathUtils.min(0.0f, m_impulse + impulse);
|
168
|
+
impulse = m_impulse - oldImpulse;
|
169
|
+
|
170
|
+
float Px = impulse * m_u.x;
|
171
|
+
float Py = impulse * m_u.y;
|
172
|
+
vA.x -= m_invMassA * Px;
|
173
|
+
vA.y -= m_invMassA * Py;
|
174
|
+
wA -= m_invIA * (m_rA.x * Py - m_rA.y * Px);
|
175
|
+
vB.x += m_invMassB * Px;
|
176
|
+
vB.y += m_invMassB * Py;
|
177
|
+
wB += m_invIB * (m_rB.x * Py - m_rB.y * Px);
|
178
|
+
|
179
|
+
pool.pushVec2(3);
|
180
|
+
|
181
|
+
// data.velocities[m_indexA].v = vA;
|
182
|
+
data.velocities[m_indexA].w = wA;
|
183
|
+
// data.velocities[m_indexB].v = vB;
|
184
|
+
data.velocities[m_indexB].w = wB;
|
185
|
+
}
|
186
|
+
|
187
|
+
@Override
|
188
|
+
public boolean solvePositionConstraints(final SolverData data) {
|
189
|
+
Vec2 cA = data.positions[m_indexA].c;
|
190
|
+
float aA = data.positions[m_indexA].a;
|
191
|
+
Vec2 cB = data.positions[m_indexB].c;
|
192
|
+
float aB = data.positions[m_indexB].a;
|
193
|
+
|
194
|
+
final Rot qA = pool.popRot();
|
195
|
+
final Rot qB = pool.popRot();
|
196
|
+
final Vec2 u = pool.popVec2();
|
197
|
+
final Vec2 rA = pool.popVec2();
|
198
|
+
final Vec2 rB = pool.popVec2();
|
199
|
+
final Vec2 temp = pool.popVec2();
|
200
|
+
|
201
|
+
qA.set(aA);
|
202
|
+
qB.set(aB);
|
203
|
+
|
204
|
+
// Compute the effective masses.
|
205
|
+
Rot.mulToOutUnsafe(qA, temp.set(m_localAnchorA).subLocal(m_localCenterA), rA);
|
206
|
+
Rot.mulToOutUnsafe(qB, temp.set(m_localAnchorB).subLocal(m_localCenterB), rB);
|
207
|
+
u.set(cB).addLocal(rB).subLocal(cA).subLocal(rA);
|
208
|
+
|
209
|
+
float length = u.normalize();
|
210
|
+
float C = length - m_maxLength;
|
211
|
+
|
212
|
+
C = MathUtils.clamp(C, 0.0f, Settings.maxLinearCorrection);
|
213
|
+
|
214
|
+
float impulse = -m_mass * C;
|
215
|
+
float Px = impulse * u.x;
|
216
|
+
float Py = impulse * u.y;
|
217
|
+
|
218
|
+
cA.x -= m_invMassA * Px;
|
219
|
+
cA.y -= m_invMassA * Py;
|
220
|
+
aA -= m_invIA * (rA.x * Py - rA.y * Px);
|
221
|
+
cB.x += m_invMassB * Px;
|
222
|
+
cB.y += m_invMassB * Py;
|
223
|
+
aB += m_invIB * (rB.x * Py - rB.y * Px);
|
224
|
+
|
225
|
+
pool.pushRot(2);
|
226
|
+
pool.pushVec2(4);
|
227
|
+
|
228
|
+
// data.positions[m_indexA].c = cA;
|
229
|
+
data.positions[m_indexA].a = aA;
|
230
|
+
// data.positions[m_indexB].c = cB;
|
231
|
+
data.positions[m_indexB].a = aB;
|
232
|
+
|
233
|
+
return length - m_maxLength < Settings.linearSlop;
|
234
|
+
}
|
235
|
+
|
236
|
+
@Override
|
237
|
+
public void getAnchorA(Vec2 argOut) {
|
238
|
+
m_bodyA.getWorldPointToOut(m_localAnchorA, argOut);
|
239
|
+
}
|
240
|
+
|
241
|
+
@Override
|
242
|
+
public void getAnchorB(Vec2 argOut) {
|
243
|
+
m_bodyB.getWorldPointToOut(m_localAnchorB, argOut);
|
244
|
+
}
|
245
|
+
|
246
|
+
@Override
|
247
|
+
public void getReactionForce(float inv_dt, Vec2 argOut) {
|
248
|
+
argOut.set(m_u).mulLocal(inv_dt).mulLocal(m_impulse);
|
249
|
+
}
|
250
|
+
|
251
|
+
@Override
|
252
|
+
public float getReactionTorque(float inv_dt) {
|
253
|
+
return 0f;
|
254
|
+
}
|
255
|
+
|
256
|
+
public Vec2 getLocalAnchorA() {
|
257
|
+
return m_localAnchorA;
|
258
|
+
}
|
259
|
+
|
260
|
+
public Vec2 getLocalAnchorB() {
|
261
|
+
return m_localAnchorB;
|
262
|
+
}
|
263
|
+
|
264
|
+
public float getMaxLength() {
|
265
|
+
return m_maxLength;
|
266
|
+
}
|
267
|
+
|
268
|
+
public void setMaxLength(float maxLength) {
|
269
|
+
this.m_maxLength = maxLength;
|
270
|
+
}
|
271
|
+
|
272
|
+
public LimitState getLimitState() {
|
273
|
+
return m_state;
|
274
|
+
}
|
275
|
+
|
276
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
package org.jbox2d.dynamics.joints;
|
2
|
+
|
3
|
+
import org.jbox2d.common.Vec2;
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Rope joint definition. This requires two body anchor points and a maximum lengths. Note: by
|
7
|
+
* default the connected objects will not collide. see collideConnected in b2JointDef.
|
8
|
+
*
|
9
|
+
* @author Daniel Murphy
|
10
|
+
*/
|
11
|
+
public class RopeJointDef extends JointDef {
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The local anchor point relative to bodyA's origin.
|
15
|
+
*/
|
16
|
+
public final Vec2 localAnchorA = new Vec2();
|
17
|
+
|
18
|
+
/**
|
19
|
+
* The local anchor point relative to bodyB's origin.
|
20
|
+
*/
|
21
|
+
public final Vec2 localAnchorB = new Vec2();
|
22
|
+
|
23
|
+
/**
|
24
|
+
* The maximum length of the rope. Warning: this must be larger than b2_linearSlop or the joint
|
25
|
+
* will have no effect.
|
26
|
+
*/
|
27
|
+
public float maxLength;
|
28
|
+
|
29
|
+
public RopeJointDef() {
|
30
|
+
super(JointType.ROPE);
|
31
|
+
localAnchorA.set(-1.0f, 0.0f);
|
32
|
+
localAnchorB.set(1.0f, 0.0f);
|
33
|
+
}
|
34
|
+
}
|