-
Notifications
You must be signed in to change notification settings - Fork 1
/
Box2D.js
12064 lines (11936 loc) · 479 KB
/
Box2D.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
var a2j = {};
(function (a2j, window) {
if(!window.flash) window.flash = {utils: {Dictionary: Object} };
else if(!window.flash.utils) window.flash.utils = {Dictionary: Object};
else if(!window.flash.utils.Dictionary) window.flash.utils.Dictionary = Object;
window.Vector = window.Array;
Function.prototype.inherit = function (base) {
var tmpCtr = this;
var empty = Function.prototype.inherit.empty;
empty.prototype = base.prototype;
this.prototype = new empty();
this.prototype.constructor = tmpCtr;
};
Function.prototype.inherit.empty = function () {};
window.trace = function () {
if (window.console && (window.console.log instanceof Function)) window.console.log.apply(window.console, arguments);
};
window.assert = function () {
if (window.console && (window.console.assert instanceof Function)) window.console.assert.apply(window.console, arguments);
};
a2j.warn = function warn() {
if (window.console) console.warn.apply(console, arguments);
};
a2j.generateCallback = function generateCallback(context, cb) {
return function () {
cb.apply(context, arguments);
};
};
a2j.NVector = function NVector(length) {
if (length === undefined) length = 0;
var tmp = new Array(length || 0);
for (var i = 0; i < length; ++i)
tmp[i] = 0;
return tmp;
};
a2j.is = function is(o1, o2) {
if (o1 === null) return false;
if ((o2 instanceof Function) && (o1 instanceof o2)) return true;
if ((o1.constructor.__implements != undefined) && (o1.constructor.__implements[o2])) return true;
return false;
};
a2j.parseUInt = function(v) {
return Math.abs(parseInt(v));
}
})(a2j, window, undefined);
var Vector_a2j_Number = a2j.NVector;
//package structure
if (!window.Box2D) Box2D = {};
if (!window.Box2D.Collision) Box2D.Collision = {};
if (!window.Box2D.Collision.Shapes) Box2D.Collision.Shapes = {};
if (!window.Box2D.Common) Box2D.Common = {};
if (!window.Box2D.Common.Math) Box2D.Common.Math = {};
if (!window.Box2D.Dynamics) Box2D.Dynamics = {};
if (!window.Box2D.Dynamics.Contacts) Box2D.Dynamics.Contacts = {};
if (!window.Box2D.Dynamics.Controllers) Box2D.Dynamics.Controllers = {};
if (!window.Box2D.Dynamics.Joints) Box2D.Dynamics.Joints = {};
//pre-definitions
(function () {
Box2D.Collision.IBroadPhase = 'Box2D.Collision.IBroadPhase';
function b2AABB() {
b2AABB.b2AABB.apply(this, arguments);
};
Box2D.Collision.b2AABB = b2AABB;
function b2Bound() {
b2Bound.b2Bound.apply(this, arguments);
};
Box2D.Collision.b2Bound = b2Bound;
function b2BoundValues() {
b2BoundValues.b2BoundValues.apply(this, arguments);
if (this.constructor === b2BoundValues) this.b2BoundValues.apply(this, arguments);
};
Box2D.Collision.b2BoundValues = b2BoundValues;
function b2BroadPhase() {
b2BroadPhase.b2BroadPhase.apply(this, arguments);
if (this.constructor === b2BroadPhase) this.b2BroadPhase.apply(this, arguments);
};
Box2D.Collision.b2BroadPhase = b2BroadPhase;
function b2Collision() {
b2Collision.b2Collision.apply(this, arguments);
};
Box2D.Collision.b2Collision = b2Collision;
function b2ContactID() {
b2ContactID.b2ContactID.apply(this, arguments);
if (this.constructor === b2ContactID) this.b2ContactID.apply(this, arguments);
};
Box2D.Collision.b2ContactID = b2ContactID;
function b2ContactPoint() {
b2ContactPoint.b2ContactPoint.apply(this, arguments);
};
Box2D.Collision.b2ContactPoint = b2ContactPoint;
function b2Distance() {
b2Distance.b2Distance.apply(this, arguments);
};
Box2D.Collision.b2Distance = b2Distance;
function b2DistanceInput() {
b2DistanceInput.b2DistanceInput.apply(this, arguments);
};
Box2D.Collision.b2DistanceInput = b2DistanceInput;
function b2DistanceOutput() {
b2DistanceOutput.b2DistanceOutput.apply(this, arguments);
};
Box2D.Collision.b2DistanceOutput = b2DistanceOutput;
function b2DistanceProxy() {
b2DistanceProxy.b2DistanceProxy.apply(this, arguments);
};
Box2D.Collision.b2DistanceProxy = b2DistanceProxy;
function b2DynamicTree() {
b2DynamicTree.b2DynamicTree.apply(this, arguments);
if (this.constructor === b2DynamicTree) this.b2DynamicTree.apply(this, arguments);
};
Box2D.Collision.b2DynamicTree = b2DynamicTree;
function b2DynamicTreeBroadPhase() {
b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase.apply(this, arguments);
};
Box2D.Collision.b2DynamicTreeBroadPhase = b2DynamicTreeBroadPhase;
function b2DynamicTreeNode() {
b2DynamicTreeNode.b2DynamicTreeNode.apply(this, arguments);
};
Box2D.Collision.b2DynamicTreeNode = b2DynamicTreeNode;
function b2DynamicTreePair() {
b2DynamicTreePair.b2DynamicTreePair.apply(this, arguments);
};
Box2D.Collision.b2DynamicTreePair = b2DynamicTreePair;
function b2Manifold() {
b2Manifold.b2Manifold.apply(this, arguments);
if (this.constructor === b2Manifold) this.b2Manifold.apply(this, arguments);
};
Box2D.Collision.b2Manifold = b2Manifold;
function b2ManifoldPoint() {
b2ManifoldPoint.b2ManifoldPoint.apply(this, arguments);
if (this.constructor === b2ManifoldPoint) this.b2ManifoldPoint.apply(this, arguments);
};
Box2D.Collision.b2ManifoldPoint = b2ManifoldPoint;
function b2OBB() {
b2OBB.b2OBB.apply(this, arguments);
};
Box2D.Collision.b2OBB = b2OBB;
function b2Pair() {
b2Pair.b2Pair.apply(this, arguments);
};
Box2D.Collision.b2Pair = b2Pair;
function b2PairManager() {
b2PairManager.b2PairManager.apply(this, arguments);
if (this.constructor === b2PairManager) this.b2PairManager.apply(this, arguments);
};
Box2D.Collision.b2PairManager = b2PairManager;
function b2Point() {
b2Point.b2Point.apply(this, arguments);
};
Box2D.Collision.b2Point = b2Point;
function b2Proxy() {
b2Proxy.b2Proxy.apply(this, arguments);
};
Box2D.Collision.b2Proxy = b2Proxy;
function b2RayCastInput() {
b2RayCastInput.b2RayCastInput.apply(this, arguments);
if (this.constructor === b2RayCastInput) this.b2RayCastInput.apply(this, arguments);
};
Box2D.Collision.b2RayCastInput = b2RayCastInput;
function b2RayCastOutput() {
b2RayCastOutput.b2RayCastOutput.apply(this, arguments);
};
Box2D.Collision.b2RayCastOutput = b2RayCastOutput;
function b2Segment() {
b2Segment.b2Segment.apply(this, arguments);
};
Box2D.Collision.b2Segment = b2Segment;
function b2SeparationFunction() {
b2SeparationFunction.b2SeparationFunction.apply(this, arguments);
};
Box2D.Collision.b2SeparationFunction = b2SeparationFunction;
function b2Simplex() {
b2Simplex.b2Simplex.apply(this, arguments);
if (this.constructor === b2Simplex) this.b2Simplex.apply(this, arguments);
};
Box2D.Collision.b2Simplex = b2Simplex;
function b2SimplexCache() {
b2SimplexCache.b2SimplexCache.apply(this, arguments);
};
Box2D.Collision.b2SimplexCache = b2SimplexCache;
function b2SimplexVertex() {
b2SimplexVertex.b2SimplexVertex.apply(this, arguments);
};
Box2D.Collision.b2SimplexVertex = b2SimplexVertex;
function b2TimeOfImpact() {
b2TimeOfImpact.b2TimeOfImpact.apply(this, arguments);
};
Box2D.Collision.b2TimeOfImpact = b2TimeOfImpact;
function b2TOIInput() {
b2TOIInput.b2TOIInput.apply(this, arguments);
};
Box2D.Collision.b2TOIInput = b2TOIInput;
function b2WorldManifold() {
b2WorldManifold.b2WorldManifold.apply(this, arguments);
if (this.constructor === b2WorldManifold) this.b2WorldManifold.apply(this, arguments);
};
Box2D.Collision.b2WorldManifold = b2WorldManifold;
function ClipVertex() {
ClipVertex.ClipVertex.apply(this, arguments);
};
Box2D.Collision.ClipVertex = ClipVertex;
function Features() {
Features.Features.apply(this, arguments);
};
Box2D.Collision.Features = Features;
function b2CircleShape() {
b2CircleShape.b2CircleShape.apply(this, arguments);
if (this.constructor === b2CircleShape) this.b2CircleShape.apply(this, arguments);
};
Box2D.Collision.Shapes.b2CircleShape = b2CircleShape;
function b2EdgeChainDef() {
b2EdgeChainDef.b2EdgeChainDef.apply(this, arguments);
if (this.constructor === b2EdgeChainDef) this.b2EdgeChainDef.apply(this, arguments);
};
Box2D.Collision.Shapes.b2EdgeChainDef = b2EdgeChainDef;
function b2EdgeShape() {
b2EdgeShape.b2EdgeShape.apply(this, arguments);
if (this.constructor === b2EdgeShape) this.b2EdgeShape.apply(this, arguments);
};
Box2D.Collision.Shapes.b2EdgeShape = b2EdgeShape;
function b2MassData() {
b2MassData.b2MassData.apply(this, arguments);
};
Box2D.Collision.Shapes.b2MassData = b2MassData;
function b2PolygonShape() {
b2PolygonShape.b2PolygonShape.apply(this, arguments);
if (this.constructor === b2PolygonShape) this.b2PolygonShape.apply(this, arguments);
};
Box2D.Collision.Shapes.b2PolygonShape = b2PolygonShape;
function b2Shape() {
b2Shape.b2Shape.apply(this, arguments);
if (this.constructor === b2Shape) this.b2Shape.apply(this, arguments);
};
Box2D.Collision.Shapes.b2Shape = b2Shape;
Box2D.Common.b2internal = 'Box2D.Common.b2internal';
function b2Color() {
b2Color.b2Color.apply(this, arguments);
if (this.constructor === b2Color) this.b2Color.apply(this, arguments);
};
Box2D.Common.b2Color = b2Color;
function b2Settings() {
b2Settings.b2Settings.apply(this, arguments);
};
Box2D.Common.b2Settings = b2Settings;
function b2Mat22() {
b2Mat22.b2Mat22.apply(this, arguments);
if (this.constructor === b2Mat22) this.b2Mat22.apply(this, arguments);
};
Box2D.Common.Math.b2Mat22 = b2Mat22;
function b2Mat33() {
b2Mat33.b2Mat33.apply(this, arguments);
if (this.constructor === b2Mat33) this.b2Mat33.apply(this, arguments);
};
Box2D.Common.Math.b2Mat33 = b2Mat33;
function b2Math() {
b2Math.b2Math.apply(this, arguments);
};
Box2D.Common.Math.b2Math = b2Math;
function b2Sweep() {
b2Sweep.b2Sweep.apply(this, arguments);
};
Box2D.Common.Math.b2Sweep = b2Sweep;
function b2Transform() {
b2Transform.b2Transform.apply(this, arguments);
if (this.constructor === b2Transform) this.b2Transform.apply(this, arguments);
};
Box2D.Common.Math.b2Transform = b2Transform;
function b2Vec2() {
b2Vec2.b2Vec2.apply(this, arguments);
if (this.constructor === b2Vec2) this.b2Vec2.apply(this, arguments);
};
Box2D.Common.Math.b2Vec2 = b2Vec2;
function b2Vec3() {
b2Vec3.b2Vec3.apply(this, arguments);
if (this.constructor === b2Vec3) this.b2Vec3.apply(this, arguments);
};
Box2D.Common.Math.b2Vec3 = b2Vec3;
function b2Body() {
b2Body.b2Body.apply(this, arguments);
if (this.constructor === b2Body) this.b2Body.apply(this, arguments);
};
Box2D.Dynamics.b2Body = b2Body;
function b2BodyDef() {
b2BodyDef.b2BodyDef.apply(this, arguments);
if (this.constructor === b2BodyDef) this.b2BodyDef.apply(this, arguments);
};
Box2D.Dynamics.b2BodyDef = b2BodyDef;
function b2ContactFilter() {
b2ContactFilter.b2ContactFilter.apply(this, arguments);
};
Box2D.Dynamics.b2ContactFilter = b2ContactFilter;
function b2ContactImpulse() {
b2ContactImpulse.b2ContactImpulse.apply(this, arguments);
};
Box2D.Dynamics.b2ContactImpulse = b2ContactImpulse;
function b2ContactListener() {
b2ContactListener.b2ContactListener.apply(this, arguments);
};
Box2D.Dynamics.b2ContactListener = b2ContactListener;
function b2ContactManager() {
b2ContactManager.b2ContactManager.apply(this, arguments);
if (this.constructor === b2ContactManager) this.b2ContactManager.apply(this, arguments);
};
Box2D.Dynamics.b2ContactManager = b2ContactManager;
function b2DebugDraw() {
b2DebugDraw.b2DebugDraw.apply(this, arguments);
if (this.constructor === b2DebugDraw) this.b2DebugDraw.apply(this, arguments);
};
Box2D.Dynamics.b2DebugDraw = b2DebugDraw;
function b2DestructionListener() {
b2DestructionListener.b2DestructionListener.apply(this, arguments);
};
Box2D.Dynamics.b2DestructionListener = b2DestructionListener;
function b2FilterData() {
b2FilterData.b2FilterData.apply(this, arguments);
};
Box2D.Dynamics.b2FilterData = b2FilterData;
function b2Fixture() {
b2Fixture.b2Fixture.apply(this, arguments);
if (this.constructor === b2Fixture) this.b2Fixture.apply(this, arguments);
};
Box2D.Dynamics.b2Fixture = b2Fixture;
function b2FixtureDef() {
b2FixtureDef.b2FixtureDef.apply(this, arguments);
if (this.constructor === b2FixtureDef) this.b2FixtureDef.apply(this, arguments);
};
Box2D.Dynamics.b2FixtureDef = b2FixtureDef;
function b2Island() {
b2Island.b2Island.apply(this, arguments);
if (this.constructor === b2Island) this.b2Island.apply(this, arguments);
};
Box2D.Dynamics.b2Island = b2Island;
function b2TimeStep() {
b2TimeStep.b2TimeStep.apply(this, arguments);
};
Box2D.Dynamics.b2TimeStep = b2TimeStep;
function b2World() {
b2World.b2World.apply(this, arguments);
if (this.constructor === b2World) this.b2World.apply(this, arguments);
};
Box2D.Dynamics.b2World = b2World;
function b2CircleContact() {
b2CircleContact.b2CircleContact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2CircleContact = b2CircleContact;
function b2Contact() {
b2Contact.b2Contact.apply(this, arguments);
if (this.constructor === b2Contact) this.b2Contact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2Contact = b2Contact;
function b2ContactConstraint() {
b2ContactConstraint.b2ContactConstraint.apply(this, arguments);
if (this.constructor === b2ContactConstraint) this.b2ContactConstraint.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactConstraint = b2ContactConstraint;
function b2ContactConstraintPoint() {
b2ContactConstraintPoint.b2ContactConstraintPoint.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactConstraintPoint = b2ContactConstraintPoint;
function b2ContactEdge() {
b2ContactEdge.b2ContactEdge.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactEdge = b2ContactEdge;
function b2ContactFactory() {
b2ContactFactory.b2ContactFactory.apply(this, arguments);
if (this.constructor === b2ContactFactory) this.b2ContactFactory.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactFactory = b2ContactFactory;
function b2ContactRegister() {
b2ContactRegister.b2ContactRegister.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactRegister = b2ContactRegister;
function b2ContactResult() {
b2ContactResult.b2ContactResult.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactResult = b2ContactResult;
function b2ContactSolver() {
b2ContactSolver.b2ContactSolver.apply(this, arguments);
if (this.constructor === b2ContactSolver) this.b2ContactSolver.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2ContactSolver = b2ContactSolver;
function b2EdgeAndCircleContact() {
b2EdgeAndCircleContact.b2EdgeAndCircleContact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2EdgeAndCircleContact = b2EdgeAndCircleContact;
function b2NullContact() {
b2NullContact.b2NullContact.apply(this, arguments);
if (this.constructor === b2NullContact) this.b2NullContact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2NullContact = b2NullContact;
function b2PolyAndCircleContact() {
b2PolyAndCircleContact.b2PolyAndCircleContact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2PolyAndCircleContact = b2PolyAndCircleContact;
function b2PolyAndEdgeContact() {
b2PolyAndEdgeContact.b2PolyAndEdgeContact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2PolyAndEdgeContact = b2PolyAndEdgeContact;
function b2PolygonContact() {
b2PolygonContact.b2PolygonContact.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2PolygonContact = b2PolygonContact;
function b2PositionSolverManifold() {
b2PositionSolverManifold.b2PositionSolverManifold.apply(this, arguments);
if (this.constructor === b2PositionSolverManifold) this.b2PositionSolverManifold.apply(this, arguments);
};
Box2D.Dynamics.Contacts.b2PositionSolverManifold = b2PositionSolverManifold;
function b2BuoyancyController() {
b2BuoyancyController.b2BuoyancyController.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2BuoyancyController = b2BuoyancyController;
function b2ConstantAccelController() {
b2ConstantAccelController.b2ConstantAccelController.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2ConstantAccelController = b2ConstantAccelController;
function b2ConstantForceController() {
b2ConstantForceController.b2ConstantForceController.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2ConstantForceController = b2ConstantForceController;
function b2Controller() {
b2Controller.b2Controller.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2Controller = b2Controller;
function b2ControllerEdge() {
b2ControllerEdge.b2ControllerEdge.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2ControllerEdge = b2ControllerEdge;
function b2GravityController() {
b2GravityController.b2GravityController.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2GravityController = b2GravityController;
function b2TensorDampingController() {
b2TensorDampingController.b2TensorDampingController.apply(this, arguments);
};
Box2D.Dynamics.Controllers.b2TensorDampingController = b2TensorDampingController;
function b2DistanceJoint() {
b2DistanceJoint.b2DistanceJoint.apply(this, arguments);
if (this.constructor === b2DistanceJoint) this.b2DistanceJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2DistanceJoint = b2DistanceJoint;
function b2DistanceJointDef() {
b2DistanceJointDef.b2DistanceJointDef.apply(this, arguments);
if (this.constructor === b2DistanceJointDef) this.b2DistanceJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2DistanceJointDef = b2DistanceJointDef;
function b2FrictionJoint() {
b2FrictionJoint.b2FrictionJoint.apply(this, arguments);
if (this.constructor === b2FrictionJoint) this.b2FrictionJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2FrictionJoint = b2FrictionJoint;
function b2FrictionJointDef() {
b2FrictionJointDef.b2FrictionJointDef.apply(this, arguments);
if (this.constructor === b2FrictionJointDef) this.b2FrictionJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2FrictionJointDef = b2FrictionJointDef;
function b2GearJoint() {
b2GearJoint.b2GearJoint.apply(this, arguments);
if (this.constructor === b2GearJoint) this.b2GearJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2GearJoint = b2GearJoint;
function b2GearJointDef() {
b2GearJointDef.b2GearJointDef.apply(this, arguments);
if (this.constructor === b2GearJointDef) this.b2GearJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2GearJointDef = b2GearJointDef;
function b2Jacobian() {
b2Jacobian.b2Jacobian.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2Jacobian = b2Jacobian;
function b2Joint() {
b2Joint.b2Joint.apply(this, arguments);
if (this.constructor === b2Joint) this.b2Joint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2Joint = b2Joint;
function b2JointDef() {
b2JointDef.b2JointDef.apply(this, arguments);
if (this.constructor === b2JointDef) this.b2JointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2JointDef = b2JointDef;
function b2JointEdge() {
b2JointEdge.b2JointEdge.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2JointEdge = b2JointEdge;
function b2LineJoint() {
b2LineJoint.b2LineJoint.apply(this, arguments);
if (this.constructor === b2LineJoint) this.b2LineJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2LineJoint = b2LineJoint;
function b2LineJointDef() {
b2LineJointDef.b2LineJointDef.apply(this, arguments);
if (this.constructor === b2LineJointDef) this.b2LineJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2LineJointDef = b2LineJointDef;
function b2MouseJoint() {
b2MouseJoint.b2MouseJoint.apply(this, arguments);
if (this.constructor === b2MouseJoint) this.b2MouseJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2MouseJoint = b2MouseJoint;
function b2MouseJointDef() {
b2MouseJointDef.b2MouseJointDef.apply(this, arguments);
if (this.constructor === b2MouseJointDef) this.b2MouseJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2MouseJointDef = b2MouseJointDef;
function b2PrismaticJoint() {
b2PrismaticJoint.b2PrismaticJoint.apply(this, arguments);
if (this.constructor === b2PrismaticJoint) this.b2PrismaticJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2PrismaticJoint = b2PrismaticJoint;
function b2PrismaticJointDef() {
b2PrismaticJointDef.b2PrismaticJointDef.apply(this, arguments);
if (this.constructor === b2PrismaticJointDef) this.b2PrismaticJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2PrismaticJointDef = b2PrismaticJointDef;
function b2PulleyJoint() {
b2PulleyJoint.b2PulleyJoint.apply(this, arguments);
if (this.constructor === b2PulleyJoint) this.b2PulleyJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2PulleyJoint = b2PulleyJoint;
function b2PulleyJointDef() {
b2PulleyJointDef.b2PulleyJointDef.apply(this, arguments);
if (this.constructor === b2PulleyJointDef) this.b2PulleyJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2PulleyJointDef = b2PulleyJointDef;
function b2RevoluteJoint() {
b2RevoluteJoint.b2RevoluteJoint.apply(this, arguments);
if (this.constructor === b2RevoluteJoint) this.b2RevoluteJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2RevoluteJoint = b2RevoluteJoint;
function b2RevoluteJointDef() {
b2RevoluteJointDef.b2RevoluteJointDef.apply(this, arguments);
if (this.constructor === b2RevoluteJointDef) this.b2RevoluteJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2RevoluteJointDef = b2RevoluteJointDef;
function b2WeldJoint() {
b2WeldJoint.b2WeldJoint.apply(this, arguments);
if (this.constructor === b2WeldJoint) this.b2WeldJoint.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2WeldJoint = b2WeldJoint;
function b2WeldJointDef() {
b2WeldJointDef.b2WeldJointDef.apply(this, arguments);
if (this.constructor === b2WeldJointDef) this.b2WeldJointDef.apply(this, arguments);
};
Box2D.Dynamics.Joints.b2WeldJointDef = b2WeldJointDef;
})(); //definitions
_A2J_postDefs = []; /* source: disabled*/
(function () {
var Dictionary = flash.utils.Dictionary;
var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;
var b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef;
var b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape;
var b2MassData = Box2D.Collision.Shapes.b2MassData;
var b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
var b2Shape = Box2D.Collision.Shapes.b2Shape;
var b2Color = Box2D.Common.b2Color;
var b2internal = Box2D.Common.b2internal;
var b2Settings = Box2D.Common.b2Settings;
var b2internal = Box2D.Common.b2internal;
var b2Mat22 = Box2D.Common.Math.b2Mat22;
var b2Mat33 = Box2D.Common.Math.b2Mat33;
var b2Math = Box2D.Common.Math.b2Math;
var b2Sweep = Box2D.Common.Math.b2Sweep;
var b2Transform = Box2D.Common.Math.b2Transform;
var b2Vec2 = Box2D.Common.Math.b2Vec2;
var b2Vec3 = Box2D.Common.Math.b2Vec3;
var b2AABB = Box2D.Collision.b2AABB;
var b2Bound = Box2D.Collision.b2Bound;
var b2BoundValues = Box2D.Collision.b2BoundValues;
var b2BroadPhase = Box2D.Collision.b2BroadPhase;
var b2Collision = Box2D.Collision.b2Collision;
var b2ContactID = Box2D.Collision.b2ContactID;
var b2ContactPoint = Box2D.Collision.b2ContactPoint;
var b2Distance = Box2D.Collision.b2Distance;
var b2DistanceInput = Box2D.Collision.b2DistanceInput;
var b2DistanceOutput = Box2D.Collision.b2DistanceOutput;
var b2DistanceProxy = Box2D.Collision.b2DistanceProxy;
var b2DynamicTree = Box2D.Collision.b2DynamicTree;
var b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase;
var b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode;
var b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair;
var b2Manifold = Box2D.Collision.b2Manifold;
var b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint;
var b2OBB = Box2D.Collision.b2OBB;
var b2Pair = Box2D.Collision.b2Pair;
var b2PairManager = Box2D.Collision.b2PairManager;
var b2Point = Box2D.Collision.b2Point;
var b2Proxy = Box2D.Collision.b2Proxy;
var b2RayCastInput = Box2D.Collision.b2RayCastInput;
var b2RayCastOutput = Box2D.Collision.b2RayCastOutput;
var b2Segment = Box2D.Collision.b2Segment;
var b2SeparationFunction = Box2D.Collision.b2SeparationFunction;
var b2Simplex = Box2D.Collision.b2Simplex;
var b2SimplexCache = Box2D.Collision.b2SimplexCache;
var b2SimplexVertex = Box2D.Collision.b2SimplexVertex;
var b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact;
var b2TOIInput = Box2D.Collision.b2TOIInput;
var b2WorldManifold = Box2D.Collision.b2WorldManifold;
var ClipVertex = Box2D.Collision.ClipVertex;
var Features = Box2D.Collision.Features;
var IBroadPhase = Box2D.Collision.IBroadPhase;
var b2internal = Box2D.Common.b2internal;
var b2internal = Box2D.Common.b2internal;
var b2Vec2 = Box2D.Common.Math.b2Vec2;
var b2AABB = Box2D.Collision.b2AABB;
var b2Bound = Box2D.Collision.b2Bound;
var b2BoundValues = Box2D.Collision.b2BoundValues;
var b2BroadPhase = Box2D.Collision.b2BroadPhase;
var b2Collision = Box2D.Collision.b2Collision;
var b2ContactID = Box2D.Collision.b2ContactID;
var b2ContactPoint = Box2D.Collision.b2ContactPoint;
var b2Distance = Box2D.Collision.b2Distance;
var b2DistanceInput = Box2D.Collision.b2DistanceInput;
var b2DistanceOutput = Box2D.Collision.b2DistanceOutput;
var b2DistanceProxy = Box2D.Collision.b2DistanceProxy;
var b2DynamicTree = Box2D.Collision.b2DynamicTree;
var b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase;
var b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode;
var b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair;
var b2Manifold = Box2D.Collision.b2Manifold;
var b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint;
var b2OBB = Box2D.Collision.b2OBB;
var b2Pair = Box2D.Collision.b2Pair;
var b2PairManager = Box2D.Collision.b2PairManager;
var b2Point = Box2D.Collision.b2Point;
var b2Proxy = Box2D.Collision.b2Proxy;
var b2RayCastInput = Box2D.Collision.b2RayCastInput;
var b2RayCastOutput = Box2D.Collision.b2RayCastOutput;
var b2Segment = Box2D.Collision.b2Segment;
var b2SeparationFunction = Box2D.Collision.b2SeparationFunction;
var b2Simplex = Box2D.Collision.b2Simplex;
var b2SimplexCache = Box2D.Collision.b2SimplexCache;
var b2SimplexVertex = Box2D.Collision.b2SimplexVertex;
var b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact;
var b2TOIInput = Box2D.Collision.b2TOIInput;
var b2WorldManifold = Box2D.Collision.b2WorldManifold;
var ClipVertex = Box2D.Collision.ClipVertex;
var Features = Box2D.Collision.Features;
var IBroadPhase = Box2D.Collision.IBroadPhase;
var IBroadPhase = Box2D.Collision.IBroadPhase;
b2AABB.b2AABB = function () {
this.lowerBound = new b2Vec2();
this.upperBound = new b2Vec2();
};
b2AABB.prototype.IsValid = function () {
var dX = this.upperBound.x - this.lowerBound.x;
var dY = this.upperBound.y - this.lowerBound.y;
var valid = dX >= 0.0 && dY >= 0.0;
valid = valid && this.lowerBound.IsValid() && this.upperBound.IsValid();
return valid;
}
b2AABB.prototype.GetCenter = function () {
return new b2Vec2((this.lowerBound.x + this.upperBound.x) / 2, (this.lowerBound.y + this.upperBound.y) / 2);
}
b2AABB.prototype.GetExtents = function () {
return new b2Vec2((this.upperBound.x - this.lowerBound.x) / 2, (this.upperBound.y - this.lowerBound.y) / 2);
}
b2AABB.prototype.Contains = function (aabb) {
var result = true;
result = result && this.lowerBound.x <= aabb.lowerBound.x;
result = result && this.lowerBound.y <= aabb.lowerBound.y;
result = result && aabb.upperBound.x <= this.upperBound.x;
result = result && aabb.upperBound.y <= this.upperBound.y;
return result;
}
b2AABB.prototype.RayCast = function (output, input) {
var tmin = (-Number.MAX_VALUE);
var tmax = Number.MAX_VALUE;
var pX = input.p1.x;
var pY = input.p1.y;
var dX = input.p2.x - input.p1.x;
var dY = input.p2.y - input.p1.y;
var absDX = Math.abs(dX);
var absDY = Math.abs(dY);
var normal = output.normal;
var inv_d = 0;
var t1 = 0;
var t2 = 0;
var t3 = 0;
var s = 0; {
if (absDX < Number.MIN_VALUE) {
if (pX < this.lowerBound.x || this.upperBound.x < pX) return false;
}
else {
inv_d = 1.0 / dX;
t1 = (this.lowerBound.x - pX) * inv_d;
t2 = (this.upperBound.x - pX) * inv_d;
s = (-1.0);
if (t1 > t2) {
t3 = t1;
t1 = t2;
t2 = t3;
s = 1.0;
}
if (t1 > tmin) {
normal.x = s;
normal.y = 0;
tmin = t1;
}
tmax = Math.min(tmax, t2);
if (tmin > tmax) return false;
}
} {
if (absDY < Number.MIN_VALUE) {
if (pY < this.lowerBound.y || this.upperBound.y < pY) return false;
}
else {
inv_d = 1.0 / dY;
t1 = (this.lowerBound.y - pY) * inv_d;
t2 = (this.upperBound.y - pY) * inv_d;
s = (-1.0);
if (t1 > t2) {
t3 = t1;
t1 = t2;
t2 = t3;
s = 1.0;
}
if (t1 > tmin) {
normal.y = s;
normal.x = 0;
tmin = t1;
}
tmax = Math.min(tmax, t2);
if (tmin > tmax) return false;
}
}
output.fraction = tmin;
return true;
}
b2AABB.prototype.TestOverlap = function (other) {
var d1X = other.lowerBound.x - this.upperBound.x;
var d1Y = other.lowerBound.y - this.upperBound.y;
var d2X = this.lowerBound.x - other.upperBound.x;
var d2Y = this.lowerBound.y - other.upperBound.y;
if (d1X > 0.0 || d1Y > 0.0) return false;
if (d2X > 0.0 || d2Y > 0.0) return false;
return true;
}
b2AABB.prototype.Combine = function (aabb1, aabb2) {
var aabb = new b2AABB();
if (this.constructor === Box2D.Collision.b2AABB) this._a2j__Combine(aabb1, aabb2);
else aabb._a2j__Combine(aabb1, aabb2);
return aabb;
}
b2AABB.Combine = b2AABB.prototype.Combine;
b2AABB.prototype._a2j__Combine = function (aabb1, aabb2) {
this.lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x);
this.lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y);
this.upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x);
this.upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y);
}
b2Bound.b2Bound = function () {};
b2Bound.prototype.IsLower = function () {
return (this.value & 1) == 0;
}
b2Bound.prototype.IsUpper = function () {
return (this.value & 1) == 1;
}
b2Bound.prototype.Swap = function (b) {
var tempValue = this.value;
var tempProxy = this.proxy;
var tempStabbingCount = this.stabbingCount;
this.value = b.value;
this.proxy = b.proxy;
this.stabbingCount = b.stabbingCount;
b.value = tempValue;
b.proxy = tempProxy;
b.stabbingCount = tempStabbingCount;
}
b2BoundValues.b2BoundValues = function () {};
b2BoundValues.prototype.b2BoundValues = function () {
this.lowerValues = new Vector_a2j_Number();
this.lowerValues[0] = 0.0;
this.lowerValues[1] = 0.0;
this.upperValues = new Vector_a2j_Number();
this.upperValues[0] = 0.0;
this.upperValues[1] = 0.0;
}
b2BroadPhase.b2BroadPhase = function () {
this.m_pairManager = new b2PairManager();
this.m_proxyPool = new Array();
this.m_querySortKeys = new Array();
this.m_queryResults = new Array();
this.m_quantizationFactor = new b2Vec2();
};
b2BroadPhase.prototype.b2BroadPhase = function (worldAABB) {
var i = 0;
this.m_pairManager.Initialize(this);
this.m_worldAABB = worldAABB;
this.m_proxyCount = 0;
this.m_bounds = new Vector();
for (i = 0;
i < 2; i++) {
this.m_bounds[i] = new Vector();
}
var dX = worldAABB.upperBound.x - worldAABB.lowerBound.x;
var dY = worldAABB.upperBound.y - worldAABB.lowerBound.y;
this.m_quantizationFactor.x = b2Settings.USHRT_MAX / dX;
this.m_quantizationFactor.y = b2Settings.USHRT_MAX / dY;
this.m_timeStamp = 1;
this.m_queryResultCount = 0;
}
b2BroadPhase.prototype.InRange = function (aabb) {
var dX = 0;
var dY = 0;
var d2X = 0;
var d2Y = 0;
dX = aabb.lowerBound.x;
dY = aabb.lowerBound.y;
dX -= this.m_worldAABB.upperBound.x;
dY -= this.m_worldAABB.upperBound.y;
d2X = this.m_worldAABB.lowerBound.x;
d2Y = this.m_worldAABB.lowerBound.y;
d2X -= aabb.upperBound.x;
d2Y -= aabb.upperBound.y;
dX = b2Math.Max(dX, d2X);
dY = b2Math.Max(dY, d2Y);
return b2Math.Max(dX, dY) < 0.0;
}
b2BroadPhase.prototype.CreateProxy = function (aabb, userData) {
var index = 0;
var proxy;
var i = 0;
var j = 0;
if (!this.m_freeProxy) {
this.m_freeProxy = this.m_proxyPool[this.m_proxyCount] = new b2Proxy();
this.m_freeProxy.next = null;
this.m_freeProxy.timeStamp = 0;
this.m_freeProxy.overlapCount = b2BroadPhase.b2_invalid;
this.m_freeProxy.userData = null;
for (i = 0;
i < 2; i++) {
j = this.m_proxyCount * 2;
this.m_bounds[i][j++] = new b2Bound();
this.m_bounds[i][j] = new b2Bound();
}
}
proxy = this.m_freeProxy;
this.m_freeProxy = proxy.next;
proxy.overlapCount = 0;
proxy.userData = userData;
var boundCount = 2 * this.m_proxyCount;
var lowerValues = new Vector_a2j_Number();
var upperValues = new Vector_a2j_Number();
this.ComputeBounds(lowerValues, upperValues, aabb);
for (var axis = 0; axis < 2; ++axis) {
var bounds = this.m_bounds[axis];
var lowerIndex = 0;
var upperIndex = 0;
var lowerIndexOut = new Vector_a2j_Number();
lowerIndexOut.push(lowerIndex);
var upperIndexOut = new Vector_a2j_Number();
upperIndexOut.push(upperIndex);
this.QueryAxis(lowerIndexOut, upperIndexOut, lowerValues[axis], upperValues[axis], bounds, boundCount, axis);
lowerIndex = lowerIndexOut[0];
upperIndex = upperIndexOut[0];
bounds.splice(upperIndex, 0, bounds[bounds.length - 1]);
bounds.length--;
bounds.splice(lowerIndex, 0, bounds[bounds.length - 1]);
bounds.length--;
++upperIndex;
var tBound1 = bounds[lowerIndex];
var tBound2 = bounds[upperIndex];
tBound1.value = lowerValues[axis];
tBound1.proxy = proxy;
tBound2.value = upperValues[axis];