Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 126 files changed
  • 0 comments
  • 1 contributor

Showing 126 changed files with 1,020 additions and 22,673 deletions. Show diff stats Hide diff stats

  1. +0 105 bin-debug/main.html
  2. BIN  bin-debug/main.swf
  3. BIN  bin/Simple-Box2D.swc
  4. BIN  lib/Box2D-2.1a.swc
  5. +0 38 src/Box2D/Collision/ClipVertex.as
  6. +0 82 src/Box2D/Collision/Features.as
  7. +0 48 src/Box2D/Collision/Shapes/b2CircleDef.as
  8. +0 251 src/Box2D/Collision/Shapes/b2CircleShape.as
  9. +0 54 src/Box2D/Collision/Shapes/b2EdgeChainDef.as
  10. +0 468 src/Box2D/Collision/Shapes/b2EdgeShape.as
  11. +0 60 src/Box2D/Collision/Shapes/b2FilterData.as
  12. +0 47 src/Box2D/Collision/Shapes/b2MassData.as
  13. +0 109 src/Box2D/Collision/Shapes/b2PolygonDef.as
  14. +0 868 src/Box2D/Collision/Shapes/b2PolygonShape.as
  15. +0 432 src/Box2D/Collision/Shapes/b2Shape.as
  16. +0 74 src/Box2D/Collision/Shapes/b2ShapeDef.as
  17. +0 192 src/Box2D/Collision/b2AABB.as
  18. +0 48 src/Box2D/Collision/b2Bound.as
  19. +0 31 src/Box2D/Collision/b2BoundValues.as
  20. +0 1,113 src/Box2D/Collision/b2BroadPhase.as
  21. +0 765 src/Box2D/Collision/b2Collision.as
  22. +0 60 src/Box2D/Collision/b2ContactID.as
  23. +0 54 src/Box2D/Collision/b2ContactPoint.as
  24. +0 670 src/Box2D/Collision/b2Distance.as
  25. +0 441 src/Box2D/Collision/b2DynamicTree.as
  26. +0 39 src/Box2D/Collision/b2DynamicTreeNode.as
  27. +0 58 src/Box2D/Collision/b2Manifold.as
  28. +0 60 src/Box2D/Collision/b2ManifoldPoint.as
  29. +0 39 src/Box2D/Collision/b2OBB.as
  30. +0 68 src/Box2D/Collision/b2Pair.as
  31. +0 38 src/Box2D/Collision/b2PairCallback.as
  32. +0 277 src/Box2D/Collision/b2PairManager.as
  33. +0 46 src/Box2D/Collision/b2Point.as
  34. +0 45 src/Box2D/Collision/b2Proxy.as
  35. +0 30 src/Box2D/Collision/b2RayCastInput.as
  36. +0 30 src/Box2D/Collision/b2RayCastOutput.as
  37. +0 159 src/Box2D/Collision/b2Segment.as
  38. +0 355 src/Box2D/Collision/b2TimeOfImpact.as
  39. +0 139 src/Box2D/Common/Math/b2Mat22.as
  40. +0 147 src/Box2D/Common/Math/b2Mat33.as
  41. +0 270 src/Box2D/Common/Math/b2Math.as
  42. +0 119 src/Box2D/Common/Math/b2Sweep.as
  43. +0 142 src/Box2D/Common/Math/b2Vec2.as
  44. +0 95 src/Box2D/Common/Math/b2Vec3.as
  45. +0 84 src/Box2D/Common/Math/b2XForm.as
  46. +0 69 src/Box2D/Common/b2Color.as
  47. +0 182 src/Box2D/Common/b2Settings.as
  48. +0 21 src/Box2D/Common/b2internal.as
  49. +0 147 src/Box2D/Dynamics/Contacts/b2CircleContact.as
  50. +0 273 src/Box2D/Dynamics/Contacts/b2Contact.as
  51. +0 57 src/Box2D/Dynamics/Contacts/b2ContactConstraint.as
  52. +0 47 src/Box2D/Dynamics/Contacts/b2ContactConstraintPoint.as
  53. +0 45 src/Box2D/Dynamics/Contacts/b2ContactEdge.as
  54. +0 34 src/Box2D/Dynamics/Contacts/b2ContactRegister.as
  55. +0 50 src/Box2D/Dynamics/Contacts/b2ContactResult.as
  56. +0 897 src/Box2D/Dynamics/Contacts/b2ContactSolver.as
  57. +0 260 src/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.as
  58. +0 39 src/Box2D/Dynamics/Contacts/b2NullContact.as
  59. +0 185 src/Box2D/Dynamics/Contacts/b2PolyAndCircleContact.as
  60. +0 496 src/Box2D/Dynamics/Contacts/b2PolyAndEdgeContact.as
  61. +0 187 src/Box2D/Dynamics/Contacts/b2PolygonContact.as
  62. +0 123 src/Box2D/Dynamics/Controllers/b2BuoyancyController.as
  63. +0 48 src/Box2D/Dynamics/Controllers/b2ConstantAccelController.as
  64. +0 43 src/Box2D/Dynamics/Controllers/b2ConstantForceController.as
  65. +0 107 src/Box2D/Dynamics/Controllers/b2Controller.as
  66. +0 19 src/Box2D/Dynamics/Controllers/b2ControllerEdge.as
  67. +0 96 src/Box2D/Dynamics/Controllers/b2GravityController.as
  68. +0 85 src/Box2D/Dynamics/Controllers/b2TensorDampingController.as
  69. +0 323 src/Box2D/Dynamics/Joints/b2DistanceJoint.as
  70. +0 95 src/Box2D/Dynamics/Joints/b2DistanceJointDef.as
  71. +0 350 src/Box2D/Dynamics/Joints/b2GearJoint.as
  72. +0 61 src/Box2D/Dynamics/Joints/b2GearJointDef.as
  73. +0 54 src/Box2D/Dynamics/Joints/b2Jacobian.as
  74. +0 270 src/Box2D/Dynamics/Joints/b2Joint.as
  75. +0 68 src/Box2D/Dynamics/Joints/b2JointDef.as
  76. +0 50 src/Box2D/Dynamics/Joints/b2JointEdge.as
  77. +0 748 src/Box2D/Dynamics/Joints/b2LineJoint.as
  78. +0 111 src/Box2D/Dynamics/Joints/b2LineJointDef.as
  79. +0 243 src/Box2D/Dynamics/Joints/b2MouseJoint.as
  80. +0 64 src/Box2D/Dynamics/Joints/b2MouseJointDef.as
  81. +0 787 src/Box2D/Dynamics/Joints/b2PrismaticJoint.as
  82. +0 116 src/Box2D/Dynamics/Joints/b2PrismaticJointDef.as
  83. +0 669 src/Box2D/Dynamics/Joints/b2PulleyJoint.as
  84. +0 131 src/Box2D/Dynamics/Joints/b2PulleyJointDef.as
  85. +0 651 src/Box2D/Dynamics/Joints/b2RevoluteJoint.as
  86. +0 121 src/Box2D/Dynamics/Joints/b2RevoluteJointDef.as
  87. +0 1,162 src/Box2D/Dynamics/b2Body.as
  88. +0 135 src/Box2D/Dynamics/b2BodyDef.as
  89. +0 47 src/Box2D/Dynamics/b2BoundaryListener.as
  90. +0 76 src/Box2D/Dynamics/b2ContactFilter.as
  91. +0 72 src/Box2D/Dynamics/b2ContactListener.as
  92. +0 269 src/Box2D/Dynamics/b2ContactManager.as
  93. +0 304 src/Box2D/Dynamics/b2DebugDraw.as
  94. +0 55 src/Box2D/Dynamics/b2DestructionListener.as
  95. +0 514 src/Box2D/Dynamics/b2Island.as
  96. +0 36 src/Box2D/Dynamics/b2TimeStep.as
  97. +0 1,585 src/Box2D/Dynamics/b2World.as
  98. +638 646 src/couk/psyked/box2d/Box2DWorld.as
  99. +0 90 src/couk/psyked/box2d/utils/Box2DMouseUtils.as
  100. +0 98 src/couk/psyked/box2d/utils/Box2DPointUtils.as
  101. +0 79 src/couk/psyked/box2d/utils/Box2DUtils.as
  102. +0 136 src/couk/psyked/box2d/utils/GrahamScan.as
  103. +101 97 src/couk/psyked/box2d/utils/PointUtils.as
  104. +0 131 src/couk/psyked/box2d/utils/PolygonTool.as
  105. +0 184 src/couk/psyked/box2d/utils/Triangulate.as
  106. +78 0 src/couk/psyked/box2d/utils/WorldUtils.as
  107. +7 5 src/couk/psyked/box2d/utils/library/{Box2DShapeParser.as → ShapeParser.as}
  108. +8 8 src/couk/psyked/box2d/utils/library/{Box2DShapeRecord.as → ShapeRecord.as}
  109. +1 6 src/couk/psyked/box2d/utils/shape/CurveToArray.as
  110. +5 5 src/couk/psyked/box2d/utils/shape/GrahamScan.as
  111. +164 166 src/couk/psyked/box2d/utils/shape/PolygonTool.as
  112. +5 4 src/couk/psyked/box2d/utils/shape/Triangulate.as
  113. +7 5 src/couk/psyked/box2d/utils/shape/Triangulator.as
  114. +6 6 src/couk/psyked/box2d/{utils/Box2DWorldOptions.as → vo/WorldOptions.as}
  115. +0 80 src/couk/psyked/utils/KeyboardManager.as
  116. 0  {src → test}/Box2DExperiments.as
  117. 0  {src → test}/ComplexPolygonExample.as
  118. 0  {src → test}/CurvedShapeExample.as
  119. 0  {src → test}/LettersExperiment.as
  120. 0  {src → test}/LibraryShapeExample.as
  121. 0  {src → test}/assets/letters_assets.fla
  122. 0  {src → test}/assets/letters_assets.swf
  123. 0  {src → test}/assets/stars_assets.fla
  124. 0  {src → test}/assets/stars_assets.swf
  125. 0  {src → test}/assets/vectorassets.fla
  126. 0  {src → test}/assets/vectorassets.swf
