A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AlmasB/FXGL/commit/f41bc2555 below:

use Array to store Joints instead of manual linked list · AlmasB/FXGL@f41bc25 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+4

-33

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+4

-33

lines changed Original file line number Diff line number Diff line change

@@ -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.

Original file line number Diff line number Diff line change

@@ -29,8 +29,6 @@ public static void destroy(Joint joint) {

29 29

joint.destructor();

30 30

}

31 31 32 -

public Joint m_prev = null;

33 -

public Joint m_next = null;

34 32

public final JointEdge m_edgeA = new JointEdge();

35 33

public final JointEdge m_edgeB = new JointEdge();

36 34

protected Body m_bodyA;

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4