box2d-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/box2d-rails.gemspec +20 -0
- data/lib/box2d-rails.rb +8 -0
- data/lib/box2d-rails/version.rb +5 -0
- data/vendor/assets/javascripts/box2d/collision/ClipVertex.js +35 -0
- data/vendor/assets/javascripts/box2d/collision/Features.js +61 -0
- data/vendor/assets/javascripts/box2d/collision/b2AABB.js +45 -0
- data/vendor/assets/javascripts/box2d/collision/b2Bound.js +43 -0
- data/vendor/assets/javascripts/box2d/collision/b2BoundValues.js +31 -0
- data/vendor/assets/javascripts/box2d/collision/b2BroadPhase.js +898 -0
- data/vendor/assets/javascripts/box2d/collision/b2BufferedPair.js +26 -0
- data/vendor/assets/javascripts/box2d/collision/b2Collision.js +738 -0
- data/vendor/assets/javascripts/box2d/collision/b2ContactID.js +52 -0
- data/vendor/assets/javascripts/box2d/collision/b2ContactPoint.js +35 -0
- data/vendor/assets/javascripts/box2d/collision/b2Distance.js +333 -0
- data/vendor/assets/javascripts/box2d/collision/b2Manifold.js +34 -0
- data/vendor/assets/javascripts/box2d/collision/b2OBB.js +34 -0
- data/vendor/assets/javascripts/box2d/collision/b2Pair.js +60 -0
- data/vendor/assets/javascripts/box2d/collision/b2PairCallback.js +34 -0
- data/vendor/assets/javascripts/box2d/collision/b2PairManager.js +386 -0
- data/vendor/assets/javascripts/box2d/collision/b2Proxy.js +40 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2BoxDef.js +49 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2CircleDef.js +49 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2CircleShape.js +198 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2MassData.js +36 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2PolyDef.js +58 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2PolyShape.js +492 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2Shape.js +339 -0
- data/vendor/assets/javascripts/box2d/collision/shapes/b2ShapeDef.js +109 -0
- data/vendor/assets/javascripts/box2d/common/b2Settings.js +72 -0
- data/vendor/assets/javascripts/box2d/common/math/b2Mat22.js +130 -0
- data/vendor/assets/javascripts/box2d/common/math/b2Math.js +218 -0
- data/vendor/assets/javascripts/box2d/common/math/b2Vec2.js +131 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2Body.js +469 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2BodyDef.js +69 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2CollisionFilter.js +42 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2ContactManager.js +337 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2Island.js +331 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2TimeStep.js +27 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2World.js +522 -0
- data/vendor/assets/javascripts/box2d/dynamics/b2WorldListener.js +52 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2CircleContact.js +102 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2Conservative.js +228 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2Contact.js +201 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2ContactConstraint.js +45 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2ContactConstraintPoint.js +40 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2ContactNode.js +33 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2ContactRegister.js +30 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2ContactSolver.js +537 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2NullContact.js +65 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2PolyAndCircleContact.js +103 -0
- data/vendor/assets/javascripts/box2d/dynamics/contacts/b2PolyContact.js +163 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2DistanceJoint.js +264 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2DistanceJointDef.js +49 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2GearJoint.js +307 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2GearJointDef.js +50 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2Jacobian.js +49 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2Joint.js +200 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2JointDef.js +40 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2JointNode.js +33 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2MouseJoint.js +234 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2MouseJointDef.js +53 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2PrismaticJoint.js +676 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2PrismaticJointDef.js +56 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2PulleyJoint.js +618 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2PulleyJointDef.js +70 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2RevoluteJoint.js +491 -0
- data/vendor/assets/javascripts/box2d/dynamics/joints/b2RevoluteJointDef.js +55 -0
- metadata +133 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2006-2007 Erin Catto http:
|
|
3
|
+
*
|
|
4
|
+
* This software is provided 'as-is', without any express or implied
|
|
5
|
+
* warranty. In no event will the authors be held liable for any damages
|
|
6
|
+
* arising from the use of this software.
|
|
7
|
+
* Permission is granted to anyone to use this software for any purpose,
|
|
8
|
+
* including commercial applications, and to alter it and redistribute it
|
|
9
|
+
* freely, subject to the following restrictions:
|
|
10
|
+
* 1. The origin of this software must not be misrepresented; you must not
|
|
11
|
+
* claim that you wrote the original software. If you use this software
|
|
12
|
+
* in a product, an acknowledgment in the product documentation would be
|
|
13
|
+
* appreciated but is not required.
|
|
14
|
+
* 2. Altered source versions must be plainly marked, and must not be
|
|
15
|
+
* misrepresented the original software.
|
|
16
|
+
* 3. This notice may not be removed or altered from any source distribution.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var b2BodyDef = Class.create();
|
|
24
|
+
b2BodyDef.prototype =
|
|
25
|
+
{
|
|
26
|
+
initialize: function()
|
|
27
|
+
{
|
|
28
|
+
// initialize instance variables for references
|
|
29
|
+
this.shapes = new Array();
|
|
30
|
+
//
|
|
31
|
+
|
|
32
|
+
this.userData = null;
|
|
33
|
+
for (var i = 0; i < b2Settings.b2_maxShapesPerBody; i++){
|
|
34
|
+
this.shapes[i] = null;
|
|
35
|
+
}
|
|
36
|
+
this.position = new b2Vec2(0.0, 0.0);
|
|
37
|
+
this.rotation = 0.0;
|
|
38
|
+
this.linearVelocity = new b2Vec2(0.0, 0.0);
|
|
39
|
+
this.angularVelocity = 0.0;
|
|
40
|
+
this.linearDamping = 0.0;
|
|
41
|
+
this.angularDamping = 0.0;
|
|
42
|
+
this.allowSleep = true;
|
|
43
|
+
this.isSleeping = false;
|
|
44
|
+
this.preventRotation = false;
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
userData: null,
|
|
48
|
+
shapes: new Array(),
|
|
49
|
+
position: null,
|
|
50
|
+
rotation: null,
|
|
51
|
+
linearVelocity: null,
|
|
52
|
+
angularVelocity: null,
|
|
53
|
+
linearDamping: null,
|
|
54
|
+
angularDamping: null,
|
|
55
|
+
allowSleep: null,
|
|
56
|
+
isSleeping: null,
|
|
57
|
+
preventRotation: null,
|
|
58
|
+
|
|
59
|
+
AddShape: function(shape)
|
|
60
|
+
{
|
|
61
|
+
for (var i = 0; i < b2Settings.b2_maxShapesPerBody; ++i)
|
|
62
|
+
{
|
|
63
|
+
if (this.shapes[i] == null)
|
|
64
|
+
{
|
|
65
|
+
this.shapes[i] = shape;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2006-2007 Erin Catto http:
|
|
3
|
+
*
|
|
4
|
+
* This software is provided 'as-is', without any express or implied
|
|
5
|
+
* warranty. In no event will the authors be held liable for any damages
|
|
6
|
+
* arising from the use of this software.
|
|
7
|
+
* Permission is granted to anyone to use this software for any purpose,
|
|
8
|
+
* including commercial applications, and to alter it and redistribute it
|
|
9
|
+
* freely, subject to the following restrictions:
|
|
10
|
+
* 1. The origin of this software must not be misrepresented; you must not
|
|
11
|
+
* claim that you wrote the original software. If you use this software
|
|
12
|
+
* in a product, an acknowledgment in the product documentation would be
|
|
13
|
+
* appreciated but is not required.
|
|
14
|
+
* 2. Altered source versions must be plainly marked, and must not be
|
|
15
|
+
* misrepresented the original software.
|
|
16
|
+
* 3. This notice may not be removed or altered from any source distribution.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var b2CollisionFilter = Class.create();
|
|
26
|
+
b2CollisionFilter.prototype =
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
// Return true if contact calculations should be performed between these two shapes.
|
|
30
|
+
ShouldCollide: function(shape1, shape2){
|
|
31
|
+
if (shape1.m_groupIndex == shape2.m_groupIndex && shape1.m_groupIndex != 0)
|
|
32
|
+
{
|
|
33
|
+
return shape1.m_groupIndex > 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var collide = (shape1.m_maskBits & shape2.m_categoryBits) != 0 && (shape1.m_categoryBits & shape2.m_maskBits) != 0;
|
|
37
|
+
return collide;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
initialize: function() {}};
|
|
42
|
+
b2CollisionFilter.b2_defaultFilter = new b2CollisionFilter;
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2006-2007 Erin Catto http:
|
|
3
|
+
*
|
|
4
|
+
* This software is provided 'as-is', without any express or implied
|
|
5
|
+
* warranty. In no event will the authors be held liable for any damages
|
|
6
|
+
* arising from the use of this software.
|
|
7
|
+
* Permission is granted to anyone to use this software for any purpose,
|
|
8
|
+
* including commercial applications, and to alter it and redistribute it
|
|
9
|
+
* freely, subject to the following restrictions:
|
|
10
|
+
* 1. The origin of this software must not be misrepresented; you must not
|
|
11
|
+
* claim that you wrote the original software. If you use this software
|
|
12
|
+
* in a product, an acknowledgment in the product documentation would be
|
|
13
|
+
* appreciated but is not required.
|
|
14
|
+
* 2. Altered source versions must be plainly marked, and must not be
|
|
15
|
+
* misrepresented the original software.
|
|
16
|
+
* 3. This notice may not be removed or altered from any source distribution.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var b2ContactManager = Class.create();
|
|
24
|
+
Object.extend(b2ContactManager.prototype, b2PairCallback.prototype);
|
|
25
|
+
Object.extend(b2ContactManager.prototype,
|
|
26
|
+
{
|
|
27
|
+
initialize: function(){
|
|
28
|
+
// The constructor for b2PairCallback
|
|
29
|
+
//
|
|
30
|
+
|
|
31
|
+
// initialize instance variables for references
|
|
32
|
+
this.m_nullContact = new b2NullContact();
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
this.m_world = null;
|
|
36
|
+
this.m_destroyImmediate = false;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
// This is a callback from the broadphase when two AABB proxies begin
|
|
40
|
+
// to overlap. We create a b2Contact to manage the narrow phase.
|
|
41
|
+
PairAdded: function(proxyUserData1, proxyUserData2){
|
|
42
|
+
var shape1 = proxyUserData1;
|
|
43
|
+
var shape2 = proxyUserData2;
|
|
44
|
+
|
|
45
|
+
var body1 = shape1.m_body;
|
|
46
|
+
var body2 = shape2.m_body;
|
|
47
|
+
|
|
48
|
+
if (body1.IsStatic() && body2.IsStatic())
|
|
49
|
+
{
|
|
50
|
+
return this.m_nullContact;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (shape1.m_body == shape2.m_body)
|
|
54
|
+
{
|
|
55
|
+
return this.m_nullContact;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (body2.IsConnected(body1))
|
|
59
|
+
{
|
|
60
|
+
return this.m_nullContact;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (this.m_world.m_filter != null && this.m_world.m_filter.ShouldCollide(shape1, shape2) == false)
|
|
64
|
+
{
|
|
65
|
+
return this.m_nullContact;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Ensure that body2 is dynamic (body1 is static or dynamic).
|
|
69
|
+
if (body2.m_invMass == 0.0)
|
|
70
|
+
{
|
|
71
|
+
var tempShape = shape1;
|
|
72
|
+
shape1 = shape2;
|
|
73
|
+
shape2 = tempShape;
|
|
74
|
+
//b2Math.b2Swap(shape1, shape2);
|
|
75
|
+
var tempBody = body1;
|
|
76
|
+
body1 = body2;
|
|
77
|
+
body2 = tempBody;
|
|
78
|
+
//b2Math.b2Swap(body1, body2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Call the factory.
|
|
82
|
+
var contact = b2Contact.Create(shape1, shape2, this.m_world.m_blockAllocator);
|
|
83
|
+
|
|
84
|
+
if (contact == null)
|
|
85
|
+
{
|
|
86
|
+
return this.m_nullContact;
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
{
|
|
90
|
+
// Insert into the world.
|
|
91
|
+
contact.m_prev = null;
|
|
92
|
+
contact.m_next = this.m_world.m_contactList;
|
|
93
|
+
if (this.m_world.m_contactList != null)
|
|
94
|
+
{
|
|
95
|
+
this.m_world.m_contactList.m_prev = contact;
|
|
96
|
+
}
|
|
97
|
+
this.m_world.m_contactList = contact;
|
|
98
|
+
this.m_world.m_contactCount++;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return contact;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
// This is a callback from the broadphase when two AABB proxies cease
|
|
105
|
+
// to overlap. We destroy the b2Contact.
|
|
106
|
+
PairRemoved: function(proxyUserData1, proxyUserData2, pairUserData){
|
|
107
|
+
|
|
108
|
+
if (pairUserData == null)
|
|
109
|
+
{
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var c = pairUserData;
|
|
114
|
+
if (c != this.m_nullContact)
|
|
115
|
+
{
|
|
116
|
+
//b2Settings.b2Assert(this.m_world.m_contactCount > 0);
|
|
117
|
+
if (this.m_destroyImmediate == true)
|
|
118
|
+
{
|
|
119
|
+
this.DestroyContact(c);
|
|
120
|
+
c = null;
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
{
|
|
124
|
+
c.m_flags |= b2Contact.e_destroyFlag;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
DestroyContact: function(c)
|
|
130
|
+
{
|
|
131
|
+
|
|
132
|
+
//b2Settings.b2Assert(this.m_world.m_contactCount > 0);
|
|
133
|
+
|
|
134
|
+
// Remove from the world.
|
|
135
|
+
if (c.m_prev)
|
|
136
|
+
{
|
|
137
|
+
c.m_prev.m_next = c.m_next;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (c.m_next)
|
|
141
|
+
{
|
|
142
|
+
c.m_next.m_prev = c.m_prev;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (c == this.m_world.m_contactList)
|
|
146
|
+
{
|
|
147
|
+
this.m_world.m_contactList = c.m_next;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// If there are contact points, then disconnect from the island graph.
|
|
151
|
+
if (c.GetManifoldCount() > 0)
|
|
152
|
+
{
|
|
153
|
+
var body1 = c.m_shape1.m_body;
|
|
154
|
+
var body2 = c.m_shape2.m_body;
|
|
155
|
+
var node1 = c.m_node1;
|
|
156
|
+
var node2 = c.m_node2;
|
|
157
|
+
|
|
158
|
+
// Wake up touching bodies.
|
|
159
|
+
body1.WakeUp();
|
|
160
|
+
body2.WakeUp();
|
|
161
|
+
|
|
162
|
+
// Remove from body 1
|
|
163
|
+
if (node1.prev)
|
|
164
|
+
{
|
|
165
|
+
node1.prev.next = node1.next;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (node1.next)
|
|
169
|
+
{
|
|
170
|
+
node1.next.prev = node1.prev;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (node1 == body1.m_contactList)
|
|
174
|
+
{
|
|
175
|
+
body1.m_contactList = node1.next;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
node1.prev = null;
|
|
179
|
+
node1.next = null;
|
|
180
|
+
|
|
181
|
+
// Remove from body 2
|
|
182
|
+
if (node2.prev)
|
|
183
|
+
{
|
|
184
|
+
node2.prev.next = node2.next;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (node2.next)
|
|
188
|
+
{
|
|
189
|
+
node2.next.prev = node2.prev;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (node2 == body2.m_contactList)
|
|
193
|
+
{
|
|
194
|
+
body2.m_contactList = node2.next;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
node2.prev = null;
|
|
198
|
+
node2.next = null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Call the factory.
|
|
202
|
+
b2Contact.Destroy(c, this.m_world.m_blockAllocator);
|
|
203
|
+
--this.m_world.m_contactCount;
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
// Destroy any contacts marked for deferred destruction.
|
|
208
|
+
CleanContactList: function()
|
|
209
|
+
{
|
|
210
|
+
var c = this.m_world.m_contactList;
|
|
211
|
+
while (c != null)
|
|
212
|
+
{
|
|
213
|
+
var c0 = c;
|
|
214
|
+
c = c.m_next;
|
|
215
|
+
|
|
216
|
+
if (c0.m_flags & b2Contact.e_destroyFlag)
|
|
217
|
+
{
|
|
218
|
+
this.DestroyContact(c0);
|
|
219
|
+
c0 = null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
// This is the top level collision call for the time step. Here
|
|
226
|
+
// all the narrow phase collision is processed for the world
|
|
227
|
+
// contact list.
|
|
228
|
+
Collide: function()
|
|
229
|
+
{
|
|
230
|
+
var body1;
|
|
231
|
+
var body2;
|
|
232
|
+
var node1;
|
|
233
|
+
var node2;
|
|
234
|
+
|
|
235
|
+
for (var c = this.m_world.m_contactList; c != null; c = c.m_next)
|
|
236
|
+
{
|
|
237
|
+
if (c.m_shape1.m_body.IsSleeping() &&
|
|
238
|
+
c.m_shape2.m_body.IsSleeping())
|
|
239
|
+
{
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
var oldCount = c.GetManifoldCount();
|
|
244
|
+
c.Evaluate();
|
|
245
|
+
|
|
246
|
+
var newCount = c.GetManifoldCount();
|
|
247
|
+
|
|
248
|
+
if (oldCount == 0 && newCount > 0)
|
|
249
|
+
{
|
|
250
|
+
//b2Settings.b2Assert(c.GetManifolds().pointCount > 0);
|
|
251
|
+
|
|
252
|
+
// Connect to island graph.
|
|
253
|
+
body1 = c.m_shape1.m_body;
|
|
254
|
+
body2 = c.m_shape2.m_body;
|
|
255
|
+
node1 = c.m_node1;
|
|
256
|
+
node2 = c.m_node2;
|
|
257
|
+
|
|
258
|
+
// Connect to body 1
|
|
259
|
+
node1.contact = c;
|
|
260
|
+
node1.other = body2;
|
|
261
|
+
|
|
262
|
+
node1.prev = null;
|
|
263
|
+
node1.next = body1.m_contactList;
|
|
264
|
+
if (node1.next != null)
|
|
265
|
+
{
|
|
266
|
+
node1.next.prev = c.m_node1;
|
|
267
|
+
}
|
|
268
|
+
body1.m_contactList = c.m_node1;
|
|
269
|
+
|
|
270
|
+
// Connect to body 2
|
|
271
|
+
node2.contact = c;
|
|
272
|
+
node2.other = body1;
|
|
273
|
+
|
|
274
|
+
node2.prev = null;
|
|
275
|
+
node2.next = body2.m_contactList;
|
|
276
|
+
if (node2.next != null)
|
|
277
|
+
{
|
|
278
|
+
node2.next.prev = node2;
|
|
279
|
+
}
|
|
280
|
+
body2.m_contactList = node2;
|
|
281
|
+
}
|
|
282
|
+
else if (oldCount > 0 && newCount == 0)
|
|
283
|
+
{
|
|
284
|
+
// Disconnect from island graph.
|
|
285
|
+
body1 = c.m_shape1.m_body;
|
|
286
|
+
body2 = c.m_shape2.m_body;
|
|
287
|
+
node1 = c.m_node1;
|
|
288
|
+
node2 = c.m_node2;
|
|
289
|
+
|
|
290
|
+
// Remove from body 1
|
|
291
|
+
if (node1.prev)
|
|
292
|
+
{
|
|
293
|
+
node1.prev.next = node1.next;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (node1.next)
|
|
297
|
+
{
|
|
298
|
+
node1.next.prev = node1.prev;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (node1 == body1.m_contactList)
|
|
302
|
+
{
|
|
303
|
+
body1.m_contactList = node1.next;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
node1.prev = null;
|
|
307
|
+
node1.next = null;
|
|
308
|
+
|
|
309
|
+
// Remove from body 2
|
|
310
|
+
if (node2.prev)
|
|
311
|
+
{
|
|
312
|
+
node2.prev.next = node2.next;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (node2.next)
|
|
316
|
+
{
|
|
317
|
+
node2.next.prev = node2.prev;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (node2 == body2.m_contactList)
|
|
321
|
+
{
|
|
322
|
+
body2.m_contactList = node2.next;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
node2.prev = null;
|
|
326
|
+
node2.next = null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
m_world: null,
|
|
332
|
+
|
|
333
|
+
// This lets us provide broadphase proxy pair user data for
|
|
334
|
+
// contacts that shouldn't exist.
|
|
335
|
+
m_nullContact: new b2NullContact(),
|
|
336
|
+
m_destroyImmediate: null});
|
|
337
|
+
|