105 bin-debug/main.html
... ... @@ -1,105 +0,0 @@
1   -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2   -<!-- saved from url=(0014)about:internet -->
3   -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4   - <!--
5   - Smart developers always View Source.
6   -
7   - This application was built using Adobe Flex, an open source framework
8   - for building rich Internet applications that get delivered via the
9   - Flash Player or to desktops via Adobe AIR.
10   -
11   - Learn more about Flex at http://flex.org
12   - // -->
13   - <head>
14   - <title></title>
15   - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
16   - <!-- Include CSS to eliminate any default margins/padding and set the height of the html element and
17   - the body element to 100%, because Firefox, or any Gecko based browser, interprets percentage as
18   - the percentage of the height of its parent container, which has to be set explicitly. Initially,
19   - don't display flashContent div so it won't show if JavaScript disabled.
20   - -->
21   - <style type="text/css" media="screen">
22   - html, body { height:100%; }
23   - body { margin:0; padding:0; overflow:auto; text-align:center;
24   - background-color: #ffffff; }
25   - #flashContent { display:none; }
26   - </style>
27   -
28   - <!-- Enable Browser History by replacing useBrowserHistory tokens with two hyphens -->
29   - <!-- BEGIN Browser History required section -->
30   - <link rel="stylesheet" type="text/css" href="history/history.css" />
31   - <script type="text/javascript" src="history/history.js"></script>
32   - <!-- END Browser History required section -->
33   -
34   - <script type="text/javascript" src="swfobject.js"></script>
35   - <script type="text/javascript">
36   - <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
37   - var swfVersionStr = "10.0.0";
38   - <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
39   - var xiSwfUrlStr = "playerProductInstall.swf";
40   - var flashvars = {};
41   - var params = {};
42   - params.quality = "high";
43   - params.bgcolor = "#ffffff";
44   - params.allowscriptaccess = "sameDomain";
45   - params.allowfullscreen = "true";
46   - var attributes = {};
47   - attributes.id = "main";
48   - attributes.name = "main";
49   - attributes.align = "middle";
50   - swfobject.embedSWF(
51   - "main.swf", "flashContent",
52   - "100%", "100%",
53   - swfVersionStr, xiSwfUrlStr,
54   - flashvars, params, attributes);
55   - <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
56   - swfobject.createCSS("#flashContent", "display:block;text-align:left;");
57   - </script>
58   - </head>
59   - <body>
60   - <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough
61   - JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
62   - when JavaScript is disabled.
63   - -->
64   - <div id="flashContent">
65   - <p>
66   - To view this page ensure that Adobe Flash Player version
67   - 10.0.0 or greater is installed.
68   - </p>
69   - <script type="text/javascript">
70   - var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
71   - document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"
72   - + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
73   - </script>
74   - </div>
75   -
76   - <noscript>
77   - <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="main">
78   - <param name="movie" value="main.swf" />
79   - <param name="quality" value="high" />
80   - <param name="bgcolor" value="#ffffff" />
81   - <param name="allowScriptAccess" value="sameDomain" />
82   - <param name="allowFullScreen" value="true" />
83   - <!--[if !IE]>-->
84   - <object type="application/x-shockwave-flash" data="main.swf" width="100%" height="100%">
85   - <param name="quality" value="high" />
86   - <param name="bgcolor" value="#ffffff" />
87   - <param name="allowScriptAccess" value="sameDomain" />
88   - <param name="allowFullScreen" value="true" />
89   - <!--<![endif]-->
90   - <!--[if gte IE 6]>-->
91   - <p>
92   - Either scripts and active content are not permitted to run or Adobe Flash Player version
93   - 10.0.0 or greater is not installed.
94   - </p>
95   - <!--<![endif]-->
96   - <a href="http://www.adobe.com/go/getflashplayer">
97   - <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
98   - </a>
99   - <!--[if !IE]>-->
100   - </object>
101   - <!--<![endif]-->
102   - </object>
103   - </noscript>
104   - </body>
105   -</html>
BIN  bin-debug/main.swf
Binary file not shown
BIN  bin/Simple-Box2D.swc
Binary file not shown
BIN  lib/Box2D-2.1a.swc
Binary file not shown
38 src/Box2D/Collision/ClipVertex.as
... ... @@ -1,38 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision{
20   -
21   -
22   -import Box2D.Common.Math.*;
23   -import Box2D.Collision.*;
24   - import Box2D.Common.b2internal;
25   -use namespace b2internal;
26   -
27   -
28   -/**
29   -* @private
30   -*/
31   -public class ClipVertex
32   -{
33   - public var v:b2Vec2 = new b2Vec2();
34   - public var id:b2ContactID = new b2ContactID();
35   -};
36   -
37   -
38   -}
82 src/Box2D/Collision/Features.as
... ... @@ -1,82 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision {
20   -
21   -import Box2D.Common.b2internal;
22   -use namespace b2internal;
23   -
24   -/**
25   -* We use contact ids to facilitate warm starting.
26   -*/
27   -public class Features
28   -{
29   - /**
30   - * The edge that defines the outward contact normal.
31   - */
32   - public function get referenceEdge():int{
33   - return _referenceEdge;
34   - }
35   - public function set referenceEdge(value:int) : void{
36   - _referenceEdge = value;
37   - _m_id._key = (_m_id._key & 0xffffff00) | (_referenceEdge & 0x000000ff);
38   - }
39   - b2internal var _referenceEdge:int;
40   -
41   - /**
42   - * The edge most anti-parallel to the reference edge.
43   - */
44   - public function get incidentEdge():int{
45   - return _incidentEdge;
46   - }
47   - public function set incidentEdge(value:int) : void{
48   - _incidentEdge = value;
49   - _m_id._key = (_m_id._key & 0xffff00ff) | ((_incidentEdge << 8) & 0x0000ff00);
50   - }
51   - b2internal var _incidentEdge:int;
52   -
53   - /**
54   - * The vertex (0 or 1) on the incident edge that was clipped.
55   - */
56   - public function get incidentVertex():int{
57   - return _incidentVertex;
58   - }
59   - public function set incidentVertex(value:int) : void{
60   - _incidentVertex = value;
61   - _m_id._key = (_m_id._key & 0xff00ffff) | ((_incidentVertex << 16) & 0x00ff0000);
62   - }
63   - b2internal var _incidentVertex:int;
64   -
65   - /**
66   - * A value of 1 indicates that the reference edge is on shape2.
67   - */
68   - public function get flip():int{
69   - return _flip;
70   - }
71   - public function set flip(value:int) : void{
72   - _flip = value;
73   - _m_id._key = (_m_id._key & 0x00ffffff) | ((_flip << 24) & 0xff000000);
74   - }
75   - b2internal var _flip:int;
76   -
77   -
78   - b2internal var _m_id:b2ContactID;
79   -};
80   -
81   -
82   -}
48 src/Box2D/Collision/Shapes/b2CircleDef.as
... ... @@ -1,48 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Collision.Shapes.*;
25   -
26   -import Box2D.Common.b2internal;
27   -use namespace b2internal;
28   -
29   -
30   -/**
31   -* This structure is used to build circle shapes.
32   -* @see b2CircleShape
33   -*/
34   -public class b2CircleDef extends b2ShapeDef
35   -{
36   - public function b2CircleDef()
37   - {
38   - type = b2Shape.e_circleShape;
39   - radius = 1.0;
40   - }
41   -
42   - /** The circle center in local coordinages */
43   - public var localPosition:b2Vec2 = new b2Vec2(0.0, 0.0);
44   - /** The circle radius */
45   - public var radius:Number;
46   -};
47   -
48   -}
251 src/Box2D/Collision/Shapes/b2CircleShape.as
... ... @@ -1,251 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Common.*;
25   -import Box2D.Collision.Shapes.*;
26   -import Box2D.Dynamics.*;
27   -import Box2D.Collision.*;
28   -
29   -import Box2D.Common.b2internal;
30   -use namespace b2internal;
31   -
32   -
33   -
34   -/**
35   -* A circle shape.
36   -* @see b2CircleDef
37   -*/
38   -public class b2CircleShape extends b2Shape
39   -{
40   - /**
41   - * @inheritDoc
42   - */
43   - public override function TestPoint(transform:b2XForm, p:b2Vec2) : Boolean{
44   - //b2Vec2 center = transform.position + b2Mul(transform.R, m_localPosition);
45   - var tMat:b2Mat22 = transform.R;
46   - var dX:Number = transform.position.x + (tMat.col1.x * m_localPosition.x + tMat.col2.x * m_localPosition.y);
47   - var dY:Number = transform.position.y + (tMat.col1.y * m_localPosition.x + tMat.col2.y * m_localPosition.y);
48   - //b2Vec2 d = p - center;
49   - dX = p.x - dX;
50   - dY = p.y - dY;
51   - //return b2Dot(d, d) <= m_radius * m_radius;
52   - return (dX*dX + dY*dY) <= m_radius * m_radius;
53   - }
54   -
55   - /**
56   - * @inheritDoc
57   - */
58   - public override function TestSegment( transform:b2XForm,
59   - lambda:Array, // float pointer
60   - normal:b2Vec2, // pointer
61   - segment:b2Segment,
62   - maxLambda:Number) :int
63   - {
64   - //b2Vec2 position = transform.position + b2Mul(transform.R, m_localPosition);
65   - var tMat:b2Mat22 = transform.R;
66   - var positionX:Number = transform.position.x + (tMat.col1.x * m_localPosition.x + tMat.col2.x * m_localPosition.y);
67   - var positionY:Number = transform.position.y + (tMat.col1.y * m_localPosition.x + tMat.col2.y * m_localPosition.y);
68   -
69   - //b2Vec2 s = segment.p1 - position;
70   - var sX:Number = segment.p1.x - positionX;
71   - var sY:Number = segment.p1.y - positionY;
72   - //float32 b = b2Dot(s, s) - m_radius * m_radius;
73   - var b:Number = (sX*sX + sY*sY) - m_radius * m_radius;
74   -
75   - // Does the segment start inside the circle?
76   - if (b < 0.0)
77   - {
78   - lambda[0]=0;
79   - return e_startsInsideCollide;
80   - }
81   -
82   - // Solve quadratic equation.
83   - //b2Vec2 r = segment.p2 - segment.p1;
84   - var rX:Number = segment.p2.x - segment.p1.x;
85   - var rY:Number = segment.p2.y - segment.p1.y;
86   - //float32 c = b2Dot(s, r);
87   - var c:Number = (sX*rX + sY*rY);
88   - //float32 rr = b2Dot(r, r);
89   - var rr:Number = (rX*rX + rY*rY);
90   - var sigma:Number = c * c - rr * b;
91   -
92   - // Check for negative discriminant and short segment.
93   - if (sigma < 0.0 || rr < Number.MIN_VALUE)
94   - {
95   - return e_missCollide;
96   - }
97   -
98   - // Find the point of intersection of the line with the circle.
99   - var a:Number = -(c + Math.sqrt(sigma));
100   -
101   - // Is the intersection point on the segment?
102   - if (0.0 <= a && a <= maxLambda * rr)
103   - {
104   - a /= rr;
105   - //*lambda = a;
106   - lambda[0] = a;
107   - //*normal = s + a * r;
108   - normal.x = sX + a * rX;
109   - normal.y = sY + a * rY;
110   - normal.Normalize();
111   - return e_hitCollide;
112   - }
113   -
114   - return e_missCollide;
115   - }
116   -
117   - /**
118   - * @inheritDoc
119   - */
120   - public override function ComputeAABB(aabb:b2AABB, transform:b2XForm) : void{
121   - //b2Vec2 p = transform.position + b2Mul(transform.R, m_localPosition);
122   - var tMat:b2Mat22 = transform.R;
123   - var pX:Number = transform.position.x + (tMat.col1.x * m_localPosition.x + tMat.col2.x * m_localPosition.y);
124   - var pY:Number = transform.position.y + (tMat.col1.y * m_localPosition.x + tMat.col2.y * m_localPosition.y);
125   - aabb.lowerBound.Set(pX - m_radius, pY - m_radius);
126   - aabb.upperBound.Set(pX + m_radius, pY + m_radius);
127   - }
128   -
129   - /**
130   - * @inheritDoc
131   - */
132   - public override function ComputeSweptAABB( aabb:b2AABB,
133   - transform1:b2XForm,
134   - transform2:b2XForm) : void
135   - {
136   - var tMat:b2Mat22;
137   - //b2Vec2 p1 = transform1.position + b2Mul(transform1.R, m_localPosition);
138   - tMat = transform1.R;
139   - var p1X:Number = transform1.position.x + (tMat.col1.x * m_localPosition.x + tMat.col2.x * m_localPosition.y);
140   - var p1Y:Number = transform1.position.y + (tMat.col1.y * m_localPosition.x + tMat.col2.y * m_localPosition.y);
141   - //b2Vec2 p2 = transform2.position + b2Mul(transform2.R, m_localPosition);
142   - tMat = transform2.R;
143   - var p2X:Number = transform2.position.x + (tMat.col1.x * m_localPosition.x + tMat.col2.x * m_localPosition.y);
144   - var p2Y:Number = transform2.position.y + (tMat.col1.y * m_localPosition.x + tMat.col2.y * m_localPosition.y);
145   -
146   - //b2Vec2 lower = b2Min(p1, p2);
147   - //b2Vec2 upper = b2Max(p1, p2);
148   -
149   - //aabb->lowerBound.Set(lower.x - m_radius, lower.y - m_radius);
150   - aabb.lowerBound.Set((p1X < p2X ? p1X : p2X) - m_radius, (p1Y < p2Y ? p1Y : p2Y) - m_radius);
151   - //aabb->upperBound.Set(upper.x + m_radius, upper.y + m_radius);
152   - aabb.upperBound.Set((p1X > p2X ? p1X : p2X) + m_radius, (p1Y > p2Y ? p1Y : p2Y) + m_radius);
153   - }
154   -
155   - /**
156   - * @inheritDoc
157   - */
158   - public override function ComputeMass(massData:b2MassData) : void{
159   - massData.mass = m_density * b2Settings.b2_pi * m_radius * m_radius;
160   - massData.center.SetV(m_localPosition);
161   -
162   - // inertia about the local origin
163   - //massData.I = massData.mass * (0.5 * m_radius * m_radius + b2Dot(m_localPosition, m_localPosition));
164   - massData.I = massData.mass * (0.5 * m_radius * m_radius + (m_localPosition.x*m_localPosition.x + m_localPosition.y*m_localPosition.y));
165   - }
166   -
167   - /**
168   - * @inheritDoc
169   - */
170   - public override function ComputeSubmergedArea(
171   - normal:b2Vec2,
172   - offset:Number,
173   - xf:b2XForm,
174   - c:b2Vec2):Number
175   - {
176   - var p:b2Vec2 = b2Math.b2MulX(xf, m_localPosition);
177   - var l:Number = -(b2Math.b2Dot(normal, p) - offset);
178   -
179   - if (l < -m_radius + Number.MIN_VALUE)
180   - {
181   - //Completely dry
182   - return 0;
183   - }
184   - if (l > m_radius)
185   - {
186   - //Completely wet
187   - c.SetV(p);
188   - return Math.PI * m_radius * m_radius;
189   - }
190   -
191   - //Magic
192   - var r2:Number = m_radius * m_radius;
193   - var l2:Number = l * l;
194   - var area:Number = r2 *( Math.asin(l / m_radius) + Math.PI / 2) + l * Math.sqrt( r2 - l2 );
195   - var com:Number = -2 / 3 * Math.pow(r2 - l2, 1.5) / area;
196   -
197   - c.x = p.x + normal.x * com;
198   - c.y = p.y + normal.y * com;
199   -
200   - return area;
201   - }
202   -
203   - /**
204   - * Get the local position of this circle in its parent body.
205   - */
206   - public function GetLocalPosition() : b2Vec2{
207   - return m_localPosition;
208   - }
209   -
210   - /**
211   - * Get the radius of this circle.
212   - */
213   - public function GetRadius() : Number{
214   - return m_radius;
215   - }
216   -
217   - //--------------- Internals Below -------------------
218   -
219   - /**
220   - * @private
221   - */
222   - public function b2CircleShape(def:b2ShapeDef){
223   - super(def);
224   -
225   - //b2Settings.b2Assert(def.type == e_circleShape);
226   - var circleDef:b2CircleDef = def as b2CircleDef;
227   -
228   - m_type = e_circleShape;
229   - m_localPosition.SetV(circleDef.localPosition);
230   - m_radius = circleDef.radius;
231   -
232   - }
233   -
234   - b2internal override function UpdateSweepRadius(center:b2Vec2) : void{
235   - // Update the sweep radius (maximum radius) as measured from
236   - // a local center point.
237   - //b2Vec2 d = m_localPosition - center;
238   - var dX:Number = m_localPosition.x - center.x;
239   - var dY:Number = m_localPosition.y - center.y;
240   - dX = Math.sqrt(dX*dX + dY*dY); // length
241   - //m_sweepRadius = d.Length() + m_radius - b2_toiSlop;
242   - m_sweepRadius = dX + m_radius - b2Settings.b2_toiSlop;
243   - }
244   -
245   - // Local position in parent body
246   - b2internal var m_localPosition:b2Vec2 = new b2Vec2();
247   - b2internal var m_radius:Number;
248   -
249   -};
250   -
251   -}
54 src/Box2D/Collision/Shapes/b2EdgeChainDef.as
... ... @@ -1,54 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Collision.Shapes.*;
25   -
26   -import Box2D.Common.b2internal;
27   -use namespace b2internal;
28   -
29   -
30   -/**
31   -* This structure is used to build edge shapes.
32   -* @see b2EdgeShape
33   -*/
34   -public class b2EdgeChainDef extends b2ShapeDef
35   -{
36   - public function b2EdgeChainDef()
37   - {
38   - type = b2Shape.e_edgeShape;
39   - vertexCount = 0;
40   - isALoop = true;
41   - vertices = [];
42   - }
43   -
44   - /** The vertices in local coordinates. */
45   - public var vertices: Array;
46   -
47   - /** The number of vertices in the chain. */
48   - public var vertexCount: int;
49   -
50   - /** Whether to create an extra edge between the first and last vertices. */
51   - public var isALoop: Boolean;
52   -};
53   -
54   -}
468 src/Box2D/Collision/Shapes/b2EdgeShape.as
... ... @@ -1,468 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Common.*;
25   -import Box2D.Collision.Shapes.*;
26   -import Box2D.Dynamics.*;
27   -import Box2D.Collision.*;
28   -
29   -import Box2D.Common.b2internal;
30   -use namespace b2internal;
31   -
32   -
33   -
34   -/**
35   -* An edge shape.
36   -* @see b2EdgeChainDef
37   -*/
38   -public class b2EdgeShape extends b2Shape
39   -{
40   - /**
41   - * Returns false. Edges cannot contain points.
42   - */
43   - public override function TestPoint(transform:b2XForm, p:b2Vec2) : Boolean{
44   - return false;
45   - }
46   -
47   - /**
48   - * @inheritDoc
49   - */
50   - public override function TestSegment( transform:b2XForm,
51   - lambda:Array, // float pointer
52   - normal:b2Vec2, // pointer
53   - segment:b2Segment,
54   - maxLambda:Number) :int
55   - {
56   - var tMat:b2Mat22;
57   - var rX: Number = segment.p2.x - segment.p1.x;
58   - var rY: Number = segment.p2.y - segment.p1.y;
59   -
60   - //b2Vec2 v1 = b2Mul(transform, m_v1);
61   - tMat = transform.R;
62   - var v1X: Number = transform.position.x + (tMat.col1.x * m_v1.x + tMat.col2.x * m_v1.y);
63   - var v1Y: Number = transform.position.y + (tMat.col1.y * m_v1.x + tMat.col2.y * m_v1.y);
64   -
65   - //b2Vec2 n = b2Cross(d, 1.0);
66   - var nX: Number = transform.position.y + (tMat.col1.y * m_v2.x + tMat.col2.y * m_v2.y) - v1Y;
67   - var nY: Number = -(transform.position.x + (tMat.col1.x * m_v2.x + tMat.col2.x * m_v2.y) - v1X);
68   -
69   - var k_slop: Number = 100.0 * Number.MIN_VALUE;
70   - var denom: Number = -(rX * nX + rY * nY);
71   -
72   - // Cull back facing collision and ignore parallel segments.
73   - if (denom > k_slop)
74   - {
75   - // Does the segment intersect the infinite line associated with this segment?
76   - var bX: Number = segment.p1.x - v1X;
77   - var bY: Number = segment.p1.y - v1Y;
78   - var a: Number = (bX * nX + bY * nY);
79   -
80   - if (0.0 <= a && a <= maxLambda * denom)
81   - {
82   - var mu2: Number = -rX * bY + rY * bX;
83   -
84   - // Does the segment intersect this segment?
85   - if (-k_slop * denom <= mu2 && mu2 <= denom * (1.0 + k_slop))
86   - {
87   - a /= denom;
88   - lambda[0] = a;
89   - var nLen: Number = Math.sqrt(nX * nX + nY * nY);
90   - normal.x = nX / nLen;
91   - normal.y = nY / nLen;
92   - return e_hitCollide;
93   - }
94   - }
95   - }
96   -
97   - return e_missCollide;
98   - }
99   -
100   - /**
101   - * @inheritDoc
102   - */
103   - public override function ComputeAABB(aabb:b2AABB, transform:b2XForm) : void{
104   - var tMat:b2Mat22 = transform.R;
105   - //b2Vec2 v1 = b2Mul(transform, m_v1);
106   - var v1X:Number = transform.position.x + (tMat.col1.x * m_v1.x + tMat.col2.x * m_v1.y);
107   - var v1Y:Number = transform.position.y + (tMat.col1.y * m_v1.x + tMat.col2.y * m_v1.y);
108   - //b2Vec2 v2 = b2Mul(transform, m_v2);
109   - var v2X:Number = transform.position.x + (tMat.col1.x * m_v2.x + tMat.col2.x * m_v2.y);
110   - var v2Y:Number = transform.position.y + (tMat.col1.y * m_v2.x + tMat.col2.y * m_v2.y);
111   - if (v1X < v2X) {
112   - aabb.lowerBound.x = v1X;
113   - aabb.upperBound.x = v2X;
114   - } else {
115   - aabb.lowerBound.x = v2X;
116   - aabb.upperBound.x = v1X;
117   - }
118   - if (v1Y < v2Y) {
119   - aabb.lowerBound.y = v1Y;
120   - aabb.upperBound.y = v2Y;
121   - } else {
122   - aabb.lowerBound.y = v2Y;
123   - aabb.upperBound.y = v1Y;
124   - }
125   - }
126   -
127   - /**
128   - * @inheritDoc
129   - */
130   - public override function ComputeSweptAABB( aabb:b2AABB,
131   - transform1:b2XForm,
132   - transform2:b2XForm) : void
133   - {
134   - var tMat:b2Mat22;
135   - tMat = transform1.R;
136   - //b2Vec2 v1 = b2Mul(transform1, m_v1);
137   - var v1X:Number = transform1.position.x + (tMat.col1.x * m_v1.x + tMat.col2.x * m_v1.y);
138   - var v1Y:Number = transform1.position.y + (tMat.col1.y * m_v1.x + tMat.col2.y * m_v1.y);
139   - //b2Vec2 v2 = b2Mul(transform1, m_v2);
140   - var v2X:Number = transform1.position.x + (tMat.col1.x * m_v2.x + tMat.col2.x * m_v2.y);
141   - var v2Y:Number = transform1.position.y + (tMat.col1.y * m_v2.x + tMat.col2.y * m_v2.y);
142   -
143   - tMat = transform2.R;
144   - //b2Vec2 v3 = b2Mul(transform2, m_v1);
145   - var v3X:Number = transform2.position.x + (tMat.col1.x * m_v1.x + tMat.col2.x * m_v1.y);
146   - var v3Y:Number = transform2.position.y + (tMat.col1.y * m_v1.x + tMat.col2.y * m_v1.y);
147   - //b2Vec2 v4 = b2Mul(transform2, m_v2);
148   - var v4X:Number = transform2.position.x + (tMat.col1.x * m_v2.x + tMat.col2.x * m_v2.y);
149   - var v4Y:Number = transform2.position.y + (tMat.col1.y * m_v2.x + tMat.col2.y * m_v2.y);
150   -
151   - //aabb.lowerBound = b2Min(b2Min(b2Min(v1, v2), v3), v4);
152   - aabb.lowerBound.x = ((v1X < v2X ? v1X : v2X) < v3X ? (v1X < v2X ? v1X : v2X) : v3X) < v4X ? ((v1X < v2X ? v1X : v2X) < v3X ? (v1X < v2X ? v1X : v2X) : v3X) : v4X;
153   - aabb.lowerBound.y = ((v1Y < v2Y ? v1Y : v2Y) < v3Y ? (v1Y < v2Y ? v1Y : v2Y) : v3Y) < v4Y ? ((v1Y < v2Y ? v1Y : v2Y) < v3Y ? (v1Y < v2Y ? v1Y : v2Y) : v3Y) : v4Y;
154   - //aabb.upperBound = b2Max(b2Max(b2Max(v1, v2), v3), v4);
155   - aabb.upperBound.x = ((v1X > v2X ? v1X : v2X) > v3X ? (v1X > v2X ? v1X : v2X) : v3X) > v4X ? ((v1X > v2X ? v1X : v2X) > v3X ? (v1X > v2X ? v1X : v2X) : v3X) : v4X;
156   - aabb.upperBound.y = ((v1Y > v2Y ? v1Y : v2Y) > v3Y ? (v1Y > v2Y ? v1Y : v2Y) : v3Y) > v4Y ? ((v1Y > v2Y ? v1Y : v2Y) > v3Y ? (v1Y > v2Y ? v1Y : v2Y) : v3Y) : v4Y;
157   - }
158   -
159   - /**
160   - * @inheritDoc
161   - */
162   - public override function ComputeMass(massData:b2MassData) : void{
163   - massData.mass = 0;
164   - massData.center.SetV(m_v1);
165   - massData.I = 0;
166   - }
167   -
168   - /**
169   - * @inheritDoc
170   - */
171   - public override function ComputeSubmergedArea(
172   - normal:b2Vec2,
173   - offset:Number,
174   - xf:b2XForm,
175   - c:b2Vec2):Number
176   - {
177   - // Note that v0 is independant of any details of the specific edge
178   - // We are relying on v0 being consistent between multiple edges of the same body
179   - //b2Vec2 v0 = offset * normal;
180   - var v0:b2Vec2 = new b2Vec2(normal.x * offset, normal.y * offset);
181   -
182   - var v1:b2Vec2 = b2Math.b2MulX(xf, m_v1);
183   - var v2:b2Vec2 = b2Math.b2MulX(xf, m_v2);
184   -
185   - var d1:Number = b2Math.b2Dot(normal, v1) - offset;
186   - var d2:Number = b2Math.b2Dot(normal, v2) - offset;
187   - if (d1 > 0)
188   - {
189   - if (d2 > 0)
190   - {
191   - return 0;
192   - }
193   - else
194   - {
195   - //v1 = -d2 / (d1 - d2) * v1 + d1 / (d1 - d2) * v2;
196   - v1.x = -d2 / (d1 - d2) * v1.x + d1 / (d1 - d2) * v2.x;
197   - v1.y = -d2 / (d1 - d2) * v1.y + d1 / (d1 - d2) * v2.y;
198   - }
199   - }
200   - else
201   - {
202   - if (d2 > 0)
203   - {
204   - //v2 = -d2 / (d1 - d2) * v1 + d1 / (d1 - d2) * v2;
205   - v2.x = -d2 / (d1 - d2) * v1.x + d1 / (d1 - d2) * v2.x;
206   - v2.y = -d2 / (d1 - d2) * v1.y + d1 / (d1 - d2) * v2.y;
207   - }
208   - else
209   - {
210   - // Nothing
211   - }
212   - }
213   - // v0,v1,v2 represents a fully submerged triangle
214   - // Area weighted centroid
215   - c.x = (v0.x + v1.x + v2.x) / 3;
216   - c.y = (v0.y + v1.y + v2.y) / 3;
217   -
218   - //b2Vec2 e1 = v1 - v0;
219   - //b2Vec2 e2 = v2 - v0;
220   - //return 0.5f * b2Cross(e1, e2);
221   - return 0.5 * ( (v1.x - v0.x) * (v2.y - v0.y) - (v1.y - v0.y) * (v2.x - v0.x) );
222   - }
223   -
224   - /**
225   - * Get the distance from vertex1 to vertex2.
226   - */
227   - public function GetLength(): Number
228   - {
229   - return m_length;
230   - }
231   -
232   - /**
233   - * Get the local position of vertex1 in parent body.
234   - */
235   - public function GetVertex1(): b2Vec2
236   - {
237   - return m_v1;
238   - }
239   -
240   - /**
241   - * Get the local position of vertex2 in parent body.
242   - */
243   - public function GetVertex2(): b2Vec2
244   - {
245   - return m_v2;
246   - }
247   -
248   - /**
249   - * Get a core vertex in local coordinates. These vertices
250   - * represent a smaller edge that is used for time of impact
251   - * computations.
252   - */
253   - public function GetCoreVertex1(): b2Vec2
254   - {
255   - return m_coreV1;
256   - }
257   -
258   - /**
259   - * Get a core vertex in local coordinates. These vertices
260   - * represent a smaller edge that is used for time of impact
261   - * computations.
262   - */
263   - public function GetCoreVertex2(): b2Vec2
264   - {
265   - return m_coreV2;
266   - }
267   -
268   - /**
269   - * Get a perpendicular unit vector, pointing
270   - * from the solid side to the empty side.
271   - */
272   - public function GetNormalVector(): b2Vec2
273   - {
274   - return m_normal;
275   - }
276   -
277   -
278   - /**
279   - * Get a parallel unit vector, pointing
280   - * from vertex1 to vertex2.
281   - */
282   - public function GetDirectionVector(): b2Vec2
283   - {
284   - return m_direction;
285   - }
286   -
287   - /**
288   - * Returns a unit vector halfway between
289   - * m_direction and m_prevEdge.m_direction.
290   - */
291   - public function GetCorner1Vector(): b2Vec2
292   - {
293   - return m_cornerDir1;
294   - }
295   -
296   - /**
297   - * Returns a unit vector halfway between
298   - * m_direction and m_nextEdge.m_direction.
299   - */
300   - public function GetCorner2Vector(): b2Vec2
301   - {
302   - return m_cornerDir2;
303   - }
304   -
305   - /**
306   - * Returns true if the first corner of this edge
307   - * bends towards the solid side.
308   - */
309   - public function Corner1IsConvex(): Boolean
310   - {
311   - return m_cornerConvex1;
312   - }
313   -
314   - /**
315   - * Returns true if the second corner of this edge
316   - * bends towards the solid side.
317   - */
318   - public function Corner2IsConvex(): Boolean
319   - {
320   - return m_cornerConvex2;
321   - }
322   -
323   - /**
324   - * Get the first vertex and apply the supplied transform.
325   - */
326   - public function GetFirstVertex(xf: b2XForm): b2Vec2
327   - {
328   - //return b2Mul(xf, m_coreV1);
329   - var tMat:b2Mat22 = xf.R;
330   - return new b2Vec2(xf.position.x + (tMat.col1.x * m_coreV1.x + tMat.col2.x * m_coreV1.y),
331   - xf.position.y + (tMat.col1.y * m_coreV1.x + tMat.col2.y * m_coreV1.y));
332   - }
333   -
334   - /**
335   - * Get the next edge in the chain.
336   - */
337   - public function GetNextEdge(): b2EdgeShape
338   - {
339   - return m_nextEdge;
340   - }
341   -
342   - /**
343   - * Get the previous edge in the chain.
344   - */
345   - public function GetPrevEdge(): b2EdgeShape
346   - {
347   - return m_prevEdge;
348   - }
349   -
350   - private var s_supportVec:b2Vec2 = new b2Vec2();
351   - /**
352   - * Get the support point in the given world direction.
353   - * Use the supplied transform.
354   - */
355   - public function Support(xf:b2XForm, dX:Number, dY:Number) : b2Vec2{
356   - var tMat:b2Mat22 = xf.R;
357   - //b2Vec2 v1 = b2Mul(xf, m_coreV1);
358   - var v1X:Number = xf.position.x + (tMat.col1.x * m_coreV1.x + tMat.col2.x * m_coreV1.y);
359   - var v1Y:Number = xf.position.y + (tMat.col1.y * m_coreV1.x + tMat.col2.y * m_coreV1.y);
360   -
361   - //b2Vec2 v2 = b2Mul(xf, m_coreV2);
362   - var v2X:Number = xf.position.x + (tMat.col1.x * m_coreV2.x + tMat.col2.x * m_coreV2.y);
363   - var v2Y:Number = xf.position.y + (tMat.col1.y * m_coreV2.x + tMat.col2.y * m_coreV2.y);
364   -
365   - if ((v1X * dX + v1Y * dY) > (v2X * dX + v2Y * dY)) {
366   - s_supportVec.x = v1X;
367   - s_supportVec.y = v1Y;
368   - } else {
369   - s_supportVec.x = v2X;
370   - s_supportVec.y = v2Y;
371   - }
372   - return s_supportVec;
373   - }
374   -
375   - //--------------- Internals Below -------------------
376   -
377   - /**
378   - * @private
379   - */
380   - public function b2EdgeShape(v1: b2Vec2, v2: b2Vec2, def: b2ShapeDef){
381   - super(def);
382   -
383   - //b2Settings.b2Assert(def.type == e_edgeShape);
384   -
385   - m_type = e_edgeShape;
386   -
387   - m_prevEdge = null;
388   - m_nextEdge = null;
389   -
390   - m_v1 = v1;
391   - m_v2 = v2;
392   -
393   - m_direction.Set(m_v2.x - m_v1.x, m_v2.y - m_v1.y);
394   - m_length = m_direction.Normalize();
395   - m_normal.Set(m_direction.y, -m_direction.x);
396   -
397   - m_coreV1.Set(-b2Settings.b2_toiSlop * (m_normal.x - m_direction.x) + m_v1.x,
398   - -b2Settings.b2_toiSlop * (m_normal.y - m_direction.y) + m_v1.y)
399   - m_coreV2.Set(-b2Settings.b2_toiSlop * (m_normal.x + m_direction.x) + m_v2.x,
400   - -b2Settings.b2_toiSlop * (m_normal.y + m_direction.y) + m_v2.y)
401   -
402   - m_cornerDir1 = m_normal;
403   - m_cornerDir2.Set(-m_normal.x, -m_normal.y);
404   - }
405   -
406   - /**
407   - * @private
408   - */
409   - b2internal override function UpdateSweepRadius(center:b2Vec2) : void{
410   - // Update the sweep radius (maximum radius) as measured from
411   - // a local center point.
412   - //b2Vec2 d = m_coreV1 - center;
413   - var dX:Number = m_coreV1.x - center.x;
414   - var dY:Number = m_coreV1.y - center.y;
415   - var d1:Number = dX*dX + dY*dY;
416   - dX = m_coreV2.x - center.x;
417   - dY = m_coreV2.y - center.y;
418   - var d2:Number = dX*dX + dY*dY;
419   - m_sweepRadius = Math.sqrt(d1 > d2 ? d1 : d2);
420   - }
421   -
422   - /**
423   - * @private
424   - */
425   - b2internal function SetPrevEdge(edge: b2EdgeShape, core: b2Vec2, cornerDir: b2Vec2, convex: Boolean): void
426   - {
427   - m_prevEdge = edge;
428   - m_coreV1 = core;
429   - m_cornerDir1 = cornerDir;
430   - m_cornerConvex1 = convex;
431   - }
432   -
433   - /**
434   - * @private
435   - */
436   - b2internal function SetNextEdge(edge: b2EdgeShape, core: b2Vec2, cornerDir: b2Vec2, convex: Boolean): void
437   - {
438   - m_nextEdge = edge;
439   - m_coreV2 = core;
440   - m_cornerDir2 = cornerDir;
441   - m_cornerConvex2 = convex;
442   - }
443   -
444   - b2internal var m_v1:b2Vec2 = new b2Vec2();
445   - b2internal var m_v2:b2Vec2 = new b2Vec2();
446   -
447   - b2internal var m_coreV1:b2Vec2 = new b2Vec2();
448   - b2internal var m_coreV2:b2Vec2 = new b2Vec2();
449   -
450   - b2internal var m_length:Number;
451   -
452   - b2internal var m_normal:b2Vec2 = new b2Vec2();
453   -
454   - b2internal var m_direction:b2Vec2 = new b2Vec2();
455   -
456   - b2internal var m_cornerDir1:b2Vec2 = new b2Vec2();
457   -
458   - b2internal var m_cornerDir2:b2Vec2 = new b2Vec2();
459   -
460   - b2internal var m_cornerConvex1:Boolean;
461   - b2internal var m_cornerConvex2:Boolean;
462   -
463   - b2internal var m_nextEdge:b2EdgeShape;
464   - b2internal var m_prevEdge:b2EdgeShape;
465   -
466   -};
467   -
468   -}
60 src/Box2D/Collision/Shapes/b2FilterData.as
... ... @@ -1,60 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Common.b2internal;
25   -use namespace b2internal;
26   -
27   -
28   -/**
29   -* This holds contact filtering data.
30   -*/
31   -public class b2FilterData
32   -{
33   - public function Copy() : b2FilterData {
34   - var copy: b2FilterData = new b2FilterData();
35   - copy.categoryBits = categoryBits;
36   - copy.maskBits = maskBits;
37   - copy.groupIndex = groupIndex;
38   - return copy;
39   - }
40   -
41   - /**
42   - * The collision category bits. Normally you would just set one bit.
43   - */
44   - public var categoryBits: uint = 0x0001;
45   -
46   - /**
47   - * The collision mask bits. This states the categories that this
48   - * shape would accept for collision.
49   - */
50   - public var maskBits: uint = 0xFFFF;
51   -
52   - /**
53   - * Collision groups allow a certain group of objects to never collide (negative)
54   - * or always collide (positive). Zero means no collision group. Non-zero group
55   - * filtering always wins against the mask bits.
56   - */
57   - public var groupIndex: int = 0;
58   -}
59   -
60   -}
47 src/Box2D/Collision/Shapes/b2MassData.as
... ... @@ -1,47 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Common.b2internal;
25   -use namespace b2internal;
26   -
27   -
28   -/**
29   -* This holds the mass data computed for a shape.
30   -*/
31   -public class b2MassData
32   -{
33   - /**
34   - * The mass of the shape, usually in kilograms.
35   - */
36   - public var mass:Number = 0.0;
37   - /**
38   - * The position of the shape's centroid relative to the shape's origin.
39   - */
40   - public var center:b2Vec2 = new b2Vec2(0,0);
41   - /**
42   - * The rotational inertia of the shape.
43   - */
44   - public var I:Number = 0.0;
45   -}
46   -
47   -}
109 src/Box2D/Collision/Shapes/b2PolygonDef.as
... ... @@ -1,109 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Common.*;
25   -import Box2D.Collision.Shapes.*;
26   -
27   -import Box2D.Common.b2internal;
28   -use namespace b2internal;
29   -
30   -
31   -
32   -/**
33   -* This structure is used to build polygon shapes.
34   -* @see b2PolygonShape
35   -*/
36   -public class b2PolygonDef extends b2ShapeDef
37   -{
38   - public function b2PolygonDef()
39   - {
40   - type = b2Shape.e_polygonShape;
41   - vertexCount = 0;
42   -
43   - for (var i:int = 0; i < b2Settings.b2_maxPolygonVertices; i++){
44   - vertices[i] = new b2Vec2();
45   - }
46   - }
47   -
48   - /**
49   - * Build vertices to represent an axis-aligned box.
50   - * @param hx the half-width.
51   - * @param hy the half-height.
52   - */
53   - public function SetAsBox(hx:Number, hy:Number) : void{
54   - vertexCount = 4;
55   - vertices[0].Set(-hx, -hy);
56   - vertices[1].Set( hx, -hy);
57   - vertices[2].Set( hx, hy);
58   - vertices[3].Set(-hx, hy);
59   - }
60   -
61   - /**
62   - * Build vertices to represent an oriented box.
63   - * @param hx the half-width.
64   - * @param hy the half-height.
65   - * @param center the center of the box in local coordinates.
66   - * @param angle the rotation of the box in local coordinates.
67   - */
68   - static private var s_mat:b2Mat22 = new b2Mat22();
69   - public function SetAsOrientedBox(hx:Number, hy:Number, center:b2Vec2=null, angle:Number=0.0) : void{
70   - //SetAsBox(hx, hy);
71   - {
72   - vertexCount = 4;
73   - vertices[0].Set(-hx, -hy);
74   - vertices[1].Set( hx, -hy);
75   - vertices[2].Set( hx, hy);
76   - vertices[3].Set(-hx, hy);
77   - }
78   -
79   - if (center){
80   - //b2XForm xf;
81   - //xf.position = center;
82   - var xfPosition:b2Vec2 = center;
83   - //xf.R.Set(angle);
84   - var xfR:b2Mat22 = s_mat;
85   - xfR.Set(angle);
86   -
87   - for (var i:int = 0; i < vertexCount; ++i)
88   - {
89   - //vertices[i] = b2Mul(xf, vertices[i]);
90   - //var a:b2Vec2 = b2MulMV(T.R, v);
91   - center = vertices[i];
92   - hx = xfPosition.x + (xfR.col1.x * center.x + xfR.col2.x * center.y)
93   - center.y = xfPosition.y + (xfR.col1.y * center.x + xfR.col2.y * center.y)
94   - center.x = hx;
95   - }
96   - }
97   - }
98   -
99   - /**
100   - * The polygon vertices in local coordinates.
101   - */
102   - public var vertices:Array = new Array(b2Settings.b2_maxPolygonVertices);
103   - /**
104   - * The number of polygon vertices.
105   - */
106   - public var vertexCount:int;
107   -};
108   -
109   -}
868 src/Box2D/Collision/Shapes/b2PolygonShape.as
... ... @@ -1,868 +0,0 @@
1   -/*
2   -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
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 as such, and must not be
15   -* misrepresented as being the original software.
16   -* 3. This notice may not be removed or altered from any source distribution.
17   -*/
18   -
19   -package Box2D.Collision.Shapes{
20   -
21   -
22   -
23   -import Box2D.Common.Math.*;
24   -import Box2D.Common.*;
25   -import Box2D.Collision.Shapes.*;
26   -import Box2D.Dynamics.*;
27   -import Box2D.Collision.*;
28   -
29   -import Box2D.Common.b2internal;
30   -use namespace b2internal;
31   -
32   -/**
33   -* Convex polygon. The vertices must be in CCW order for a right-handed
34   -* coordinate system with the z-axis coming out of the screen.
35   -* @see b2PolygonDef
36   -*/
37   -
38   -public class b2PolygonShape extends b2Shape
39   -{
40   - /**
41   - * @inheritDoc
42   - */
43   - public override function TestPoint(xf:b2XForm, p:b2Vec2) : Boolean{
44   - var tVec:b2Vec2;
45   -
46   - //b2Vec2 pLocal = b2MulT(xf.R, p - xf.position);
47   - var tMat:b2Mat22 = xf.R;
48   - var tX:Number = p.x - xf.position.x;
49   - var tY:Number = p.y - xf.position.y;
50   - var pLocalX:Number = (tX*tMat.col1.x + tY*tMat.col1.y);
51   - var pLocalY:Number = (tX*tMat.col2.x + tY*tMat.col2.y);
52   -
53   - for (var i:int = 0; i < m_vertexCount; ++i)
54   - {
55   - //float32 dot = b2Dot(m_normals[i], pLocal - m_vertices[i]);
56   - tVec = m_vertices[i];
57   - tX = pLocalX - tVec.x;
58   - tY = pLocalY - tVec.y;
59   - tVec = m_normals[i];
60   - var dot:Number = (tVec.x * tX + tVec.y * tY);
61   - if (dot > 0.0)
62   - {
63   - return false;
64   - }
65   - }
66   -
67   - return true;
68   - }
69   -
70   - /**
71   - * @inheritDoc
72   - */
73   - public override function TestSegment( xf:b2XForm,
74   - lambda:Array, // float ptr
75   - normal:b2Vec2, // ptr
76   - segment:b2Segment,
77   - maxLambda:Number) : int
78   - {
79   - var lower:Number = 0.0;
80   - var upper:Number = maxLambda;
81   -
82   - var tX:Number;
83   - var tY:Number;
84   - var tMat:b2Mat22;
85   - var tVec:b2Vec2;
86   -
87   - //b2Vec2 p1 = b2MulT(xf.R, segment.p1 - xf.position);
88   - tX = segment.p1.x - xf.position.x;
89   - tY = segment.p1.y - xf.position.y;
90   - tMat = xf.R;
91   - var p1X:Number = (tX * tMat.col1.x + tY * tMat.col1.y);
92   - var p1Y:Number = (tX * tMat.col2.x + tY * tMat.col2.y);
93   - //b2Vec2 p2 = b2MulT(xf.R, segment.p2 - xf.position);
94   - tX = segment.p2.x - xf.position.x;
95   - tY = segment.p2.y - xf.position.y;
96   - tMat = xf.R;
97   - var p2X:Number = (tX * tMat.col1.x + tY * tMat.col1.y);
98   - var p2Y:Number = (tX * tMat.col2.x + tY * tMat.col2.y);
99   - //b2Vec2 d = p2 - p1;
100   - var dX:Number = p2X - p1X;
101   - var dY:Number = p2Y - p1Y;
102   - var index:int = -1;
103   -
104   - for (var i:int = 0; i < m_vertexCount; ++i)
105   - {
106   - // p = p1 + a * d
107   - // dot(normal, p - v) = 0
108   - // dot(normal, p1 - v) + a * dot(normal, d) = 0
109   -
110   - //float32 numerator = b2Dot(m_normals[i], m_vertices[i] - p1);
111   - tVec = m_vertices[i];
112   - tX = tVec.x - p1X;
113   - tY = tVec.y - p1Y;
114   - tVec = m_normals[i];
115   - var numerator:Number = (tVec.x*tX + tVec.y*tY);
116   - //float32 denominator = b2Dot(m_normals[i], d);
117   - var denominator:Number = (tVec.x * dX + tVec.y * dY);
118   -
119   - if (denominator == 0.0)
120   - {
121   - if (numerator < 0)
122   - {
123   - return e_missCollide;
124   - }
125   - }
126   - else
127   - {
128   - // Note: we want this predicate without division:
129   - // lower < numerator / denominator, where denominator < 0
130   - // Since denominator < 0, we have to flip the inequality:
131   - // lower < numerator / denominator <==> denominator * lower > numerator.
132   - if (denominator < 0.0 && numerator < lower * denominator)
133   - {
134   - // Increase lower.
135   - // The segment enters this half-space.
136   - lower = numerator / denominator;
137   - index = i;
138   - }
139   - else if (denominator > 0.0 && numerator < upper * denominator)
140   - {
141   - // Decrease upper.
142   - // The segment exits this half-space.
143   - upper = numerator / denominator;
144   - }
145   - }
146   -
147   - if (upper < lower)
148   - {
149   - return e_missCollide;
150   - }
151   - }
152   -
153   - //b2Settings.b2Assert(0.0 <= lower && lower <= maxLambda);
154   -
155   - if (index >= 0)
156   - {
157   - //*lambda = lower;