@@ -64,7 +64,7 @@ public final class World {
64
64
65
65
private Array <Body > bodies = new Array <>(WORLD_POOL_SIZE );
66
66
67
- private Joint m_jointList = null ;
67
+ private Array < Joint > joints = new Array <>() ;
68
68
private int jointCount = 0 ;
69
69
70
70
private final Vec2 gravity = new Vec2 ();
@@ -127,13 +127,7 @@ public <T extends Joint> T createJoint(JointDef<T> def) {
127
127
128
128
T j = Joint .create (this , def );
129
129
130
- // Connect to the world list.
131
- j .m_prev = null ;
132
- j .m_next = m_jointList ;
133
- if (m_jointList != null ) {
134
- m_jointList .m_prev = j ;
135
- }
136
- m_jointList = j ;
130
+ joints .add (j );
137
131
++jointCount ;
138
132
139
133
// Connect to the bodies' doubly linked lists.
@@ -177,18 +171,7 @@ public void destroyJoint(Joint j) {
177
171
178
172
boolean collideConnected = j .getCollideConnected ();
179
173
180
- // Remove from the doubly linked list.
181
- if (j .m_prev != null ) {
182
- j .m_prev .m_next = j .m_next ;
183
- }
184
-
185
- if (j .m_next != null ) {
186
- j .m_next .m_prev = j .m_prev ;
187
- }
188
-
189
- if (j == m_jointList ) {
190
- m_jointList = j .m_next ;
191
- }
174
+ joints .removeValueByIdentity (j );
192
175
193
176
// Disconnect from island graph.
194
177
Body bodyA = j .getBodyA ();
@@ -334,7 +317,7 @@ private void solve(TimeStep step) {
334
317
for (Contact c = contactManager .contactList ; c != null ; c = c .m_next ) {
335
318
c .m_flags &= ~Contact .ISLAND_FLAG ;
336
319
}
337
- for (Joint j = m_jointList ; j != null ; j = j . m_next ) {
320
+ for (Joint j : joints ) {
338
321
j .m_islandFlag = false ;
339
322
}
340
323
@@ -1149,16 +1132,6 @@ public Array<Body> getBodies() {
1149
1132
return bodies ;
1150
1133
}
1151
1134
1152
- /**
1153
- * Get the world joint list. With the returned joint, use Joint.getNext to get the next joint in
1154
- * the world list. A null joint indicates the end of the list.
1155
- *
1156
- * @return the head of the world joint list.
1157
- */
1158
- public Joint getJointList () {
1159
- return m_jointList ;
1160
- }
1161
-
1162
1135
/**
1163
1136
* Get the world contact list. With the returned contact, use Contact.getNext to get the next
1164
1137
* contact in the world list. A null contact indicates the end of the list.
0 commit comments