├── BlankProject ├── main.fla ├── main.swc └── main.swf ├── Box2D ├── .svn │ ├── all-wcprops │ ├── entries │ └── text-base │ │ ├── Box2D.h.svn-base │ │ ├── Box2DConfig.cmake.svn-base │ │ └── CMakeLists.txt.svn-base ├── Box2D.h ├── Collision │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── b2BroadPhase.cpp.svn-base │ │ │ ├── b2BroadPhase.h.svn-base │ │ │ ├── b2CollideCircle.cpp.svn-base │ │ │ ├── b2CollideEdge.cpp.svn-base │ │ │ ├── b2CollidePolygon.cpp.svn-base │ │ │ ├── b2Collision.cpp.svn-base │ │ │ ├── b2Collision.h.svn-base │ │ │ ├── b2Distance.cpp.svn-base │ │ │ ├── b2Distance.h.svn-base │ │ │ ├── b2DynamicTree.cpp.svn-base │ │ │ ├── b2DynamicTree.h.svn-base │ │ │ ├── b2TimeOfImpact.cpp.svn-base │ │ │ └── b2TimeOfImpact.h.svn-base │ ├── Shapes │ │ ├── .svn │ │ │ ├── all-wcprops │ │ │ ├── entries │ │ │ └── text-base │ │ │ │ ├── b2CircleShape.cpp.svn-base │ │ │ │ ├── b2CircleShape.h.svn-base │ │ │ │ ├── b2EdgeShape.cpp.svn-base │ │ │ │ ├── b2EdgeShape.h.svn-base │ │ │ │ ├── b2LoopShape.cpp.svn-base │ │ │ │ ├── b2LoopShape.h.svn-base │ │ │ │ ├── b2PolygonShape.cpp.svn-base │ │ │ │ ├── b2PolygonShape.h.svn-base │ │ │ │ └── b2Shape.h.svn-base │ │ ├── b2CircleShape.cpp │ │ ├── b2CircleShape.h │ │ ├── b2EdgeShape.cpp │ │ ├── b2EdgeShape.h │ │ ├── b2LoopShape.cpp │ │ ├── b2LoopShape.h │ │ ├── b2PolygonShape.cpp │ │ ├── b2PolygonShape.h │ │ └── b2Shape.h │ ├── b2BroadPhase.cpp │ ├── b2BroadPhase.h │ ├── b2CollideCircle.cpp │ ├── b2CollideEdge.cpp │ ├── b2CollidePolygon.cpp │ ├── b2Collision.cpp │ ├── b2Collision.h │ ├── b2Distance.cpp │ ├── b2Distance.h │ ├── b2DynamicTree.cpp │ ├── b2DynamicTree.h │ ├── b2TimeOfImpact.cpp │ └── b2TimeOfImpact.h ├── Common │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── b2BlockAllocator.cpp.svn-base │ │ │ ├── b2BlockAllocator.h.svn-base │ │ │ ├── b2GrowableStack.h.svn-base │ │ │ ├── b2Math.cpp.svn-base │ │ │ ├── b2Math.h.svn-base │ │ │ ├── b2Settings.cpp.svn-base │ │ │ ├── b2Settings.h.svn-base │ │ │ ├── b2StackAllocator.cpp.svn-base │ │ │ └── b2StackAllocator.h.svn-base │ ├── b2BlockAllocator.cpp │ ├── b2BlockAllocator.h │ ├── b2GrowableStack.h │ ├── b2Math.cpp │ ├── b2Math.h │ ├── b2Settings.cpp │ ├── b2Settings.h │ ├── b2StackAllocator.cpp │ └── b2StackAllocator.h ├── ConvexDecomposition │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── b2Polygon.cpp.svn-base │ │ │ ├── b2Polygon.h.svn-base │ │ │ ├── b2Triangle.cpp.svn-base │ │ │ └── b2Triangle.h.svn-base │ ├── b2Polygon.cpp │ ├── b2Polygon.h │ ├── b2Triangle.cpp │ └── b2Triangle.h └── Dynamics │ ├── .svn │ ├── all-wcprops │ ├── entries │ └── text-base │ │ ├── b2Body.cpp.svn-base │ │ ├── b2Body.h.svn-base │ │ ├── b2ContactManager.cpp.svn-base │ │ ├── b2ContactManager.h.svn-base │ │ ├── b2Fixture.cpp.svn-base │ │ ├── b2Fixture.h.svn-base │ │ ├── b2Island.cpp.svn-base │ │ ├── b2Island.h.svn-base │ │ ├── b2TimeStep.h.svn-base │ │ ├── b2World.cpp.svn-base │ │ ├── b2World.h.svn-base │ │ ├── b2WorldCallbacks.cpp.svn-base │ │ └── b2WorldCallbacks.h.svn-base │ ├── Contacts │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── b2CircleContact.cpp.svn-base │ │ │ ├── b2CircleContact.h.svn-base │ │ │ ├── b2Contact.cpp.svn-base │ │ │ ├── b2Contact.h.svn-base │ │ │ ├── b2ContactSolver.cpp.svn-base │ │ │ ├── b2ContactSolver.h.svn-base │ │ │ ├── b2EdgeAndCircleContact.cpp.svn-base │ │ │ ├── b2EdgeAndCircleContact.h.svn-base │ │ │ ├── b2EdgeAndPolygonContact.cpp.svn-base │ │ │ ├── b2EdgeAndPolygonContact.h.svn-base │ │ │ ├── b2LoopAndCircleContact.cpp.svn-base │ │ │ ├── b2LoopAndCircleContact.h.svn-base │ │ │ ├── b2LoopAndPolygonContact.cpp.svn-base │ │ │ ├── b2LoopAndPolygonContact.h.svn-base │ │ │ ├── b2NullContact.h.svn-base │ │ │ ├── b2PolygonAndCircleContact.cpp.svn-base │ │ │ ├── b2PolygonAndCircleContact.h.svn-base │ │ │ ├── b2PolygonContact.cpp.svn-base │ │ │ └── b2PolygonContact.h.svn-base │ ├── b2CircleContact.cpp │ ├── b2CircleContact.h │ ├── b2Contact.cpp │ ├── b2Contact.h │ ├── b2ContactSolver.cpp │ ├── b2ContactSolver.h │ ├── b2EdgeAndCircleContact.cpp │ ├── b2EdgeAndCircleContact.h │ ├── b2EdgeAndPolygonContact.cpp │ ├── b2EdgeAndPolygonContact.h │ ├── b2LoopAndCircleContact.cpp │ ├── b2LoopAndCircleContact.h │ ├── b2LoopAndPolygonContact.cpp │ ├── b2LoopAndPolygonContact.h │ ├── b2NullContact.h │ ├── b2PolygonAndCircleContact.cpp │ ├── b2PolygonAndCircleContact.h │ ├── b2PolygonContact.cpp │ └── b2PolygonContact.h │ ├── Joints │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── b2DistanceJoint.cpp.svn-base │ │ │ ├── b2DistanceJoint.h.svn-base │ │ │ ├── b2FrictionJoint.cpp.svn-base │ │ │ ├── b2FrictionJoint.h.svn-base │ │ │ ├── b2GearJoint.cpp.svn-base │ │ │ ├── b2GearJoint.h.svn-base │ │ │ ├── b2Joint.cpp.svn-base │ │ │ ├── b2Joint.h.svn-base │ │ │ ├── b2LineJoint.cpp.svn-base │ │ │ ├── b2LineJoint.h.svn-base │ │ │ ├── b2MouseJoint.cpp.svn-base │ │ │ ├── b2MouseJoint.h.svn-base │ │ │ ├── b2PrismaticJoint.cpp.svn-base │ │ │ ├── b2PrismaticJoint.h.svn-base │ │ │ ├── b2PulleyJoint.cpp.svn-base │ │ │ ├── b2PulleyJoint.h.svn-base │ │ │ ├── b2RevoluteJoint.cpp.svn-base │ │ │ ├── b2RevoluteJoint.h.svn-base │ │ │ ├── b2WeldJoint.cpp.svn-base │ │ │ └── b2WeldJoint.h.svn-base │ ├── b2DistanceJoint.cpp │ ├── b2DistanceJoint.h │ ├── b2FrictionJoint.cpp │ ├── b2FrictionJoint.h │ ├── b2GearJoint.cpp │ ├── b2GearJoint.h │ ├── b2Joint.cpp │ ├── b2Joint.h │ ├── b2LineJoint.cpp │ ├── b2LineJoint.h │ ├── b2MouseJoint.cpp │ ├── b2MouseJoint.h │ ├── b2PrismaticJoint.cpp │ ├── b2PrismaticJoint.h │ ├── b2PulleyJoint.cpp │ ├── b2PulleyJoint.h │ ├── b2RevoluteJoint.cpp │ ├── b2RevoluteJoint.h │ ├── b2RopeJoint.cpp │ ├── b2RopeJoint.h │ ├── b2WeldJoint.cpp │ └── b2WeldJoint.h │ ├── b2Body.cpp │ ├── b2Body.h │ ├── b2ContactManager.cpp │ ├── b2ContactManager.h │ ├── b2Fixture.cpp │ ├── b2Fixture.h │ ├── b2Island.cpp │ ├── b2Island.h │ ├── b2TimeStep.h │ ├── b2World.cpp │ ├── b2World.h │ ├── b2WorldCallbacks.cpp │ └── b2WorldCallbacks.h ├── Box2DAS ├── Box2D.c ├── Box2D.h ├── Box2D.swc ├── Collision │ ├── AABB.as │ ├── Shapes │ │ ├── b2CircleShape.as │ │ ├── b2EdgeShape.as │ │ ├── b2LoopShape.as │ │ ├── b2MassData.as │ │ ├── b2PolygonShape.as │ │ └── b2Shape.as │ ├── b2AABB.as │ ├── b2BroadPhase.as │ ├── b2Distance.as │ ├── b2DistanceInput.as │ ├── b2DistanceOutput.as │ ├── b2DistanceProxy.as │ ├── b2Manifold.as │ ├── b2ManifoldPoint.as │ ├── b2SimplexCache.as │ └── b2WorldManifold.as ├── Common │ ├── M22.as │ ├── M33.as │ ├── V2.as │ ├── V3.as │ ├── XF.as │ ├── b2Base.as │ ├── b2Def.as │ ├── b2EventDispatcher.as │ ├── b2Mat22.as │ ├── b2Mat33.as │ ├── b2Settings.as │ ├── b2Sweep.as │ ├── b2Transform.as │ ├── b2Vec2.as │ └── b2Vec3.as ├── Controllers │ ├── b2BuoyancyEffect.as │ ├── b2Controller.as │ └── b2Effect.as ├── Dynamics │ ├── ContactEvent.as │ ├── Contacts │ │ ├── b2Contact.as │ │ ├── b2ContactEdge.as │ │ └── b2ContactID.as │ ├── GoodbyeFixtureEvent.as │ ├── GoodbyeJointEvent.as │ ├── Joints │ │ ├── b2DistanceJoint.as │ │ ├── b2DistanceJointDef.as │ │ ├── b2FrictionJoint.as │ │ ├── b2FrictionJointDef.as │ │ ├── b2GearJoint.as │ │ ├── b2GearJointDef.as │ │ ├── b2Jacobian.as │ │ ├── b2Joint.as │ │ ├── b2JointDef.as │ │ ├── b2JointEdge.as │ │ ├── b2LineJoint.as │ │ ├── b2LineJointDef.as │ │ ├── b2MouseJoint.as │ │ ├── b2MouseJointDef.as │ │ ├── b2PrismaticJoint.as │ │ ├── b2PrismaticJointDef.as │ │ ├── b2PulleyJoint.as │ │ ├── b2PulleyJointDef.as │ │ ├── b2RevoluteJoint.as │ │ ├── b2RevoluteJointDef.as │ │ ├── b2RopeJoint.as │ │ ├── b2RopeJointDef.as │ │ ├── b2WeldJoint.as │ │ └── b2WeldJointDef.as │ ├── StepEvent.as │ ├── b2Body.as │ ├── b2BodyDef.as │ ├── b2ContactImpulse.as │ ├── b2ContactListener.as │ ├── b2ContactManager.as │ ├── b2DebugDraw.as │ ├── b2DestructionListener.as │ ├── b2Filter.as │ ├── b2Fixture.as │ ├── b2FixtureDef.as │ └── b2World.as └── achacks.as ├── README.txt ├── TestBed ├── Bullet.as ├── Buoyancy.as ├── Contact.as ├── Decompose.as ├── Decompose2.as ├── Edges.as ├── Edges1.as ├── Edges2.as ├── Filter.as ├── Impulse.as ├── Main.as ├── Memory.as ├── Ragdoll.as ├── Raycast.as ├── Test.as ├── TestBed.fla ├── TestBed.swc ├── TestBed.swf ├── TheoJansen.as └── Wave.as ├── demo ├── BoxAndCircle.as ├── BoxMan.as ├── Demo.as ├── Preload.as ├── RemoveButton.as ├── Vehicle.as ├── WorldBuoyancy.as ├── demo.fla ├── demo.swc ├── demo.swf └── pattern.png ├── extras ├── Crayon.as ├── CrayonLine.as ├── CrayonSolid.as ├── CrayonTip.as ├── GroundFinder.as ├── Platform.as └── WorldClickAdd.as ├── gravity ├── Gravity.as ├── GravityCapsule.as ├── GravityLinear.as ├── GravityRadial.as └── GravitySine.as ├── misc ├── Connector.as ├── ConnectorLine.as ├── ConnectorMask.as ├── ConnectorStretch.as ├── Cursor.as ├── DictionaryTree.as ├── Entity.as ├── FPS.as ├── FX.as ├── FX3DSpinner.as ├── FXContainer.as ├── Input.as ├── KeyCodes.as ├── Parallax.as ├── Scroller.as ├── ScrollerChild.as ├── Util.as ├── Wave.as ├── Waves.as ├── XYSource.as ├── XYSourceDisplayObject.as └── XYTracer.as ├── probe ├── Box2D.c ├── Box2D.swc ├── output.txt ├── probe.fla ├── probe.swc └── probe.swf ├── script ├── Clear Outline.jsfl ├── Decompose Polygon.jsfl ├── Set Component Property.jsfl └── Trace Edges.jsfl ├── shapes ├── Arc180.as ├── Arc270.as ├── Arc360.as ├── Arc90.as ├── Box.as ├── Circle.as ├── Line.as ├── LineArc180.as ├── LineArc270.as ├── LineArc360.as ├── LineArc90.as ├── Oval.as ├── Poly3.as ├── Poly4.as ├── Poly5.as ├── Poly6.as ├── Poly7.as ├── Poly8.as ├── ShapeBase.as └── Triangle.as └── wck ├── BodyShape.as ├── Buoyancy.as ├── ContactEventFilter.as ├── ContactList.as ├── Joint.as ├── WCK.as ├── WavesEffect.as └── World.as /BlankProject/main.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/BlankProject/main.fla -------------------------------------------------------------------------------- /BlankProject/main.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/BlankProject/main.swc -------------------------------------------------------------------------------- /BlankProject/main.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/BlankProject/main.swf -------------------------------------------------------------------------------- /Box2D/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 35 4 | /svn/!svn/ver/116/trunk/Box2D/Box2D 5 | END 6 | Box2DConfig.cmake 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 52 10 | /svn/!svn/ver/59/trunk/Box2D/Box2D/Box2DConfig.cmake 11 | END 12 | Box2D.h 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 43 16 | /svn/!svn/ver/110/trunk/Box2D/Box2D/Box2D.h 17 | END 18 | CMakeLists.txt 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 50 22 | /svn/!svn/ver/114/trunk/Box2D/Box2D/CMakeLists.txt 23 | END 24 | -------------------------------------------------------------------------------- /Box2D/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 116 5 | http://box2d.googlecode.com/svn/trunk/Box2D/Box2D 6 | http://box2d.googlecode.com/svn 7 | 8 | 9 | 10 | 2010-06-21T08:46:59.579824Z 11 | 116 12 | erincatto 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | cafe418c-1137-0410-84cc-357ec87a5d9b 28 | 29 | Box2DConfig.cmake 30 | file 31 | 32 | 33 | 34 | 35 | 2010-06-26T20:14:40.000000Z 36 | da1a45b32e3b86e95364163a8c423436 37 | 2010-02-28T18:53:10.341684Z 38 | 59 39 | erincatto 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 191 62 | 63 | Box2D.h 64 | file 65 | 66 | 67 | 68 | 69 | 2010-06-26T20:14:40.000000Z 70 | 90622ad76257580c23a3ffe91fa436c5 71 | 2010-06-07T08:02:20.953274Z 72 | 110 73 | erincatto 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 2347 96 | 97 | Dynamics 98 | dir 99 | 100 | Common 101 | dir 102 | 103 | Collision 104 | dir 105 | 106 | CMakeLists.txt 107 | file 108 | 109 | 110 | 111 | 112 | 2010-06-26T20:14:40.000000Z 113 | 7788c6e83cef4e89aef16cf5502f5d3d 114 | 2010-06-19T16:34:13.975934Z 115 | 114 116 | erincatto 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 5516 139 | 140 | -------------------------------------------------------------------------------- /Box2D/.svn/text-base/Box2DConfig.cmake.svn-base: -------------------------------------------------------------------------------- 1 | get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | include(${SELF_DIR}/Box2D-targets.cmake) 3 | get_filename_component(Box2D_INCLUDE_DIRS "${SELF_DIR}/../../include" ABSOLUTE) 4 | -------------------------------------------------------------------------------- /Box2D/Collision/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 45 4 | /svn/!svn/ver/114/trunk/Box2D/Box2D/Collision 5 | END 6 | b2Distance.cpp 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 60 10 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/b2Distance.cpp 11 | END 12 | b2Collision.cpp 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 61 16 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/b2Collision.cpp 17 | END 18 | b2BroadPhase.h 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 59 22 | /svn/!svn/ver/39/trunk/Box2D/Box2D/Collision/b2BroadPhase.h 23 | END 24 | b2CollideCircle.cpp 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 64 28 | /svn/!svn/ver/33/trunk/Box2D/Box2D/Collision/b2CollideCircle.cpp 29 | END 30 | b2Distance.h 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 58 34 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/b2Distance.h 35 | END 36 | b2CollideEdge.cpp 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 63 40 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/b2CollideEdge.cpp 41 | END 42 | b2Collision.h 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 59 46 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/b2Collision.h 47 | END 48 | b2TimeOfImpact.cpp 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 64 52 | /svn/!svn/ver/114/trunk/Box2D/Box2D/Collision/b2TimeOfImpact.cpp 53 | END 54 | b2CollidePolygon.cpp 55 | K 25 56 | svn:wc:ra_dav:version-url 57 | V 66 58 | /svn/!svn/ver/111/trunk/Box2D/Box2D/Collision/b2CollidePolygon.cpp 59 | END 60 | b2DynamicTree.cpp 61 | K 25 62 | svn:wc:ra_dav:version-url 63 | V 63 64 | /svn/!svn/ver/113/trunk/Box2D/Box2D/Collision/b2DynamicTree.cpp 65 | END 66 | b2TimeOfImpact.h 67 | K 25 68 | svn:wc:ra_dav:version-url 69 | V 61 70 | /svn/!svn/ver/33/trunk/Box2D/Box2D/Collision/b2TimeOfImpact.h 71 | END 72 | b2BroadPhase.cpp 73 | K 25 74 | svn:wc:ra_dav:version-url 75 | V 61 76 | /svn/!svn/ver/18/trunk/Box2D/Box2D/Collision/b2BroadPhase.cpp 77 | END 78 | b2DynamicTree.h 79 | K 25 80 | svn:wc:ra_dav:version-url 81 | V 61 82 | /svn/!svn/ver/103/trunk/Box2D/Box2D/Collision/b2DynamicTree.h 83 | END 84 | -------------------------------------------------------------------------------- /Box2D/Collision/.svn/text-base/b2TimeOfImpact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_TIME_OF_IMPACT_H 20 | #define B2_TIME_OF_IMPACT_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /// Input parameters for b2TimeOfImpact 27 | struct b2TOIInput 28 | { 29 | b2DistanceProxy proxyA; 30 | b2DistanceProxy proxyB; 31 | b2Sweep sweepA; 32 | b2Sweep sweepB; 33 | float32 tMax; // defines sweep interval [0, tMax] 34 | }; 35 | 36 | // Output parameters for b2TimeOfImpact. 37 | struct b2TOIOutput 38 | { 39 | enum State 40 | { 41 | e_unknown, 42 | e_failed, 43 | e_overlapped, 44 | e_touching, 45 | e_separated 46 | }; 47 | 48 | State state; 49 | float32 t; 50 | }; 51 | 52 | /// Compute the upper bound on time before two shapes penetrate. Time is represented as 53 | /// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, 54 | /// non-tunneling collision. If you change the time interval, you should call this function 55 | /// again. 56 | /// Note: use b2Distance to compute the contact point and normal at the time of impact. 57 | void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Box2D/Collision/Shapes/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 52 4 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/Shapes 5 | END 6 | b2EdgeShape.h 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 66 10 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/Shapes/b2EdgeShape.h 11 | END 12 | b2LoopShape.cpp 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 68 16 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/Shapes/b2LoopShape.cpp 17 | END 18 | b2PolygonShape.h 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 69 22 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Collision/Shapes/b2PolygonShape.h 23 | END 24 | b2LoopShape.h 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 66 28 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/Shapes/b2LoopShape.h 29 | END 30 | b2CircleShape.cpp 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 70 34 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Collision/Shapes/b2CircleShape.cpp 35 | END 36 | b2EdgeShape.cpp 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 68 40 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Collision/Shapes/b2EdgeShape.cpp 41 | END 42 | b2Shape.h 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 62 46 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Collision/Shapes/b2Shape.h 47 | END 48 | b2CircleShape.h 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 68 52 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Collision/Shapes/b2CircleShape.h 53 | END 54 | b2PolygonShape.cpp 55 | K 25 56 | svn:wc:ra_dav:version-url 57 | V 71 58 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Collision/Shapes/b2PolygonShape.cpp 59 | END 60 | -------------------------------------------------------------------------------- /Box2D/Collision/b2TimeOfImpact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_TIME_OF_IMPACT_H 20 | #define B2_TIME_OF_IMPACT_H 21 | 22 | #include 23 | #include 24 | 25 | /// Input parameters for b2TimeOfImpact 26 | struct b2TOIInput 27 | { 28 | b2DistanceProxy proxyA; 29 | b2DistanceProxy proxyB; 30 | b2Sweep sweepA; 31 | b2Sweep sweepB; 32 | float32 tMax; // defines sweep interval [0, tMax] 33 | }; 34 | 35 | // Output parameters for b2TimeOfImpact. 36 | struct b2TOIOutput 37 | { 38 | enum State 39 | { 40 | e_unknown, 41 | e_failed, 42 | e_overlapped, 43 | e_touching, 44 | e_separated 45 | }; 46 | 47 | State state; 48 | float32 t; 49 | }; 50 | 51 | /// Compute the upper bound on time before two shapes penetrate. Time is represented as 52 | /// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, 53 | /// non-tunneling collision. If you change the time interval, you should call this function 54 | /// again. 55 | /// Note: use b2Distance to compute the contact point and normal at the time of impact. 56 | void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Box2D/Common/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 42 4 | /svn/!svn/ver/113/trunk/Box2D/Box2D/Common 5 | END 6 | b2StackAllocator.h 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 59 10 | /svn/!svn/ver/2/trunk/Box2D/Box2D/Common/b2StackAllocator.h 11 | END 12 | b2BlockAllocator.cpp 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 62 16 | /svn/!svn/ver/63/trunk/Box2D/Box2D/Common/b2BlockAllocator.cpp 17 | END 18 | b2GrowableStack.h 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 60 22 | /svn/!svn/ver/103/trunk/Box2D/Box2D/Common/b2GrowableStack.h 23 | END 24 | b2Math.h 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 51 28 | /svn/!svn/ver/113/trunk/Box2D/Box2D/Common/b2Math.h 29 | END 30 | b2BlockAllocator.h 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 59 34 | /svn/!svn/ver/2/trunk/Box2D/Box2D/Common/b2BlockAllocator.h 35 | END 36 | b2Settings.cpp 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 57 40 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Common/b2Settings.cpp 41 | END 42 | b2Settings.h 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 54 46 | /svn/!svn/ver/69/trunk/Box2D/Box2D/Common/b2Settings.h 47 | END 48 | b2StackAllocator.cpp 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 61 52 | /svn/!svn/ver/2/trunk/Box2D/Box2D/Common/b2StackAllocator.cpp 53 | END 54 | b2Math.cpp 55 | K 25 56 | svn:wc:ra_dav:version-url 57 | V 52 58 | /svn/!svn/ver/27/trunk/Box2D/Box2D/Common/b2Math.cpp 59 | END 60 | -------------------------------------------------------------------------------- /Box2D/Common/.svn/text-base/b2BlockAllocator.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_BLOCK_ALLOCATOR_H 20 | #define B2_BLOCK_ALLOCATOR_H 21 | 22 | #include 23 | 24 | const int32 b2_chunkSize = 4096; 25 | const int32 b2_maxBlockSize = 640; 26 | const int32 b2_blockSizes = 14; 27 | const int32 b2_chunkArrayIncrement = 128; 28 | 29 | struct b2Block; 30 | struct b2Chunk; 31 | 32 | // This is a small object allocator used for allocating small 33 | // objects that persist for more than one time step. 34 | // See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp 35 | class b2BlockAllocator 36 | { 37 | public: 38 | b2BlockAllocator(); 39 | ~b2BlockAllocator(); 40 | 41 | void* Allocate(int32 size); 42 | void Free(void* p, int32 size); 43 | 44 | void Clear(); 45 | 46 | private: 47 | 48 | b2Chunk* m_chunks; 49 | int32 m_chunkCount; 50 | int32 m_chunkSpace; 51 | 52 | b2Block* m_freeLists[b2_blockSizes]; 53 | 54 | static int32 s_blockSizes[b2_blockSizes]; 55 | static uint8 s_blockSizeLookup[b2_maxBlockSize + 1]; 56 | static bool s_blockSizeLookupInitialized; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Box2D/Common/.svn/text-base/b2GrowableStack.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 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 | #ifndef B2_GROWABLE_STACK_H 20 | #define B2_GROWABLE_STACK_H 21 | #include 22 | 23 | /// This is a growable LIFO stack with an initial capacity of N. 24 | /// If the stack size exceeds the initial capacity, the heap is used 25 | /// to increase the size of the stack. 26 | template 27 | class b2GrowableStack 28 | { 29 | public: 30 | b2GrowableStack() 31 | { 32 | m_stack = m_array; 33 | m_count = 0; 34 | m_capacity = N; 35 | } 36 | 37 | ~b2GrowableStack() 38 | { 39 | if (m_stack != m_array) 40 | { 41 | b2Free(m_stack); 42 | m_stack = NULL; 43 | } 44 | } 45 | 46 | void Push(const T& element) 47 | { 48 | if (m_count == m_capacity) 49 | { 50 | T* old = m_stack; 51 | m_capacity *= 2; 52 | m_stack = (T*)b2Alloc(m_capacity * sizeof(T)); 53 | memcpy(m_stack, old, m_count * sizeof(T)); 54 | if (old != m_array) 55 | { 56 | b2Free(old); 57 | } 58 | } 59 | 60 | m_stack[m_count] = element; 61 | ++m_count; 62 | } 63 | 64 | T Pop() 65 | { 66 | b2Assert(m_count > 0); 67 | --m_count; 68 | return m_stack[m_count]; 69 | } 70 | 71 | int32 GetCount() 72 | { 73 | return m_count; 74 | } 75 | 76 | private: 77 | T* m_stack; 78 | T m_array[N]; 79 | int32 m_count; 80 | int32 m_capacity; 81 | }; 82 | 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /Box2D/Common/.svn/text-base/b2Math.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2009 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 | #include 20 | 21 | const b2Vec2 b2Vec2_zero(0.0f, 0.0f); 22 | const b2Mat22 b2Mat22_identity(1.0f, 0.0f, 0.0f, 1.0f); 23 | const b2Transform b2Transform_identity(b2Vec2_zero, b2Mat22_identity); 24 | 25 | /// Solve A * x = b, where b is a column vector. This is more efficient 26 | /// than computing the inverse in one-shot cases. 27 | b2Vec3 b2Mat33::Solve33(const b2Vec3& b) const 28 | { 29 | float32 det = b2Dot(col1, b2Cross(col2, col3)); 30 | if (det != 0.0f) 31 | { 32 | det = 1.0f / det; 33 | } 34 | b2Vec3 x; 35 | x.x = det * b2Dot(b, b2Cross(col2, col3)); 36 | x.y = det * b2Dot(col1, b2Cross(b, col3)); 37 | x.z = det * b2Dot(col1, b2Cross(col2, b)); 38 | return x; 39 | } 40 | 41 | /// Solve A * x = b, where b is a column vector. This is more efficient 42 | /// than computing the inverse in one-shot cases. 43 | b2Vec2 b2Mat33::Solve22(const b2Vec2& b) const 44 | { 45 | float32 a11 = col1.x, a12 = col2.x, a21 = col1.y, a22 = col2.y; 46 | float32 det = a11 * a22 - a12 * a21; 47 | if (det != 0.0f) 48 | { 49 | det = 1.0f / det; 50 | } 51 | b2Vec2 x; 52 | x.x = det * (a22 * b.x - a12 * b.y); 53 | x.y = det * (a11 * b.y - a21 * b.x); 54 | return x; 55 | } 56 | -------------------------------------------------------------------------------- /Box2D/Common/.svn/text-base/b2Settings.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | 22 | b2Version b2_version = {2, 2, 0}; 23 | 24 | // Memory allocators. Modify these to use your own allocator. 25 | void* b2Alloc(int32 size) 26 | { 27 | return malloc(size); 28 | } 29 | 30 | void b2Free(void* mem) 31 | { 32 | free(mem); 33 | } 34 | -------------------------------------------------------------------------------- /Box2D/Common/.svn/text-base/b2StackAllocator.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_STACK_ALLOCATOR_H 20 | #define B2_STACK_ALLOCATOR_H 21 | 22 | #include 23 | 24 | const int32 b2_stackSize = 100 * 1024; // 100k 25 | const int32 b2_maxStackEntries = 32; 26 | 27 | struct b2StackEntry 28 | { 29 | char* data; 30 | int32 size; 31 | bool usedMalloc; 32 | }; 33 | 34 | // This is a stack allocator used for fast per step allocations. 35 | // You must nest allocate/free pairs. The code will assert 36 | // if you try to interleave multiple allocate/free pairs. 37 | class b2StackAllocator 38 | { 39 | public: 40 | b2StackAllocator(); 41 | ~b2StackAllocator(); 42 | 43 | void* Allocate(int32 size); 44 | void Free(void* p); 45 | 46 | int32 GetMaxAllocation() const; 47 | 48 | private: 49 | 50 | char m_data[b2_stackSize]; 51 | int32 m_index; 52 | 53 | int32 m_allocation; 54 | int32 m_maxAllocation; 55 | 56 | b2StackEntry m_entries[b2_maxStackEntries]; 57 | int32 m_entryCount; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Box2D/Common/b2BlockAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_BLOCK_ALLOCATOR_H 20 | #define B2_BLOCK_ALLOCATOR_H 21 | 22 | #include 23 | 24 | const int32 b2_chunkSize = 4096; 25 | const int32 b2_maxBlockSize = 640; 26 | const int32 b2_blockSizes = 14; 27 | const int32 b2_chunkArrayIncrement = 128; 28 | 29 | struct b2Block; 30 | struct b2Chunk; 31 | 32 | /// This is a small object allocator used for allocating small 33 | /// objects that persist for more than one time step. 34 | /// See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp 35 | class b2BlockAllocator 36 | { 37 | public: 38 | b2BlockAllocator(); 39 | ~b2BlockAllocator(); 40 | 41 | /// Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize. 42 | void* Allocate(int32 size); 43 | 44 | /// Free memory. This will use b2Free if the size is larger than b2_maxBlockSize. 45 | void Free(void* p, int32 size); 46 | 47 | void Clear(); 48 | 49 | public: 50 | 51 | b2Chunk* m_chunks; 52 | int32 m_chunkCount; 53 | int32 m_chunkSpace; 54 | 55 | b2Block* m_freeLists[b2_blockSizes]; 56 | 57 | static int32 s_blockSizes[b2_blockSizes]; 58 | static uint8 s_blockSizeLookup[b2_maxBlockSize + 1]; 59 | static bool s_blockSizeLookupInitialized; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /Box2D/Common/b2GrowableStack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 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 | #ifndef B2_GROWABLE_STACK_H 20 | #define B2_GROWABLE_STACK_H 21 | #include 22 | #include 23 | 24 | /// This is a growable LIFO stack with an initial capacity of N. 25 | /// If the stack size exceeds the initial capacity, the heap is used 26 | /// to increase the size of the stack. 27 | template 28 | class b2GrowableStack 29 | { 30 | public: 31 | b2GrowableStack() 32 | { 33 | m_stack = m_array; 34 | m_count = 0; 35 | m_capacity = N; 36 | } 37 | 38 | ~b2GrowableStack() 39 | { 40 | if (m_stack != m_array) 41 | { 42 | b2Free(m_stack); 43 | m_stack = NULL; 44 | } 45 | } 46 | 47 | void Push(const T& element) 48 | { 49 | if (m_count == m_capacity) 50 | { 51 | T* old = m_stack; 52 | m_capacity *= 2; 53 | m_stack = (T*)b2Alloc(m_capacity * sizeof(T)); 54 | std::memcpy(m_stack, old, m_count * sizeof(T)); 55 | if (old != m_array) 56 | { 57 | b2Free(old); 58 | } 59 | } 60 | 61 | m_stack[m_count] = element; 62 | ++m_count; 63 | } 64 | 65 | T Pop() 66 | { 67 | b2Assert(m_count > 0); 68 | --m_count; 69 | return m_stack[m_count]; 70 | } 71 | 72 | int32 GetCount() 73 | { 74 | return m_count; 75 | } 76 | 77 | public: 78 | T* m_stack; 79 | T m_array[N]; 80 | int32 m_count; 81 | int32 m_capacity; 82 | }; 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Box2D/Common/b2Math.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2009 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 | #include 20 | 21 | const b2Vec2 b2Vec2_zero(0.0f, 0.0f); 22 | const b2Mat22 b2Mat22_identity(1.0f, 0.0f, 0.0f, 1.0f); 23 | const b2Transform b2Transform_identity(b2Vec2_zero, b2Mat22_identity); 24 | 25 | /// Solve A * x = b, where b is a column vector. This is more efficient 26 | /// than computing the inverse in one-shot cases. 27 | b2Vec3 b2Mat33::Solve33(const b2Vec3& b) const 28 | { 29 | float32 det = b2Dot(col1, b2Cross(col2, col3)); 30 | if (det != 0.0f) 31 | { 32 | det = 1.0f / det; 33 | } 34 | b2Vec3 x; 35 | x.x = det * b2Dot(b, b2Cross(col2, col3)); 36 | x.y = det * b2Dot(col1, b2Cross(b, col3)); 37 | x.z = det * b2Dot(col1, b2Cross(col2, b)); 38 | return x; 39 | } 40 | 41 | /// Solve A * x = b, where b is a column vector. This is more efficient 42 | /// than computing the inverse in one-shot cases. 43 | b2Vec2 b2Mat33::Solve22(const b2Vec2& b) const 44 | { 45 | float32 a11 = col1.x, a12 = col2.x, a21 = col1.y, a22 = col2.y; 46 | float32 det = a11 * a22 - a12 * a21; 47 | if (det != 0.0f) 48 | { 49 | det = 1.0f / det; 50 | } 51 | b2Vec2 x; 52 | x.x = det * (a22 * b.x - a12 * b.y); 53 | x.y = det * (a11 * b.y - a21 * b.x); 54 | return x; 55 | } 56 | -------------------------------------------------------------------------------- /Box2D/Common/b2Settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | 22 | b2Version b2_version = {2, 2, 0}; 23 | 24 | // Memory allocators. Modify these to use your own allocator. 25 | void* b2Alloc(int32 size) 26 | { 27 | return malloc(size); 28 | } 29 | 30 | void b2Free(void* mem) 31 | { 32 | free(mem); 33 | } 34 | -------------------------------------------------------------------------------- /Box2D/Common/b2StackAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_STACK_ALLOCATOR_H 20 | #define B2_STACK_ALLOCATOR_H 21 | 22 | #include 23 | 24 | const int32 b2_stackSize = 100 * 1024; // 100k 25 | const int32 b2_maxStackEntries = 32; 26 | 27 | struct b2StackEntry 28 | { 29 | char* data; 30 | int32 size; 31 | bool usedMalloc; 32 | }; 33 | 34 | // This is a stack allocator used for fast per step allocations. 35 | // You must nest allocate/free pairs. The code will assert 36 | // if you try to interleave multiple allocate/free pairs. 37 | class b2StackAllocator 38 | { 39 | public: 40 | b2StackAllocator(); 41 | ~b2StackAllocator(); 42 | 43 | void* Allocate(int32 size); 44 | void Free(void* p); 45 | 46 | int32 GetMaxAllocation() const; 47 | 48 | public: 49 | 50 | char m_data[b2_stackSize]; 51 | int32 m_index; 52 | 53 | int32 m_allocation; 54 | int32 m_maxAllocation; 55 | 56 | b2StackEntry m_entries[b2_maxStackEntries]; 57 | int32 m_entryCount; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Box2D/ConvexDecomposition/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 65 4 | /svn/!svn/ver/2/trunk/Contributions/Utilities/ConvexDecomposition 5 | END 6 | b2Triangle.h 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 78 10 | /svn/!svn/ver/2/trunk/Contributions/Utilities/ConvexDecomposition/b2Triangle.h 11 | END 12 | b2Polygon.h 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 77 16 | /svn/!svn/ver/2/trunk/Contributions/Utilities/ConvexDecomposition/b2Polygon.h 17 | END 18 | b2Triangle.cpp 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 80 22 | /svn/!svn/ver/2/trunk/Contributions/Utilities/ConvexDecomposition/b2Triangle.cpp 23 | END 24 | b2Polygon.cpp 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 79 28 | /svn/!svn/ver/2/trunk/Contributions/Utilities/ConvexDecomposition/b2Polygon.cpp 29 | END 30 | -------------------------------------------------------------------------------- /Box2D/ConvexDecomposition/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 31 5 | http://box2d.googlecode.com/svn/trunk/Contributions/Utilities/ConvexDecomposition 6 | http://box2d.googlecode.com/svn 7 | 8 | 9 | 10 | 2009-08-03T03:50:45.406654Z 11 | 2 12 | erincatto 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | cafe418c-1137-0410-84cc-357ec87a5d9b 28 | 29 | b2Triangle.h 30 | file 31 | 32 | 33 | 34 | 35 | 2009-12-18T23:09:20.000000Z 36 | 12e5760b7a3cf298750e6da386156628 37 | 2009-08-03T03:50:45.406654Z 38 | 2 39 | erincatto 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 1231 62 | 63 | b2Polygon.h 64 | file 65 | 66 | 67 | 68 | 69 | 2009-12-18T23:09:20.000000Z 70 | 78c8a348f1354b425c3bbe18bf33af23 71 | 2009-08-03T03:50:45.406654Z 72 | 2 73 | erincatto 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 3708 96 | 97 | b2Triangle.cpp 98 | file 99 | 100 | 101 | 102 | 103 | 2009-12-18T23:09:20.000000Z 104 | 394fd5c7bec326579ef108b9872a0e1d 105 | 2009-08-03T03:50:45.406654Z 106 | 2 107 | erincatto 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 2483 130 | 131 | b2Polygon.cpp 132 | file 133 | 134 | 135 | 136 | 137 | 2009-12-18T23:09:20.000000Z 138 | 7becc5adb708b18e2b1b8addf37360de 139 | 2009-08-03T03:50:45.406654Z 140 | 2 141 | erincatto 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 50218 164 | 165 | -------------------------------------------------------------------------------- /Box2D/ConvexDecomposition/.svn/text-base/b2Triangle.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Eric Jordan 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 | #ifndef B2_TRIANGLE_H 20 | #define B2_TRIANGLE_H 21 | 22 | #include "../../Source/Common/b2Math.h" 23 | 24 | class b2Triangle{ 25 | public: 26 | float* x; 27 | float* y; 28 | b2Triangle(); 29 | b2Triangle(float32 x1, float32 y1, float32 x2, float32 y2, float32 x3, float32 y3); 30 | ~b2Triangle(); 31 | bool IsInside(float32 _x, float32 _y); 32 | void Set(const b2Triangle& toMe); 33 | 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /Box2D/ConvexDecomposition/b2Triangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Eric Jordan 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 | #ifndef B2_TRIANGLE_H 20 | #define B2_TRIANGLE_H 21 | 22 | //#include "Box2D/Source/Common/b2Math.h" 23 | 24 | class b2Triangle{ 25 | public: 26 | float* x; 27 | float* y; 28 | b2Triangle(); 29 | b2Triangle(float32 x1, float32 y1, float32 x2, float32 y2, float32 x3, float32 y3); 30 | ~b2Triangle(); 31 | bool IsInside(float32 _x, float32 _y); 32 | void Set(const b2Triangle& toMe); 33 | 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /Box2D/Dynamics/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 44 4 | /svn/!svn/ver/116/trunk/Box2D/Box2D/Dynamics 5 | END 6 | b2Island.cpp 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 57 10 | /svn/!svn/ver/116/trunk/Box2D/Box2D/Dynamics/b2Island.cpp 11 | END 12 | b2ContactManager.h 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 62 16 | /svn/!svn/ver/69/trunk/Box2D/Box2D/Dynamics/b2ContactManager.h 17 | END 18 | b2Fixture.h 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 56 22 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Dynamics/b2Fixture.h 23 | END 24 | b2WorldCallbacks.h 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 63 28 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Dynamics/b2WorldCallbacks.h 29 | END 30 | b2World.h 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 54 34 | /svn/!svn/ver/114/trunk/Box2D/Box2D/Dynamics/b2World.h 35 | END 36 | b2Body.cpp 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 55 40 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Dynamics/b2Body.cpp 41 | END 42 | b2TimeStep.h 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 56 46 | /svn/!svn/ver/31/trunk/Box2D/Box2D/Dynamics/b2TimeStep.h 47 | END 48 | b2Island.h 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 55 52 | /svn/!svn/ver/113/trunk/Box2D/Box2D/Dynamics/b2Island.h 53 | END 54 | b2Body.h 55 | K 25 56 | svn:wc:ra_dav:version-url 57 | V 53 58 | /svn/!svn/ver/114/trunk/Box2D/Box2D/Dynamics/b2Body.h 59 | END 60 | b2Fixture.cpp 61 | K 25 62 | svn:wc:ra_dav:version-url 63 | V 58 64 | /svn/!svn/ver/112/trunk/Box2D/Box2D/Dynamics/b2Fixture.cpp 65 | END 66 | b2ContactManager.cpp 67 | K 25 68 | svn:wc:ra_dav:version-url 69 | V 65 70 | /svn/!svn/ver/109/trunk/Box2D/Box2D/Dynamics/b2ContactManager.cpp 71 | END 72 | b2WorldCallbacks.cpp 73 | K 25 74 | svn:wc:ra_dav:version-url 75 | V 64 76 | /svn/!svn/ver/71/trunk/Box2D/Box2D/Dynamics/b2WorldCallbacks.cpp 77 | END 78 | b2World.cpp 79 | K 25 80 | svn:wc:ra_dav:version-url 81 | V 56 82 | /svn/!svn/ver/116/trunk/Box2D/Box2D/Dynamics/b2World.cpp 83 | END 84 | -------------------------------------------------------------------------------- /Box2D/Dynamics/.svn/text-base/b2ContactManager.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_CONTACT_MANAGER_H 20 | #define B2_CONTACT_MANAGER_H 21 | 22 | #include 23 | 24 | class b2Contact; 25 | class b2ContactFilter; 26 | class b2ContactListener; 27 | class b2BlockAllocator; 28 | 29 | // Delegate of b2World. 30 | class b2ContactManager 31 | { 32 | public: 33 | b2ContactManager(); 34 | 35 | // Broad-phase callback. 36 | void AddPair(void* proxyUserDataA, void* proxyUserDataB); 37 | 38 | void FindNewContacts(); 39 | 40 | void Destroy(b2Contact* c); 41 | 42 | void Collide(); 43 | 44 | b2BroadPhase m_broadPhase; 45 | b2Contact* m_contactList; 46 | int32 m_contactCount; 47 | b2ContactFilter* m_contactFilter; 48 | b2ContactListener* m_contactListener; 49 | b2BlockAllocator* m_allocator; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Box2D/Dynamics/.svn/text-base/b2TimeStep.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_TIME_STEP_H 20 | #define B2_TIME_STEP_H 21 | 22 | #include 23 | 24 | /// This is an internal structure. 25 | struct b2TimeStep 26 | { 27 | float32 dt; // time step 28 | float32 inv_dt; // inverse time step (0 if dt == 0). 29 | float32 dtRatio; // dt * inv_dt0 30 | int32 velocityIterations; 31 | int32 positionIterations; 32 | bool warmStarting; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Box2D/Dynamics/.svn/text-base/b2WorldCallbacks.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | 22 | // Return true if contact calculations should be performed between these two shapes. 23 | // If you implement your own collision filter you may want to build from this implementation. 24 | bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB) 25 | { 26 | const b2Filter& filterA = fixtureA->GetFilterData(); 27 | const b2Filter& filterB = fixtureB->GetFilterData(); 28 | 29 | if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) 30 | { 31 | return filterA.groupIndex > 0; 32 | } 33 | 34 | bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0; 35 | return collide; 36 | } 37 | 38 | b2DebugDraw::b2DebugDraw() 39 | { 40 | m_drawFlags = 0; 41 | } 42 | 43 | void b2DebugDraw::SetFlags(uint32 flags) 44 | { 45 | m_drawFlags = flags; 46 | } 47 | 48 | uint32 b2DebugDraw::GetFlags() const 49 | { 50 | return m_drawFlags; 51 | } 52 | 53 | void b2DebugDraw::AppendFlags(uint32 flags) 54 | { 55 | m_drawFlags |= flags; 56 | } 57 | 58 | void b2DebugDraw::ClearFlags(uint32 flags) 59 | { 60 | m_drawFlags &= ~flags; 61 | } 62 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2CircleContact.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | using namespace std; 28 | 29 | b2Contact* b2CircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 30 | { 31 | void* mem = allocator->Allocate(sizeof(b2CircleContact)); 32 | return new (mem) b2CircleContact(fixtureA, fixtureB); 33 | } 34 | 35 | void b2CircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 36 | { 37 | ((b2CircleContact*)contact)->~b2CircleContact(); 38 | allocator->Free(contact, sizeof(b2CircleContact)); 39 | } 40 | 41 | b2CircleContact::b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 42 | : b2Contact(fixtureA, 0, fixtureB, 0) 43 | { 44 | b2Assert(m_fixtureA->GetType() == b2Shape::e_circle); 45 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 46 | } 47 | 48 | void b2CircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 49 | { 50 | b2CollideCircles(manifold, 51 | (b2CircleShape*)m_fixtureA->GetShape(), xfA, 52 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 53 | } 54 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2CircleContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_CIRCLE_CONTACT_H 20 | #define B2_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2CircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2CircleContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2EdgeAndCircleContact.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2010 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 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | using namespace std; 25 | 26 | b2Contact* b2EdgeAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 27 | { 28 | void* mem = allocator->Allocate(sizeof(b2EdgeAndCircleContact)); 29 | return new (mem) b2EdgeAndCircleContact(fixtureA, fixtureB); 30 | } 31 | 32 | void b2EdgeAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 33 | { 34 | ((b2EdgeAndCircleContact*)contact)->~b2EdgeAndCircleContact(); 35 | allocator->Free(contact, sizeof(b2EdgeAndCircleContact)); 36 | } 37 | 38 | b2EdgeAndCircleContact::b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 39 | : b2Contact(fixtureA, 0, fixtureB, 0) 40 | { 41 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 42 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 43 | } 44 | 45 | void b2EdgeAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 46 | { 47 | b2CollideEdgeAndCircle( manifold, 48 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 49 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 50 | } 51 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2EdgeAndCircleContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_EDGE_AND_CIRCLE_CONTACT_H 20 | #define B2_EDGE_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2EdgeAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2EdgeAndCircleContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2EdgeAndPolygonContact.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2010 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 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | using namespace std; 25 | 26 | b2Contact* b2EdgeAndPolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 27 | { 28 | void* mem = allocator->Allocate(sizeof(b2EdgeAndPolygonContact)); 29 | return new (mem) b2EdgeAndPolygonContact(fixtureA, fixtureB); 30 | } 31 | 32 | void b2EdgeAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 33 | { 34 | ((b2EdgeAndPolygonContact*)contact)->~b2EdgeAndPolygonContact(); 35 | allocator->Free(contact, sizeof(b2EdgeAndPolygonContact)); 36 | } 37 | 38 | b2EdgeAndPolygonContact::b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 39 | : b2Contact(fixtureA, 0, fixtureB, 0) 40 | { 41 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 42 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 43 | } 44 | 45 | void b2EdgeAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 46 | { 47 | b2CollideEdgeAndPolygon( manifold, 48 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 49 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 50 | } 51 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2EdgeAndPolygonContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_EDGE_AND_POLYGON_CONTACT_H 20 | #define B2_EDGE_AND_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2EdgeAndPolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2EdgeAndPolygonContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2LoopAndCircleContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_LOOP_AND_CIRCLE_CONTACT_H 20 | #define B2_LOOP_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2LoopAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2LoopAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 34 | ~b2LoopAndCircleContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2LoopAndPolygonContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_LOOP_AND_POLYGON_CONTACT_H 20 | #define B2_LOOP_AND_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2LoopAndPolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2LoopAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 34 | ~b2LoopAndPolygonContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2NullContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_NULL_CONTACT_H 20 | #define B2_NULL_CONTACT_H 21 | 22 | #include 23 | 24 | class b2NullContact : public b2Contact 25 | { 26 | public: 27 | b2NullContact() {} 28 | void Evaluate() {} 29 | float32 ComputeTOI(const b2Sweep& sweepA, const b2Sweep& sweepB) const 30 | { 31 | B2_NOT_USED(sweepA); 32 | B2_NOT_USED(sweepB); 33 | return 1.0f; 34 | } 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2PolygonAndCircleContact.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | using namespace std; 25 | 26 | b2Contact* b2PolygonAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 27 | { 28 | void* mem = allocator->Allocate(sizeof(b2PolygonAndCircleContact)); 29 | return new (mem) b2PolygonAndCircleContact(fixtureA, fixtureB); 30 | } 31 | 32 | void b2PolygonAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 33 | { 34 | ((b2PolygonAndCircleContact*)contact)->~b2PolygonAndCircleContact(); 35 | allocator->Free(contact, sizeof(b2PolygonAndCircleContact)); 36 | } 37 | 38 | b2PolygonAndCircleContact::b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 39 | : b2Contact(fixtureA, 0, fixtureB, 0) 40 | { 41 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 42 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 43 | } 44 | 45 | void b2PolygonAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 46 | { 47 | b2CollidePolygonAndCircle( manifold, 48 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 49 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 50 | } 51 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2PolygonAndCircleContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H 20 | #define B2_POLYGON_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2PolygonAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 30 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 31 | 32 | b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 33 | ~b2PolygonAndCircleContact() {} 34 | 35 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/.svn/text-base/b2PolygonContact.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_POLYGON_CONTACT_H 20 | #define B2_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2PolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2PolygonContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2CircleContact.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | using namespace std; 28 | 29 | b2Contact* b2CircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 30 | { 31 | void* mem = allocator->Allocate(sizeof(b2CircleContact)); 32 | return new (mem) b2CircleContact(fixtureA, fixtureB); 33 | } 34 | 35 | void b2CircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 36 | { 37 | ((b2CircleContact*)contact)->~b2CircleContact(); 38 | allocator->Free(contact, sizeof(b2CircleContact)); 39 | } 40 | 41 | b2CircleContact::b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 42 | : b2Contact(fixtureA, 0, fixtureB, 0) 43 | { 44 | b2Assert(m_fixtureA->GetType() == b2Shape::e_circle); 45 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 46 | } 47 | 48 | void b2CircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 49 | { 50 | b2CollideCircles(manifold, 51 | (b2CircleShape*)m_fixtureA->GetShape(), xfA, 52 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 53 | } 54 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2CircleContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_CIRCLE_CONTACT_H 20 | #define B2_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2CircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2CircleContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2010 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 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | using namespace std; 25 | 26 | b2Contact* b2EdgeAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 27 | { 28 | void* mem = allocator->Allocate(sizeof(b2EdgeAndCircleContact)); 29 | return new (mem) b2EdgeAndCircleContact(fixtureA, fixtureB); 30 | } 31 | 32 | void b2EdgeAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 33 | { 34 | ((b2EdgeAndCircleContact*)contact)->~b2EdgeAndCircleContact(); 35 | allocator->Free(contact, sizeof(b2EdgeAndCircleContact)); 36 | } 37 | 38 | b2EdgeAndCircleContact::b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 39 | : b2Contact(fixtureA, 0, fixtureB, 0) 40 | { 41 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 42 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 43 | } 44 | 45 | void b2EdgeAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 46 | { 47 | b2CollideEdgeAndCircle( manifold, 48 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 49 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 50 | } 51 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_EDGE_AND_CIRCLE_CONTACT_H 20 | #define B2_EDGE_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2EdgeAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2EdgeAndCircleContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2010 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 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | using namespace std; 25 | 26 | b2Contact* b2EdgeAndPolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 27 | { 28 | void* mem = allocator->Allocate(sizeof(b2EdgeAndPolygonContact)); 29 | return new (mem) b2EdgeAndPolygonContact(fixtureA, fixtureB); 30 | } 31 | 32 | void b2EdgeAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 33 | { 34 | ((b2EdgeAndPolygonContact*)contact)->~b2EdgeAndPolygonContact(); 35 | allocator->Free(contact, sizeof(b2EdgeAndPolygonContact)); 36 | } 37 | 38 | b2EdgeAndPolygonContact::b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 39 | : b2Contact(fixtureA, 0, fixtureB, 0) 40 | { 41 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 42 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 43 | } 44 | 45 | void b2EdgeAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 46 | { 47 | b2CollideEdgeAndPolygon( manifold, 48 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 49 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 50 | } 51 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_EDGE_AND_POLYGON_CONTACT_H 20 | #define B2_EDGE_AND_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2EdgeAndPolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2EdgeAndPolygonContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2LoopAndCircleContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_LOOP_AND_CIRCLE_CONTACT_H 20 | #define B2_LOOP_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2LoopAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2LoopAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 34 | ~b2LoopAndCircleContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2LoopAndPolygonContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_LOOP_AND_POLYGON_CONTACT_H 20 | #define B2_LOOP_AND_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2LoopAndPolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2LoopAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 34 | ~b2LoopAndPolygonContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2NullContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_NULL_CONTACT_H 20 | #define B2_NULL_CONTACT_H 21 | 22 | #include 23 | 24 | class b2NullContact : public b2Contact 25 | { 26 | public: 27 | b2NullContact() {} 28 | void Evaluate() {} 29 | float32 ComputeTOI(const b2Sweep& sweepA, const b2Sweep& sweepB) const 30 | { 31 | B2_NOT_USED(sweepA); 32 | B2_NOT_USED(sweepB); 33 | return 1.0f; 34 | } 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | using namespace std; 25 | 26 | b2Contact* b2PolygonAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 27 | { 28 | void* mem = allocator->Allocate(sizeof(b2PolygonAndCircleContact)); 29 | return new (mem) b2PolygonAndCircleContact(fixtureA, fixtureB); 30 | } 31 | 32 | void b2PolygonAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 33 | { 34 | ((b2PolygonAndCircleContact*)contact)->~b2PolygonAndCircleContact(); 35 | allocator->Free(contact, sizeof(b2PolygonAndCircleContact)); 36 | } 37 | 38 | b2PolygonAndCircleContact::b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 39 | : b2Contact(fixtureA, 0, fixtureB, 0) 40 | { 41 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 42 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 43 | } 44 | 45 | void b2PolygonAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 46 | { 47 | b2CollidePolygonAndCircle( manifold, 48 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 49 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 50 | } 51 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H 20 | #define B2_POLYGON_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2PolygonAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 30 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 31 | 32 | b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 33 | ~b2PolygonAndCircleContact() {} 34 | 35 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2PolygonContact.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | using namespace std; 28 | 29 | b2Contact* b2PolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 30 | { 31 | void* mem = allocator->Allocate(sizeof(b2PolygonContact)); 32 | return new (mem) b2PolygonContact(fixtureA, fixtureB); 33 | } 34 | 35 | void b2PolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 36 | { 37 | ((b2PolygonContact*)contact)->~b2PolygonContact(); 38 | allocator->Free(contact, sizeof(b2PolygonContact)); 39 | } 40 | 41 | b2PolygonContact::b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 42 | : b2Contact(fixtureA, 0, fixtureB, 0) 43 | { 44 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 45 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 46 | } 47 | 48 | void b2PolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 49 | { 50 | b2CollidePolygons( manifold, 51 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 52 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 53 | } 54 | -------------------------------------------------------------------------------- /Box2D/Dynamics/Contacts/b2PolygonContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_POLYGON_CONTACT_H 20 | #define B2_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2PolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 30 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 31 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 32 | 33 | b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 34 | ~b2PolygonContact() {} 35 | 36 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Box2D/Dynamics/b2ContactManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_CONTACT_MANAGER_H 20 | #define B2_CONTACT_MANAGER_H 21 | 22 | #include 23 | 24 | class b2Contact; 25 | class b2ContactFilter; 26 | class b2ContactListener; 27 | class b2BlockAllocator; 28 | 29 | // Delegate of b2World. 30 | class b2ContactManager 31 | { 32 | public: 33 | b2ContactManager(); 34 | 35 | // Broad-phase callback. 36 | void AddPair(void* proxyUserDataA, void* proxyUserDataB); 37 | 38 | void FindNewContacts(); 39 | 40 | void Destroy(b2Contact* c); 41 | 42 | void Collide(); 43 | 44 | b2BroadPhase m_broadPhase; 45 | b2Contact* m_contactList; 46 | int32 m_contactCount; 47 | b2ContactFilter* m_contactFilter; 48 | b2ContactListener* m_contactListener; 49 | b2BlockAllocator* m_allocator; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Box2D/Dynamics/b2TimeStep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #ifndef B2_TIME_STEP_H 20 | #define B2_TIME_STEP_H 21 | 22 | #include 23 | 24 | /// This is an internal structure. 25 | struct b2TimeStep 26 | { 27 | float32 dt; // time step 28 | float32 inv_dt; // inverse time step (0 if dt == 0). 29 | float32 dtRatio; // dt * inv_dt0 30 | int32 velocityIterations; 31 | int32 positionIterations; 32 | bool warmStarting; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Box2D/Dynamics/b2WorldCallbacks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 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 | #include 20 | #include 21 | 22 | // Return true if contact calculations should be performed between these two shapes. 23 | // If you implement your own collision filter you may want to build from this implementation. 24 | bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB) 25 | { 26 | const b2Filter& filterA = fixtureA->GetFilterData(); 27 | const b2Filter& filterB = fixtureB->GetFilterData(); 28 | 29 | if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) 30 | { 31 | return filterA.groupIndex > 0; 32 | } 33 | 34 | bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0; 35 | return collide; 36 | } 37 | 38 | b2DebugDraw::b2DebugDraw() 39 | { 40 | m_drawFlags = 0; 41 | } 42 | 43 | void b2DebugDraw::SetFlags(uint32 flags) 44 | { 45 | m_drawFlags = flags; 46 | } 47 | 48 | uint32 b2DebugDraw::GetFlags() const 49 | { 50 | return m_drawFlags; 51 | } 52 | 53 | void b2DebugDraw::AppendFlags(uint32 flags) 54 | { 55 | m_drawFlags |= flags; 56 | } 57 | 58 | void b2DebugDraw::ClearFlags(uint32 flags) 59 | { 60 | m_drawFlags &= ~flags; 61 | } 62 | -------------------------------------------------------------------------------- /Box2DAS/Box2D.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | To compile the SWC: 4 | 5 | alc-on; g++ Box2D.c -I.. -O3 -Wall -swc -DOSX -o Box2D.swc; alc-off 6 | 7 | To see the temporary AS files: 8 | 9 | export ACHACKS_TMPS=1 10 | 11 | 12 | */ 13 | #include "Box2DAS/Box2D.h"; 14 | 15 | int main() { 16 | AS3_LibInit(b2Core()); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Box2DAS/Box2D.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/Box2DAS/Box2D.swc -------------------------------------------------------------------------------- /Box2DAS/Collision/AABB.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; /// An axis aligned bounding box. public class AABB { public function AABB(l:V2 = null, u:V2 = null) { if(l) lowerBound.xy(l.x, l.y); if(u) upperBound.xy(u.x, u.y); } public function get width():Number { return upperBound.x - lowerBound.x; } public function get height():Number { return upperBound.y - lowerBound.y; } /// Verify that the bounds are sorted. /// bool IsValid() const; public function IsValid():Boolean { var v:V2 = V2.subtract(upperBound, lowerBound); return v.x > 0 && v.y > 0; } /// Get the center of the AABB. /// b2Vec2 GetCenter() const public function getCenter():V2 { return V2.add(lowerBound, upperBound).divideN(2); } /// Get the extents of the AABB (half-widths). /// b2Vec2 GetExtents() const public function GetExtents():V2 { return V2.subtract(upperBound, lowerBound).divideN(2); } /// Combine two AABBs into this one. /// void Combine(const b2AABB& aabb1, const b2AABB& aabb2) public function Combine(aabb1:AABB, aabb2:AABB):void { lowerBound = V2.min(aabb1.lowerBound, aabb2.lowerBound); upperBound = V2.max(aabb1.upperBound, aabb2.upperBound); } /// Does this aabb contain the provided AABB. /// bool Contains(const b2AABB& aabb) const public function Contains(aabb:AABB):Boolean { return ( (lowerBound.x <= aabb.lowerBound.x) && (lowerBound.y <= aabb.lowerBound.y) && (aabb.upperBound.x <= upperBound.x) && (aabb.upperBound.y <= upperBound.y)); } public function Expand(v:Number):void { lowerBound.subtractN(v); upperBound.addN(v); } public function toString():String { return ', <' + upperBound.x + ', ' + upperBound.y + '>>' } public static function FromV2(v:V2, expandX:Number = 0.001, expandY:Number = 0.001):AABB { return new AABB(new V2(v.x - expandX, v.y - expandY), new V2(v.x + expandX, v.y + expandY)); } public var lowerBound:V2 = new V2(); public var upperBound:V2 = new V2(); } } -------------------------------------------------------------------------------- /Box2DAS/Collision/Shapes/b2EdgeShape.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision.Shapes { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.display.*; /// A line segment (edge) shape. These can be connected in chains or loops /// to other edge shapes. The connectivity information is used to ensure /// correct contact normals. public class b2EdgeShape extends b2Shape { public function b2EdgeShape(p:int = 0) { _ptr = (p == 0 ? lib.b2EdgeShape_new() : p); m_vertex0 = new b2Vec2(_ptr + 32); m_vertex1 = new b2Vec2(_ptr + 16); m_vertex2 = new b2Vec2(_ptr + 24); m_vertex3 = new b2Vec2(_ptr + 40); } /// Draw the edge. You must set the stroke/fill style before calling. public override function Draw(g:Graphics, xf:XF, scale:Number = 1, options:Object = null):void { var v1:V2 = xf.multiply(m_vertex1.v2); var v2:V2 = xf.multiply(m_vertex2.v2); g.moveTo(v1.x * scale, v1.y * scale); g.lineTo(v2.x * scale, v2.y * scale); } public var m_vertex0:b2Vec2; // m_vertex0 = new b2Vec2(_ptr + 32); public var m_vertex1:b2Vec2; // m_vertex1 = new b2Vec2(_ptr + 16); public var m_vertex2:b2Vec2; // m_vertex2 = new b2Vec2(_ptr + 24); public var m_vertex3:b2Vec2; // m_vertex3 = new b2Vec2(_ptr + 40); public function get m_hasVertex0():Boolean { return mem._mru8(_ptr + 48) == 1; } public function set m_hasVertex0(v:Boolean):void { mem._mw8(_ptr + 48, v ? 1 : 0); } public function get m_hasVertex3():Boolean { return mem._mru8(_ptr + 49) == 1; } public function set m_hasVertex3(v:Boolean):void { mem._mw8(_ptr + 49, v ? 1 : 0); } } } -------------------------------------------------------------------------------- /Box2DAS/Collision/Shapes/b2LoopShape.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision.Shapes { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.display.*; /// A loop shape is a free form sequence of line segments that form a circular list. /// The loop may cross upon itself, but this is not recommended for smooth collision. /// The loop has double sided collision, so you can use inside and outside collision. /// Therefore, you may use any winding order. public class b2LoopShape extends b2Shape { public function b2LoopShape(p:int = 0) { _ptr = (p == 0 ? lib.b2LoopShape_new() : p); } public function set m_vertices(v:Vector.):void { if(m_verticesSet) { destroyVertices(); } m_verticesSet = true; m_verticesPtr = lib.b2Vec2Array_new(v.length); m_count = v.length; writeVertices(m_verticesPtr, v); } public function get m_vertices():Vector. { return readVertices(m_verticesPtr, m_count); } public function destroyVertices():void { m_verticesSet = false; lib.b2Vec2Array_delete(m_verticesPtr); } public override function destroy():void { destroyVertices(); super.destroy(); } /// Draw the loop to a graphics object. You must set the fill/stroke style before calling. public override function Draw(g:Graphics, xf:XF, scale:Number = 1, options:Object = null):void { var vertices:Vector. = m_vertices; var vertexCount:Number = m_count; var v:V2 = xf.multiply(vertices[0]); g.moveTo(v.x * scale, v.y * scale); if(options && options.startPoint) { g.drawCircle(v.x * scale, v.y * scale, 3); } for(var i:int = 1; i < vertexCount; ++i) { v = xf.multiply(vertices[i]); g.lineTo(v.x * scale, v.y * scale); } v = xf.multiply(vertices[0]); g.lineTo(v.x * scale, v.y * scale); } public var m_verticesSet:Boolean = false; public function get m_verticesPtr():int { return mem._mr32(_ptr + 16); } public function set m_verticesPtr(v:int):void { mem._mw32(_ptr + 16, v); } public function get m_count():int { return mem._mr32(_ptr + 20); } public function set m_count(v:int):void { mem._mw32(_ptr + 20, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Collision/Shapes/b2MassData.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision.Shapes { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2MassData extends b2Base { 13 | 14 | public function b2MassData(p:int = 0) { 15 | _ptr = p ? p : lib.b2MassData_new(); 16 | center = new b2Vec2(_ptr + 4); 17 | } 18 | 19 | public function get mass():Number { return mem._mrf(_ptr + 0); } 20 | public function set mass(v:Number):void { mem._mwf(_ptr + 0, v); } 21 | public var center:b2Vec2; // center = new b2Vec2(_ptr + 4); 22 | public function get I():Number { return mem._mrf(_ptr + 12); } 23 | public function set I(v:Number):void { mem._mwf(_ptr + 12, v); } 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2AABB.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | /// An axis aligned bounding box. 13 | public class b2AABB extends b2Base { 14 | 15 | public function b2AABB(p:int) { 16 | _ptr = p; 17 | lowerBound = new b2Vec2(_ptr + 0); 18 | upperBound = new b2Vec2(_ptr + 8); 19 | } 20 | 21 | public function get aabb():AABB { 22 | return new AABB(lowerBound.v2, upperBound.v2); 23 | } 24 | 25 | public function set aabb(v:AABB):void { 26 | lowerBound.v2 = v.lowerBound; 27 | upperBound.v2 = v.upperBound; 28 | } 29 | 30 | public var lowerBound:b2Vec2; // lowerBound = new b2Vec2(_ptr + 0); 31 | public var upperBound:b2Vec2; // upperBound = new b2Vec2(_ptr + 8); 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2BroadPhase.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | /// The broad-phase is used for computing pairs and performing volume queries and ray casts. 13 | /// This broad-phase does not persist pairs. Instead, this reports potentially new pairs. 14 | /// It is up to the client to consume the new pairs and to track subsequent overlap. 15 | public class b2BroadPhase extends b2Base { 16 | 17 | public function b2BroadPhase(p:int) { 18 | _ptr = p; 19 | } 20 | 21 | /// Get the number of proxies. 22 | public function GetProxyCount():int { 23 | return m_proxyCount; 24 | } 25 | 26 | public static const e_nullProxy:int = -1; 27 | 28 | public function get m_proxyCount():int { return mem._mr32(_ptr + 28); } 29 | public function set m_proxyCount(v:int):void { mem._mw32(_ptr + 28, v); } 30 | public function get m_moveBuffer():int { return mem._mr32(_ptr + 32); } 31 | public function set m_moveBuffer(v:int):void { mem._mw32(_ptr + 32, v); } 32 | public function get m_moveCapacity():int { return mem._mr32(_ptr + 36); } 33 | public function set m_moveCapacity(v:int):void { mem._mw32(_ptr + 36, v); } 34 | public function get m_moveCount():int { return mem._mr32(_ptr + 40); } 35 | public function set m_moveCount(v:int):void { mem._mw32(_ptr + 40, v); } 36 | public function get m_pairCapacity():int { return mem._mr32(_ptr + 48); } 37 | public function set m_pairCapacity(v:int):void { mem._mw32(_ptr + 48, v); } 38 | public function get m_pairCount():int { return mem._mr32(_ptr + 52); } 39 | public function set m_pairCount(v:int):void { mem._mw32(_ptr + 52, v); } 40 | public function get m_queryProxyId():int { return mem._mr32(_ptr + 56); } 41 | public function set m_queryProxyId(v:int):void { mem._mw32(_ptr + 56, v); } 42 | } 43 | } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2Distance.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; /// Compute the closest points between two shapes. Supports any combination of: /// b2CircleShape, b2PolygonShape, b2EdgeShape. The simplex cache is input/output. /// On the first call set b2SimplexCache.count to zero. /// void b2Distance(b2DistanceOutput* output, /// b2SimplexCache* cache, /// const b2DistanceInput* input); public function b2Distance( output:b2DistanceOutput = null, cache:b2SimplexCache = null, input:b2DistanceInput = null ):void { output ||= b2Def.distanceOutput; cache ||= b2Def.simplexCache; input ||= b2Def.distanceInput; b2Base.lib.b2Distance(output._ptr, cache._ptr, input._ptr); } } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2DistanceInput.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; public class b2DistanceInput extends b2Base { public function b2DistanceInput() { _ptr = lib.b2DistanceInput_new(); proxyA = new b2DistanceProxy(_ptr + 0); proxyB = new b2DistanceProxy(_ptr + 28); transformA = new b2Transform(_ptr + 56); transformB = new b2Transform(_ptr + 80); } public override function destroy():void { lib.b2DistanceInput_delete(_ptr); super.destroy(); } public function init(f1:b2Fixture, f2:b2Fixture):void { proxyA.Set(f1.m_shape); proxyB.Set(f2.m_shape); transformA.xf = f1.m_body.m_xf.xf; transformB.xf = f2.m_body.m_xf.xf; } public var proxyA:b2DistanceProxy; public var proxyB:b2DistanceProxy; public var transformA:b2Transform; public var transformB:b2Transform; public function get useRadii():Boolean { return mem._mru8(_ptr + 104) == 1; } public function set useRadii(v:Boolean):void { mem._mw8(_ptr + 104, v ? 1 : 0); } } } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2DistanceOutput.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; public class b2DistanceOutput extends b2Base { public function b2DistanceOutput() { _ptr = lib.b2DistanceOutput_new(); pointA = new b2Vec2(_ptr + 0); pointB = new b2Vec2(_ptr + 8); } public override function destroy():void { lib.b2DistanceOutput_delete(_ptr); super.destroy(); } public var pointA:b2Vec2; public var pointB:b2Vec2; public function get distance():Number { return mem._mrf(_ptr + 16); } public function set distance(v:Number):void { mem._mwf(_ptr + 16, v); } public function get iterations():int { return mem._mr32(_ptr + 20); } public function set iterations(v:int):void { mem._mw32(_ptr + 20, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2DistanceProxy.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; /// A distance proxy is used by the GJK algorithm. /// It encapsulates any shape. public class b2DistanceProxy extends b2Base { public function b2DistanceProxy(p:int) { _ptr = p; } /// Note: m_vertices is a pointer. You can't actually get vertices from it. public function get m_vertices():int { return mem._mr32(_ptr + 16); } public function set m_vertices(v:int):void { mem._mw32(_ptr + 16, v); } public function get m_count():int { return mem._mr32(_ptr + 20); } public function set m_count(v:int):void { mem._mw32(_ptr + 20, v); } public function get m_radius():Number { return mem._mrf(_ptr + 24); } public function set m_radius(v:Number):void { mem._mwf(_ptr + 24, v); } public function Set(shape:b2Shape):void { switch (shape.m_type) { case b2Shape.e_circle: var circle:b2CircleShape = shape as b2CircleShape; m_vertices = circle._ptr + 16; // Address of m_p variable. m_count = 1; m_radius = circle.m_radius; break; case b2Shape.e_polygon: var polygon:b2PolygonShape = shape as b2PolygonShape; m_vertices = polygon._ptr + 24; // Address of m_vertices. m_count = polygon.m_vertexCount; m_radius = polygon.m_radius; break; } } } } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2Manifold.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Manifold extends b2Base { 13 | 14 | public static var e_circles:int = 0; 15 | public static var e_faceA:int = 1; 16 | public static var e_faceB:int = 2; 17 | 18 | public function b2Manifold(p:int) { 19 | _ptr = p; 20 | //localPlaneNormal = new b2Vec2(_ptr + 40); 21 | //localPoint = new b2Vec2(_ptr + 48); 22 | localNormal = new b2Vec2(_ptr + 48); 23 | localPoint = new b2Vec2(_ptr + 56); 24 | points[0] = new b2ManifoldPoint(_ptr + 0); 25 | //points[1] = new b2ManifoldPoint(_ptr + 20); 26 | points[1] = new b2ManifoldPoint(_ptr + 24) 27 | } 28 | 29 | /* public var localPlaneNormal:b2Vec2; 30 | public var localPoint:b2Vec2; 31 | public function get type():int { return mem._mrs8(_ptr + 56); } 32 | public function set type(v:int):void { mem._mw8(_ptr + 56, v); } 33 | public function get pointCount():int { return mem._mr32(_ptr + 60); } 34 | public function set pointCount(v:int):void { mem._mw32(_ptr + 60, v); } */ 35 | 36 | public var points:Array = []; 37 | 38 | public var localNormal:b2Vec2; // localNormal = new b2Vec2(_ptr + 48); 39 | public var localPoint:b2Vec2; // localPoint = new b2Vec2(_ptr + 56); 40 | public function get type():int { return mem._mrs8(_ptr + 64); } 41 | public function set type(v:int):void { mem._mw8(_ptr + 64, v); } 42 | public function get pointCount():int { return mem._mr32(_ptr + 68); } 43 | public function set pointCount(v:int):void { mem._mw32(_ptr + 68, v); } 44 | //public var points[0]:b2ManifoldPoint; // points[0] = new b2ManifoldPoint(_ptr + 0); 45 | //public var points[1]:b2ManifoldPoint; // points[1] = new b2ManifoldPoint(_ptr + 24); 46 | 47 | } 48 | } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2ManifoldPoint.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2ManifoldPoint extends b2Base { 13 | 14 | public function b2ManifoldPoint(p:int) { 15 | _ptr = p; 16 | localPoint = new b2Vec2(_ptr + 0); 17 | id = new b2ContactID(_ptr + 16); 18 | } 19 | 20 | public var localPoint:b2Vec2; // m_localPoint = new b2Vec2(_ptr + 0); 21 | public function get normalImpulse():Number { return mem._mrf(_ptr + 8); } 22 | public function set normalImpulse(v:Number):void { mem._mwf(_ptr + 8, v); } 23 | public function get tangentImpulse():Number { return mem._mrf(_ptr + 12); } 24 | public function set tangentImpulse(v:Number):void { mem._mwf(_ptr + 12, v); } 25 | public var id:b2ContactID; // m_id = new b2ContactID(_ptr + 16); 26 | public function get isNew():Boolean { return mem._mru8(_ptr + 20) == 1; } 27 | public function set isNew(v:Boolean):void { mem._mw8(_ptr + 20, v ? 1 : 0); } 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /Box2DAS/Collision/b2SimplexCache.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Collision { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; public class b2SimplexCache extends b2Base { public function b2SimplexCache() { _ptr = lib.b2SimplexCache_new(); } public override function destroy():void { lib.b2SimplexCache_delete(_ptr); super.destroy(); } public function get metric():Number { return mem._mrf(_ptr + 0); } public function set metric(v:Number):void { mem._mwf(_ptr + 0, v); } public function get count():int { return mem._mru16(_ptr + 4); } public function set count(v:int):void { mem._mw16(_ptr + 4, v); } public function get indexA():int { return mem._mru8(_ptr + 6); } public function set indexA(v:int):void { mem._mw8(_ptr + 6, v); } public function get indexB():int { return mem._mru8(_ptr + 9); } public function set indexB(v:int):void { mem._mw8(_ptr + 9, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Common/M22.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; public class M22 { public var c1:V2 = new V2(); public var c2:V2 = new V2(); public function toString():String { return '<<'+ c1.x +', '+ c1.y +'>, <'+ c2.x +', '+ c2.y +'>>'; } public function M22(_c1:V2 = null, _c2:V2 = null) { if(_c1 && _c2) columns(_c1, _c2); } public function columns(_c1:V2, _c2:V2):void { c1.xy(_c1.x, _c1.y); c2.xy(_c2.x, _c2.y); } public function values(x1:Number, y1:Number, x2:Number, y2:Number):void { c1.xy(x1, y1); c2.xy(x2, y2); } public static function values(x1:Number, y1:Number, x2:Number, y2:Number):M22 { var m:M22 = new M22(); m.values(x1, y1, x2, y2); return m; } public function clone():M22 { return new M22(c1, c2); } public function set angle(n:Number):void { c1.x = Math.cos(n); c1.y = Math.sin(n); c2.x = -c1.y; c2.y = c1.x; } public function get angle():Number { return Math.atan2(c1.y, c1.x); } public static function angle(n:Number):M22 { var m:M22 = new M22(); m.angle = n; return m; } public function zero():void { c1.zero(); c2.zero(); } public function multiplyV(v:V2):V2 { return new V2( c1.x * v.x + c2.x * v.y, c1.y * v.x + c2.y * v.y ); } public function multiplyVT(v:V2):V2 { return new V2(v.dot(c1), v.dot(c2)); } public function identity():M22 { c1.x = 1; c2.y = 1; return this; } public static function identity():M22 { return (new M22()).identity(); } } } -------------------------------------------------------------------------------- /Box2DAS/Common/M33.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class M33 { 13 | 14 | public var c1:V3 = new V3(); 15 | public var c2:V3 = new V3(); 16 | public var c3:V3 = new V3(); 17 | 18 | public function M33(_c1:V3 = null, _c2:V3 = null, _c3:V3 = null) { 19 | if(c1 && c2 && c3) columns(c1, c2, c3); 20 | } 21 | 22 | public function columns(_c1:V3, _c2:V3, _c3:V3):void { 23 | c1.xyz(_c1.x, _c1.y, _c1.z); 24 | c2.xyz(_c2.x, _c2.y, _c2.z); 25 | c3.xyz(_c3.x, _c3.y, _c3.z); 26 | } 27 | 28 | public function values(x1:Number, y1:Number, z1:Number, x2:Number, y2:Number, z2:Number, x3:Number, y3:Number, z3:Number):void { 29 | c1.xyz(x1, y1, z1); 30 | c2.xyz(x2, y2, z2); 31 | c3.xyz(x3, y3, z3); 32 | } 33 | 34 | public static function values(x1:Number, y1:Number, z1:Number, x2:Number, y2:Number, z2:Number, x3:Number, y3:Number, z3:Number):M33 { 35 | var m:M33 = new M33(); 36 | m.values(x1, y1, z1, x2, y2, z2, x3, y3, z3); 37 | return m; 38 | } 39 | 40 | public function clone():M33 { 41 | return new M33(c1, c2, c3); 42 | } 43 | 44 | public function zero():void { 45 | c1.zero(); 46 | c2.zero(); 47 | c3.zero(); 48 | } 49 | 50 | public function multiplyV(v:V3):V3 { 51 | return c1.multiplyN(v.x) + c2.multiplyN(v.y) + c3.multiplyN(v.z); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Box2DAS/Common/XF.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class XF { 13 | 14 | public var p:V2 = new V2(); 15 | public var r:M22 = new M22(); 16 | 17 | public function XF(_p:V2 = null, _r:M22 = null) { 18 | if(_p && _r) posRot(_p, _r); 19 | } 20 | 21 | public function posRot(_p:V2, _r:M22):void { 22 | p.xy(_p.x, _p.y); 23 | r.columns(_r.c1, _r.c2); 24 | } 25 | 26 | public function get angle():Number { 27 | return r.angle; 28 | } 29 | 30 | public function set angle(v:Number):void { 31 | r.angle = v; 32 | } 33 | 34 | public function multiply(v:V2):V2 { 35 | var v2:V2 = r.multiplyV(v); 36 | v2.add(p); 37 | return v2; 38 | } 39 | 40 | public function multiplyT(v:V2):V2 { 41 | return r.multiplyVT(V2.subtract(v, p)); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Box2DAS/Common/b2EventDispatcher.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.utils.*; import flash.events.*; public class b2EventDispatcher extends b2Base implements IEventDispatcher { public var dispatcher:IEventDispatcher; public function b2EventDispatcher(d:IEventDispatcher = null) { dispatcher = d || new EventDispatcher(this); } public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { dispatcher.addEventListener(type, listener, useCapture, priority); } public function dispatchEvent(evt:Event):Boolean { return dispatcher.dispatchEvent(evt); } public function hasEventListener(type:String):Boolean { return dispatcher.hasEventListener(type); } public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { dispatcher.removeEventListener(type, listener, useCapture); } public function willTrigger(type:String):Boolean { return dispatcher.willTrigger(type); } } } -------------------------------------------------------------------------------- /Box2DAS/Common/b2Mat22.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Mat22 extends b2Base { 13 | 14 | public function b2Mat22(p:int) { 15 | _ptr = p; 16 | col1 = new b2Vec2(_ptr + 0); 17 | col2 = new b2Vec2(_ptr + 8); 18 | } 19 | 20 | public function get m22():M22 { 21 | return new M22(col1.v2, col2.v2); 22 | } 23 | 24 | public function set m22(v:M22):void { 25 | col1.v2 = v.c1; 26 | col2.v2 = v.c2; 27 | } 28 | 29 | public var col1:b2Vec2; // col1 = new b2Vec2(_ptr + 0); 30 | public var col2:b2Vec2; // col2 = new b2Vec2(_ptr + 8); 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /Box2DAS/Common/b2Mat33.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Mat33 extends b2Base { 13 | 14 | public function b2Mat33(p:int) { 15 | _ptr = p; 16 | col1 = new b2Vec3(_ptr + 0); 17 | col2 = new b2Vec3(_ptr + 12); 18 | col3 = new b2Vec3(_ptr + 24) 19 | } 20 | 21 | public function get m33():M33 { 22 | return new M33(col1.v3, col2.v3, col3.v3); 23 | } 24 | 25 | public function set m33(v:M33):void { 26 | col1.v3 = v.c1; 27 | col2.v3 = v.c2; 28 | col3.v3 = v.c3; 29 | } 30 | 31 | public var col1:b2Vec3; // col1 = new b2Vec3(_ptr + 0); 32 | public var col2:b2Vec3; // col2 = new b2Vec3(_ptr + 12); 33 | public var col3:b2Vec3; // col3 = new b2Vec3(_ptr + 24); 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Box2DAS/Common/b2Sweep.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Sweep extends b2Base { 13 | 14 | public function b2Sweep(p:int) { 15 | _ptr = p; 16 | localCenter = new b2Vec2(_ptr + 0); 17 | c0 = new b2Vec2(_ptr + 8); 18 | c = new b2Vec2(_ptr + 16); 19 | } 20 | 21 | public var localCenter:b2Vec2; // localCenter = new b2Vec2(_ptr + 0); 22 | public var c0:b2Vec2; // c0 = new b2Vec2(_ptr + 8); 23 | public var c:b2Vec2; // c = new b2Vec2(_ptr + 16); 24 | public function get a0():Number { return mem._mrf(_ptr + 24); } 25 | public function set a0(v:Number):void { mem._mwf(_ptr + 24, v); } 26 | public function get a():Number { return mem._mrf(_ptr + 28); } 27 | public function set a(v:Number):void { mem._mwf(_ptr + 28, v); } 28 | //public function get t0():Number { return mem._mrf(_ptr + 32); } 29 | //public function set t0(v:Number):void { mem._mwf(_ptr + 32, v); } 30 | public function get alpha0():Number { return mem._mrf(_ptr + 32); } 31 | public function set alpha0(v:Number):void { mem._mwf(_ptr + 32, v); } 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /Box2DAS/Common/b2Transform.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Transform extends b2Base { 13 | 14 | public function b2Transform(p:int) { 15 | _ptr = p; 16 | position = new b2Vec2(_ptr + 0); 17 | R = new b2Mat22(_ptr + 8); 18 | } 19 | 20 | public function get xf():XF { 21 | return new XF(position.v2, R.m22); 22 | } 23 | 24 | public function set xf(v:XF):void { 25 | position.v2 = v.p; 26 | R.m22 = v.r; 27 | } 28 | 29 | public var position:b2Vec2; // position = new b2Vec2(_ptr + 0); 30 | public var R:b2Mat22; // R = new b2Mat22(_ptr + 8); 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /Box2DAS/Common/b2Vec2.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Vec2 extends b2Base { 13 | 14 | public function b2Vec2(p:int) { 15 | _ptr = p; 16 | } 17 | 18 | public function get v2():V2 { 19 | return new V2(x, y); 20 | } 21 | 22 | public function set v2(v:V2):void { 23 | x = v.x; 24 | y = v.y; 25 | } 26 | 27 | public function get x():Number { return mem._mrf(_ptr + 0); } 28 | public function set x(v:Number):void { mem._mwf(_ptr + 0, v); } 29 | public function get y():Number { return mem._mrf(_ptr + 4); } 30 | public function set y(v:Number):void { mem._mwf(_ptr + 4, v); } 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /Box2DAS/Common/b2Vec3.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Common { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Vec3 extends b2Base { 13 | 14 | public function b2Vec3(p:int) { 15 | _ptr = p; 16 | } 17 | 18 | public function get v3():V3 { 19 | return new V3(x, y, z); 20 | } 21 | 22 | public function set v3(v:V3):void { 23 | x = v.x; 24 | y = v.y; 25 | z = v.z; 26 | } 27 | 28 | public function get x():Number { return mem._mrf(_ptr + 0); } 29 | public function set x(v:Number):void { mem._mwf(_ptr + 0, v); } 30 | public function get y():Number { return mem._mrf(_ptr + 4); } 31 | public function set y(v:Number):void { mem._mwf(_ptr + 4, v); } 32 | public function get z():Number { return mem._mrf(_ptr + 8); } 33 | public function set z(v:Number):void { mem._mwf(_ptr + 8, v); } 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Box2DAS/Controllers/b2Controller.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Controllers { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.utils.*; public class b2Controller { public var effect:b2Effect; public var storage:Dictionary = new Dictionary(); public var world:b2World; public var allBodies:Boolean = false; public var priority:int = 0; public function b2Controller(w:b2World = null, e:b2Effect = null, all:Boolean = false) { effect = e; allBodies = all; if(w) { world = w; w.AddController(this); } } public function destroy():void { world.RemoveController(this); world = null; } public function toString():String { return GetBodies().toString(); } public function GetBodies():Array { var b:Array = []; for(var i:* in storage) { b.push(i); } return b; } public function AddBody(body:b2Body):void { storage[body] ||= 0; storage[body]++; body.m_controllers[this] = true; } public function RemoveBody(body:b2Body):void { if(storage[body]) { storage[body]--; if(storage[body] == 0) { delete storage[body]; delete body.m_controllers[this]; } } } public function Step(e:StepEvent = null):void { if(effect) { if(allBodies) { for(var b:b2Body = world.m_bodyList; b; b = b.m_next) { effect.Apply(b); } } else { for(var i:* in storage) { effect.Apply(i as b2Body); } } } } } } -------------------------------------------------------------------------------- /Box2DAS/Controllers/b2Effect.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Controllers { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.utils.*; public class b2Effect { public virtual function Apply(b:b2Body):void { } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Contacts/b2ContactEdge.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Contacts { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; /// A contact edge is used to connect bodies and contacts together /// in a contact graph where each body is a node and each contact /// is an edge. A contact edge belongs to a doubly linked list /// maintained in each attached body. Each contact has two contact /// nodes, one for each attached body. public class b2ContactEdge extends b2Base { public function b2ContactEdge(p:int) { _ptr = p; } /// provides quick access to the other body attached. public function get other():b2Body { /// Address of b2Body + userData offset -> deref to AS3 = AS3 b2Body. return deref(mem._mr32(mem._mr32(_ptr + 0) + 152)) as b2Body; } /// the contact public function get contact():b2Contact { /// Read value at pointer -> send to b2Contact constructor. return new b2Contact(mem._mr32(_ptr + 4)); } /// the previous contact edge in the body's contact list public function get prev():b2ContactEdge { var p:int = mem._mr32(_ptr + 8); return p ? new b2ContactEdge(p) : null; } /// the next contact edge in the body's contact list public function get next():b2ContactEdge { var p:int = mem._mr32(_ptr + 12); return p ? new b2ContactEdge(p) : null; } } }; -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Contacts/b2ContactID.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Contacts { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2ContactID extends b2Base { 13 | 14 | public static var e_vertex:int = 0; 15 | public static var e_face:int = 1; 16 | 17 | public function b2ContactID(p:int) { 18 | _ptr = p; 19 | } 20 | 21 | /* public function get referenceEdge():int { return mem._mru8(_ptr + 0); } 22 | public function set referenceEdge(v:int):void { mem._mw8(_ptr + 0, v); } 23 | public function get incidentEdge():int { return mem._mru8(_ptr + 1); } 24 | public function set incidentEdge(v:int):void { mem._mw8(_ptr + 1, v); } 25 | public function get incidentVertex():int { return mem._mru8(_ptr + 2); } 26 | public function set incidentVertex(v:int):void { mem._mw8(_ptr + 2, v); } 27 | public function get flip():int { return mem._mru8(_ptr + 3); } 28 | public function set flip(v:int):void { mem._mw8(_ptr + 3, v); } 29 | public function get key():int { return mem._mr32(_ptr + 0); } 30 | public function set key(v:int):void { mem._mw32(_ptr + 0, v); } */ 31 | 32 | public function get key():int { return mem._mr32(_ptr + 0); } 33 | public function set key(v:int):void { mem._mw32(_ptr + 0, v); } 34 | public function get indexA():int { return mem._mru8(_ptr + 0); } 35 | public function set indexA(v:int):void { mem._mw8(_ptr + 0, v); } 36 | public function get indexB():int { return mem._mru8(_ptr + 1); } 37 | public function set indexB(v:int):void { mem._mw8(_ptr + 1, v); } 38 | public function get typeA():int { return mem._mru8(_ptr + 2); } 39 | public function set typeA(v:int):void { mem._mw8(_ptr + 2, v); } 40 | public function get typeB():int { return mem._mru8(_ptr + 3); } 41 | public function set typeB(v:int):void { mem._mw8(_ptr + 3, v); } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/GoodbyeFixtureEvent.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | import flash.events.*; 12 | 13 | public class GoodbyeFixtureEvent extends Event { 14 | 15 | public static var GOODBYE_FIXTURE:String = 'onGoodbyeFixture'; 16 | 17 | public var fixture:b2Fixture; 18 | 19 | public function GoodbyeFixtureEvent(f:b2Fixture) { 20 | fixture = f; 21 | super(GOODBYE_FIXTURE); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/GoodbyeJointEvent.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | import flash.events.*; 12 | 13 | public class GoodbyeJointEvent extends Event { 14 | 15 | public static var GOODBYE_JOINT:String = 'onGoodbyeJoint'; 16 | 17 | public var joint:b2Joint; 18 | 19 | public function GoodbyeJointEvent(j:b2Joint) { 20 | joint = j; 21 | super(GOODBYE_JOINT); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2DistanceJointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Distance joint definition. This requires defining an /// anchor point on both bodies and the non-zero length of the /// distance joint. The definition uses local anchor points /// so that the initial configuration can violate the constraint /// slightly. This helps when saving and loading a game. /// @warning Do not use a zero or short length. public class b2DistanceJointDef extends b2JointDef { public override function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2DistanceJoint(w, this, ed); } public function b2DistanceJointDef() { _ptr = lib.b2DistanceJointDef_new(); localAnchorA = new b2Vec2(_ptr + 20); localAnchorB = new b2Vec2(_ptr + 28); } public override function destroy():void { lib.b2DistanceJointDef_delete(_ptr); super.destroy(); } /// Initialize the bodies, anchors, and length using the world /// anchors. ///void Initialize(b2Body* bodyA, b2Body* bodyB, /// const b2Vec2& anchorA, const b2Vec2& anchorB); public function Initialize(b1:b2Body, b2:b2Body, anchorA:V2, anchorB:V2):void { bodyA = b1; bodyB = b2; localAnchorA.v2 = bodyA.GetLocalPoint(anchorA); localAnchorB.v2 = bodyB.GetLocalPoint(anchorB); length = anchorB.distance(anchorA); } /// The local anchor point relative to bodyA's origin. public var localAnchorA:b2Vec2; /// The local anchor point relative to bodyB's origin. public var localAnchorB:b2Vec2; /// The equilibrium length between the anchor points. public function get length():Number { return mem._mrf(_ptr + 36); } public function set length(v:Number):void { mem._mwf(_ptr + 36, v); } /// The response speed. public function get frequencyHz():Number { return mem._mrf(_ptr + 40); } public function set frequencyHz(v:Number):void { mem._mwf(_ptr + 40, v); } /// The damping ratio. 0 = no damping, 1 = critical damping. public function get dampingRatio():Number { return mem._mrf(_ptr + 44); } public function set dampingRatio(v:Number):void { mem._mwf(_ptr + 44, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2FrictionJointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Friction joint definition. public class b2FrictionJointDef extends b2JointDef { public override function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2FrictionJoint(w, this, ed); } public function b2FrictionJointDef() { _ptr = lib.b2FrictionJointDef_new(); localAnchorA = new b2Vec2(_ptr + 20); localAnchorB = new b2Vec2(_ptr + 28); } public override function destroy():void { lib.b2FrictionJointDef_delete(_ptr); super.destroy(); } /// Initialize the bodies, anchors, axis, and reference angle using the world /// anchor and world axis. /// void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor); public function Initialize(bA:b2Body, bB:b2Body, anchor:V2):void { bodyA = bA; bodyB = bB; localAnchorA.v2 = bodyA.GetLocalPoint(anchor); localAnchorB.v2 = bodyB.GetLocalPoint(anchor); } /// The local anchor point relative to bodyA's origin. public var localAnchorA:b2Vec2; /// The local anchor point relative to bodyB's origin. public var localAnchorB:b2Vec2; /// The maximum friction force in N. public function get maxForce():Number { return mem._mrf(_ptr + 36); } public function set maxForce(v:Number):void { mem._mwf(_ptr + 36, v); } /// The maximum friction torque in N-m. public function get maxTorque():Number { return mem._mrf(_ptr + 40); } public function set maxTorque(v:Number):void { mem._mwf(_ptr + 40, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2GearJointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Gear joint definition. This definition requires two existing /// revolute or prismatic joints (any combination will work). /// The provided joints must attach a dynamic body to a static body. public class b2GearJointDef extends b2JointDef { public override function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2GearJoint(w, this, ed); } public function b2GearJointDef() { _ptr = lib.b2GearJointDef_new(); } public override function destroy():void { lib.b2GearJointDef_delete(_ptr); super.destroy(); } public function Initialize(j1:b2Joint, j2:b2Joint, r:Number):void { bodyA = j1.GetBodyB(); bodyB = j2.GetBodyB(); joint1 = j1; joint2 = j2; ratio = r; } /// The first revolute/prismatic joint attached to the gear joint. public var _joint1:b2Joint; public function get joint1():b2Joint { return _joint1; } public function set joint1(v:b2Joint):void { mem._mw32(_ptr + 20, v._ptr); _joint1 = v; } /// The second revolute/prismatic joint attached to the gear joint. public var _joint2:b2Joint; public function get joint2():b2Joint { return _joint2; } public function set joint2(v:b2Joint):void { mem._mw32(_ptr + 24, v._ptr); _joint2 = v; } /// The gear ratio. /// @see b2GearJoint for explanation. public function get ratio():Number { return mem._mrf(_ptr + 28); } public function set ratio(v:Number):void { mem._mwf(_ptr + 28, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2Jacobian.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | public class b2Jacobian extends b2Base { 13 | 14 | public function b2Jacobian(p:int) { 15 | _ptr = p; 16 | linear1 = new b2Vec2(_ptr + 0); 17 | linear2 = new b2Vec2(_ptr + 12); 18 | } 19 | 20 | public var linear1:b2Vec2; 21 | public function get angular1():Number { return mem._mrf(_ptr + 8); } 22 | public function set angular1(v:Number):void { mem._mwf(_ptr + 8, v); } 23 | public var linear2:b2Vec2; 24 | public function get angular2():Number { return mem._mrf(_ptr + 20); } 25 | public function set angular2(v:Number):void { mem._mwf(_ptr + 20, v); } 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2JointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Joint definitions are used to construct joints. public class b2JointDef extends b2Base { public function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2Joint(w, this, ed); } /// The joint type is set automatically for concrete joint types. public function get type():int { return mem._mrs16(_ptr + 0); } public function set type(v:int):void { mem._mw16(_ptr + 0, v); } /// Use this to attach application specific data to your joints. public var userData:*; /// The first attached body. public var _bodyA:b2Body; public function get bodyA():b2Body { return _bodyA; } public function set bodyA(v:b2Body):void { mem._mw32(_ptr + 8, v._ptr); _bodyA = v; } /// The second attached body. public var _bodyB:b2Body; public function get bodyB():b2Body { return _bodyB; } public function set bodyB(v:b2Body):void { mem._mw32(_ptr + 12, v._ptr); _bodyB = v; } /// Set this flag to true if the attached bodies should collide. public function get collideConnected():Boolean { return mem._mru8(_ptr + 16) == 1; } public function set collideConnected(v:Boolean):void { mem._mw8(_ptr + 16, v ? 1 : 0); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2JointEdge.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; /// A joint edge is used to connect bodies and joints together /// in a joint graph where each body is a node and each joint /// is an edge. A joint edge belongs to a doubly linked list /// maintained in each attached body. Each joint has two joint /// nodes, one for each attached body. public class b2JointEdge extends b2Base { public function b2JointEdge(p:int) { _ptr = p; } /// provides quick access to the other body attached. public function get other():b2Body { /// Address of b2Body + userData offset -> deref to AS3 = AS3 b2Body. return deref(mem._mr32(mem._mr32(_ptr + 0) + 152)) as b2Body; } /// the joint public function get joint():b2Joint { /// Address of b2Joint + userData offset -> deref to AS3 = AS3 b2Body. return deref(mem._mr32(mem._mr32(_ptr + 4) + 60)) as b2Joint; } /// the previous joint edge in the body's joint list public function get prev():b2JointEdge { var p:int = mem._mr32(_ptr + 8); return p ? new b2JointEdge(p) : null; } /// the next joint edge in the body's joint list public function get next():b2JointEdge { var p:int = mem._mr32(_ptr + 12); return p ? new b2JointEdge(p) : null; } } }; -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2MouseJointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Mouse joint definition. This requires a world target point, /// tuning parameters, and the time step. public class b2MouseJointDef extends b2JointDef { public override function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2MouseJoint(w, this, ed); } public function b2MouseJointDef() { _ptr = lib.b2MouseJointDef_new(); target = new b2Vec2(_ptr + 20); } public override function destroy():void { lib.b2MouseJointDef_delete(_ptr); super.destroy(); } public function Initialize(b:b2Body, t:V2):void { bodyA = b.m_world.m_groundBody; bodyB = b; target.v2 = t; } /// The initial world target point. This is assumed /// to coincide with the body anchor initially. public var target:b2Vec2; /// The maximum constraint force that can be exerted /// to move the candidate body. Usually you will express /// as some multiple of the weight (multiplier * mass * gravity). public function get maxForce():Number { return mem._mrf(_ptr + 28); } public function set maxForce(v:Number):void { mem._mwf(_ptr + 28, v); } /// The response speed. public function get frequencyHz():Number { return mem._mrf(_ptr + 32); } public function set frequencyHz(v:Number):void { mem._mwf(_ptr + 32, v); } /// The damping ratio. 0 = no damping, 1 = critical damping. public function get dampingRatio():Number { return mem._mrf(_ptr + 36); } public function set dampingRatio(v:Number):void { mem._mwf(_ptr + 36, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2RopeJointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Rope joint definition. This requires two body anchor points and /// a maximum lengths. /// Note: by default the connected objects will not collide. /// see collideConnected in b2JointDef. public class b2RopeJointDef extends b2JointDef { public override function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2RopeJoint(w, this, ed); } public function b2RopeJointDef() { _ptr = lib.b2RopeJointDef_new(); localAnchorA = new b2Vec2(_ptr + 20); localAnchorB = new b2Vec2(_ptr + 28); } public override function destroy():void { lib.b2RopeJointDef_delete(_ptr); super.destroy(); } public function Initialize(b1:b2Body, b2:b2Body, anchorA:V2, anchorB:V2):void { bodyA = b1; bodyB = b2; localAnchorA.v2 = bodyA.GetLocalPoint(anchorA); localAnchorB.v2 = bodyB.GetLocalPoint(anchorB); maxLength = anchorB.distance(anchorA); } /// The local anchor point relative to bodyA's origin. public var localAnchorA:b2Vec2; /// The local anchor point relative to bodyB's origin. public var localAnchorB:b2Vec2; /// The maximum length of the rope. /// Warning: this must be larger than b2_linearSlop or /// the joint will have no effect. public function get maxLength():Number { return mem._mrf(_ptr + 36); } public function set maxLength(v:Number):void { mem._mwf(_ptr + 36, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2WeldJoint.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// A weld joint essentially glues two bodies together. A weld joint may /// distort somewhat because the island constraint solver is approximate. public class b2WeldJoint extends b2Joint { public function b2WeldJoint(w:b2World, d:b2WeldJointDef = null, ed:IEventDispatcher = null) { d ||= b2Def.weldJoint; super(w, d, ed); m_localAnchorA = new b2Vec2(_ptr + 96); m_localAnchorB = new b2Vec2(_ptr + 104); m_impulse = new b2Vec3(_ptr + 116); m_mass = new b2Mat33(_ptr + 128); } public override function GetAnchorA():V2 { return m_bodyA.GetWorldPoint(m_localAnchorA.v2); } public override function GetAnchorB():V2 { return m_bodyB.GetWorldPoint(m_localAnchorB.v2); } public override function GetReactionForce(inv_dt:Number):V2 { return new V2(m_impulse.x, m_impulse.y).multiplyN(inv_dt); } public override function GetReactionTorque(inv_dt:Number):Number { return inv_dt * m_impulse.z; } public var m_localAnchorA:b2Vec2; public var m_localAnchorB:b2Vec2; public function get m_referenceAngle():Number { return mem._mrf(_ptr + 112); } public function set m_referenceAngle(v:Number):void { mem._mwf(_ptr + 112, v); } public var m_impulse:b2Vec3; public var m_mass:b2Mat33; } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/Joints/b2WeldJointDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics.Joints { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; /// Weld joint definition. You need to specify local anchor points /// where they are attached and the relative body angle. The position /// of the anchor points is important for computing the reaction torque. public class b2WeldJointDef extends b2JointDef { public override function create(w:b2World, ed:IEventDispatcher = null):b2Joint { return new b2WeldJoint(w, this, ed); } public function b2WeldJointDef() { _ptr = lib.b2WeldJointDef_new(); localAnchorA = new b2Vec2(_ptr + 20); localAnchorB = new b2Vec2(_ptr + 28); } public override function destroy():void { lib.b2WeldJointDef_delete(_ptr); super.destroy(); } /// Initialize the bodies, anchors, and reference angle using a world /// anchor point. /// void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor); public function Initialize(bA:b2Body, bB:b2Body, anchor:V2):void { bodyA = bA; bodyB = bB; localAnchorA.v2 = bodyA.GetLocalPoint(anchor); localAnchorB.v2 = bodyB.GetLocalPoint(anchor); referenceAngle = bodyB.GetAngle() - bodyA.GetAngle(); } /// The local anchor point relative to bodyA's origin. public var localAnchorA:b2Vec2; /// The local anchor point relative to bodyB's origin. public var localAnchorB:b2Vec2; /// The bodyB angle minus bodyA angle in the reference state (radians). public function get referenceAngle():Number { return mem._mrf(_ptr + 36); } public function set referenceAngle(v:Number):void { mem._mwf(_ptr + 36, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/StepEvent.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import flash.events.*; public class StepEvent extends Event { public static var STEP:String = 'onStep'; public var timeStep:Number; public var velocityIterations:Number; public var positionIterations:Number; public var stepTime:Number; public function StepEvent(ts:Number, vi:Number, pi:Number, st:Number) { timeStep = ts; velocityIterations = vi; positionIterations = pi; stepTime = st; super(STEP); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/b2ContactImpulse.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | /// Contact impulses for reporting. Impulses are used instead of forces because 13 | /// sub-step forces may approach infinity for rigid body collisions. These 14 | /// match up one-to-one with the contact points in b2Manifold. 15 | public class b2ContactImpulse extends b2Base { 16 | 17 | public function b2ContactImpulse(p:int) { 18 | _ptr = p; 19 | } 20 | 21 | public function get normalImpulse1():Number { return mem._mrf(_ptr + 0); } 22 | public function set normalImpulse1(v:Number):void { mem._mwf(_ptr + 0, v); } 23 | public function get normalImpulse2():Number { return mem._mrf(_ptr + 4); } 24 | public function set normalImpulse2(v:Number):void { mem._mwf(_ptr + 4, v); } 25 | public function get tangentImpulse1():Number { return mem._mrf(_ptr + 8); } 26 | public function set tangentImpulse1(v:Number):void { mem._mwf(_ptr + 8, v); } 27 | public function get tangentImpulse2():Number { return mem._mrf(_ptr + 12); } 28 | public function set tangentImpulse2(v:Number):void { mem._mwf(_ptr + 12, v); } 29 | } 30 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/b2ContactManager.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | 12 | // Delegate of b2World. 13 | public class b2ContactManager extends b2Base { 14 | 15 | public function b2ContactManager(p:int) { 16 | _ptr = p; 17 | m_broadPhase = new b2BroadPhase(_ptr + 0); 18 | } 19 | 20 | public function get m_contactList():b2Contact { 21 | return new b2Contact(mem._mr32(_ptr + 60)); 22 | } 23 | 24 | public function get m_contactCount():int { return mem._mr32(_ptr + 64); } 25 | public function set m_contactCount(v:int):void { mem._mw32(_ptr + 64, v); } 26 | public var m_broadPhase:b2BroadPhase; 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/b2DestructionListener.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { 2 | 3 | import Box2DAS.*; 4 | import Box2DAS.Collision.*; 5 | import Box2DAS.Collision.Shapes.*; 6 | import Box2DAS.Common.*; 7 | import Box2DAS.Dynamics.*; 8 | import Box2DAS.Dynamics.Contacts.*; 9 | import Box2DAS.Dynamics.Joints.*; 10 | import cmodule.Box2D.*; 11 | import flash.events.*; 12 | import flash.utils.*; 13 | 14 | /// Joints and fixtures are destroyed when their associated 15 | /// body is destroyed. Implement this listener so that you 16 | /// may nullify references to these joints and shapes. 17 | /// 18 | /// Default AS3 Implementation: If the joint/fixture userData is an event dispatcher (like 19 | /// a display object) then an AS3 native event will be dispatched off of that object. 20 | /// 21 | public class b2DestructionListener { 22 | 23 | /// Called when any joint is about to be destroyed due 24 | /// to the destruction of one of its attached bodies. 25 | public function SayGoodbyeJoint(j:b2Joint):void { 26 | j.dispatchEvent(new GoodbyeJointEvent(j)); 27 | } 28 | 29 | /// Called when any fixture is about to be destroyed due 30 | /// to the destruction of its parent body. 31 | public function SayGoodbyeFixture(f:b2Fixture):void { 32 | f.dispatchEvent(new GoodbyeFixtureEvent(f)); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/b2Filter.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; public class b2Filter extends b2Base { public function b2Filter(p:int) { _ptr = p; } public function set filter(v:Object):void { categoryBits = v.categoryBits; maskBits = v.maskBits; groupIndex = v.groupIndex; } public function get filter():Object { return {categoryBits: categoryBits, maskBits: maskBits, groupIndex: groupIndex} } public function get categoryBits():int { return mem._mru16(_ptr + 0); } public function set categoryBits(v:int):void { mem._mw16(_ptr + 0, v); } public function get maskBits():int { return mem._mru16(_ptr + 2); } public function set maskBits(v:int):void { mem._mw16(_ptr + 2, v); } public function get groupIndex():int { return mem._mrs16(_ptr + 4); } public function set groupIndex(v:int):void { mem._mw16(_ptr + 4, v); } } } -------------------------------------------------------------------------------- /Box2DAS/Dynamics/b2FixtureDef.as: -------------------------------------------------------------------------------- 1 | package Box2DAS.Dynamics { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; /// A fixture definition is used to create a fixture. This class defines an /// abstract fixture definition. You can reuse fixture definitions safely. public class b2FixtureDef extends b2Base { /// The constructor sets the default fixture definition values. public function b2FixtureDef() { _ptr = lib.b2FixtureDef_new(this); filter = new b2Filter(_ptr + 26); } public override function destroy():void { lib.b2FixtureDef_delete(_ptr); super.destroy(); } public function create(b:b2Body):b2Fixture { return new b2Fixture(b, this); } /// The shape, this must be set. The shape will be cloned, so you /// can create the shape on the stack. public var _shape:b2Shape; public function get shape():b2Shape { return _shape; } public function set shape(v:b2Shape):void { mem._mw32(_ptr + 4, v ? v._ptr : 0); _shape = v; } /// Use this to store application specific fixture data. public var userData:*; /// The friction coefficient, usually in the range [0,1]. public function get friction():Number { return mem._mrf(_ptr + 12); } public function set friction(v:Number):void { mem._mwf(_ptr + 12, v); } /// The restitution (elasticity) usually in the range [0,1]. public function get restitution():Number { return mem._mrf(_ptr + 16); } public function set restitution(v:Number):void { mem._mwf(_ptr + 16, v); } /// The density, usually in kg/m^2. public function get density():Number { return mem._mrf(_ptr + 20); } public function set density(v:Number):void { mem._mwf(_ptr + 20, v); } /// A sensor shape collects contact information but never generates a collision /// response. public function get isSensor():Boolean { return mem._mru8(_ptr + 24) == 1; } public function set isSensor(v:Boolean):void { mem._mw8(_ptr + 24, v ? 1 : 0); } /// Contact filtering data. public var filter:b2Filter; } } -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Please see the WIKI for documentation: 2 | 3 | http://wiki.github.com/jesses/wck/ -------------------------------------------------------------------------------- /TestBed/Bullet.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; import flash.utils.*; public class Bullet extends Test { public function Bullet() { super(); Main.txt.text = "Bullet/Contact Callbacks"; b2Def.body.type = b2Body.b2_dynamicBody; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 100 / scale; b2Def.body.allowSleep = false; //b2Def.body.bullet = true; b2Def.body.allowSleep = false; b2Def.polygon.SetAsBox(50 / scale, 50 / scale); b2Def.fixture.shape = b2Def.polygon; b2Def.fixture.density = 1; var b:b2Body = b2Def.body.create(this); var f:b2Fixture = b2Def.fixture.create(b); f.m_reportBeginContact = true; f.m_reportEndContact = true; f.m_reportPreSolve = true; f.m_reportPostSolve = true; f.addEventListener(ContactEvent.BEGIN_CONTACT, reportContact, false, 0, true); f.addEventListener(ContactEvent.END_CONTACT, reportContact, false, 0, true); f.addEventListener(ContactEvent.PRE_SOLVE, reportContact, false, 0, true); f.addEventListener(ContactEvent.POST_SOLVE, reportContact, false, 0, true); } public override function EnterFrame():void { trace('-------'); super.EnterFrame(); } function reportContact(e:ContactEvent):void { trace(e.type); } } } -------------------------------------------------------------------------------- /TestBed/Buoyancy.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import Box2DAS.Controllers.*; import misc.*; public class Buoyancy extends Test { public function Buoyancy() { super(); Main.txt.text = "Buoyancy"; var be:b2BuoyancyEffect = new b2BuoyancyEffect(); be.density = 1.5; be.offset = -300 / scale; var c:b2Controller = new b2Controller(this, be, true); /*graphics.clear(); graphics.lineStyle(1, 0x0000ff); graphics.moveTo(-2000, 300); graphics.lineTo(2000, 300);*/ b2Def.body.type = b2Body.b2_dynamicBody; b2Def.fixture.shape = b2Def.polygon; b2Def.fixture.density = 1; var body:b2Body; var fix:b2Fixture; for(var i:uint = 0; i < 50; ++i) { b2Def.polygon.SetAsBox((Math.random() * 40 + 5) / scale, (Math.random() * 5 + 5) / scale); b2Def.body.position.x = Math.random() * 720 / scale; b2Def.body.position.y = Math.random() * 480 / scale; b2Def.body.angularVelocity = Math.random() * 2 - 1; body = CreateBody(b2Def.body); fix = body.CreateFixture(b2Def.fixture); //c.AddBody(body); } b2Def.fixture.shape = b2Def.circle; for(i = 0; i < 50; ++i) { b2Def.circle.m_radius = (Math.random() * 10 + 5) / scale; b2Def.body.position.x = Math.random() * 720 / scale; b2Def.body.position.y = Math.random() * 480 / scale; b2Def.body.angularVelocity = Math.random() * 2 - 1; body = CreateBody(b2Def.body); fix = body.CreateFixture(b2Def.fixture); //c.AddBody(body); } } } } -------------------------------------------------------------------------------- /TestBed/Contact.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; import flash.utils.*; public class Contact extends Test { public var f:b2Fixture; public var b:b2Body; public function Contact() { super(); Main.txt.text = "Contact"; b2Def.body.type = b2Body.b2_dynamicBody; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 100 / scale; b2Def.body.allowSleep = false; b2Def.polygon.SetAsBox(50 / scale, 50 / scale); b2Def.fixture.shape = b2Def.polygon; b2Def.fixture.density = 1; b = b2Def.body.create(this); f = b2Def.fixture.create(b); f.m_userData = 'Fixture 1'; f.m_reportBeginContact = true; f.m_reportEndContact = true; f.addEventListener(ContactEvent.BEGIN_CONTACT, reportContact); f.addEventListener(ContactEvent.END_CONTACT, reportContact); b2Def.body.type = b2Body.b2_staticBody; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 300 / scale; b = b2Def.body.create(this); f = b2Def.fixture.create(b); f.m_userData = 'Fixture 2'; f.m_reportBeginContact = true; f.m_reportEndContact = true; f.addEventListener(ContactEvent.BEGIN_CONTACT, reportContact); f.addEventListener(ContactEvent.END_CONTACT, reportContact); setTimeout(removeBody, 2000); } public function removeBody():void { b.destroy(); } public function reportContact(e:ContactEvent):void { trace('Contact Event', e.type, (e.target as b2Fixture).m_userData); } } } -------------------------------------------------------------------------------- /TestBed/Decompose.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; public class Decompose extends Test { public function Decompose() { super(); Main.txt.text = "Decomposition:"; b2Def.body.type = b2Body.b2_dynamicBody; var f:b2Fixture; var hx:Number = 20 / scale; var hy:Number = 20 / scale; for(var x:Number = 100; x <= 500; x += 50) { for(var y:Number = 100; y <= 200; y += 50) { b2Def.body.position.x = x / scale; b2Def.body.position.y = y / scale; var b:b2Body = b2Def.body.create(this); var s:Vector. = b2PolygonShape.Decompose(Vector.([ -hx, -hy, 0, -hy + (Math.random() * 20 - 10) / scale, hx, -hy, hx + (Math.random() * 20 - 10) / scale, 0, hx, hy, 0, hy + (Math.random() * 20 - 10) / scale, -hx, hy, -hx + (Math.random() * 20 - 10) / scale, 0 ])); for(var i:int = 0; i < s.length; ++i) { with(b2Def.fixture) { shape = s[i]; density = 1.0; f = create(b); } s[i].destroy(); } } } } } } -------------------------------------------------------------------------------- /TestBed/Edges.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; import flash.utils.*; public class Edges extends Test { public function Edges() { super(); Main.txt.text = "Edges"; b2Def.body.type = b2Body.b2_dynamicBody; b2Def.body.position.x = 100 / scale; b2Def.body.position.y = 100 / scale; b2Def.body.allowSleep = false; b2Def.polygon.SetAsBox(20 / scale, 20 / scale); b2Def.fixture.shape = b2Def.polygon; b2Def.fixture.density = 1; var b:b2Body = b2Def.body.create(this); b2Def.fixture.create(b); b2Def.body.type = b2Body.b2_staticBody; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 400 / scale; b2Def.fixture.filter.groupIndex = -1; b2Def.fixture.shape = b2Def.edge; b2Def.edge.m_vertex0.v2 = new V2(-100 / scale, 50 / scale); b2Def.edge.m_vertex1.v2 = new V2(-100 / scale, 0 / scale); b2Def.edge.m_vertex2.v2 = new V2(100 / scale, 0 / scale); b2Def.edge.m_vertex3.v2 = new V2(100 / scale, 50 / scale); b2Def.edge.m_hasVertex0 = true; b2Def.edge.m_hasVertex3 = true; b = b2Def.body.create(this); b2Def.fixture.create(b); b2Def.fixture.shape = b2Def.loop; var s:Number = 100 / scale; var o:Number = 10 / scale; b2Def.loop.m_vertices = Vector.([ new V2(-s, -s), new V2(-s, s), new V2(s + o, s + o), new V2(s, -s) ]); b2Def.body.position.x = 500 / scale; b2Def.body.position.y = 200 / scale; b = b2Def.body.create(this); b2Def.fixture.create(b); } } } -------------------------------------------------------------------------------- /TestBed/Filter.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; import flash.utils.*; public class Filter extends Test { public var f:b2Fixture; public function Filter() { super(); Main.txt.text = "Filter"; b2Def.body.type = b2Body.b2_dynamicBody; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 100 / scale; b2Def.body.allowSleep = false; b2Def.polygon.SetAsBox(50 / scale, 50 / scale); b2Def.fixture.shape = b2Def.polygon; b2Def.fixture.density = 1; var b:b2Body = b2Def.body.create(this); f = b2Def.fixture.create(b); b2Def.body.type = b2Body.b2_staticBody; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 300 / scale; b2Def.fixture.filter.groupIndex = -1; b = b2Def.body.create(this); b2Def.fixture.create(b); setTimeout(setFilter, 2000); } public function setFilter():void { var fltr:Object = f.GetFilterData(); fltr.groupIndex = -1; f.SetFilterData(fltr); } } } -------------------------------------------------------------------------------- /TestBed/Impulse.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; public class Impulse extends Test { public function Impulse() { super(); Main.txt.text = "Contact Impulse:\n"; b2Def.circle.m_radius = 13 / scale; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 300 / scale; b2Def.body.type = b2Body.b2_dynamicBody; var b:b2Body = b2Def.body.create(this); var f:b2Fixture; with(b2Def.fixture) { shape = b2Def.circle; density = 1.0; f = create(b); f.addEventListener(ContactEvent.PRE_SOLVE, handlePreSolve, false, 0, true); f.addEventListener(ContactEvent.POST_SOLVE, handlePostSolve, false, 0, true); } f.m_reportPostSolve = true; } public function handlePreSolve(e:ContactEvent):void { trace('pre: ', e.contact.m_manifold.points[0].tangentImpulse, e.contact.m_manifold.points[0].normalImpulse); } public function handlePostSolve(e:ContactEvent):void { Main.txt.text = "Contact Impulse:\n" + e.impulses.tangentImpulse1 + ', ' + e.impulses.normalImpulse1; trace('post: ', e.impulses.tangentImpulse1, e.impulses.normalImpulse1); trace('post: ', e.contact.m_manifold.points[0].tangentImpulse, e.contact.m_manifold.points[0].normalImpulse); } } } -------------------------------------------------------------------------------- /TestBed/Main.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import flash.display.*; import flash.events.*; import flash.text.*; import misc.*; public class Main extends MovieClip { public static var tests:Array = [Ragdoll, TheoJansen, Buoyancy, Edges, Edges1, Edges2, Decompose, Decompose2, Wave, Filter, Contact, Impulse, Memory, Raycast, Bullet]; public static var current:int = 0; public static var test:Test = null; public static var debug:b2DebugDraw; public static var fps:FPS; public static var txt:TextField; public function Main() { b2Base.initialize(); Input.initialize(stage); debug = new b2DebugDraw(); addChild(debug); txt = new TextField(); var fmt:TextFormat = new TextFormat("Verdana", 12, 0, false, false, false); txt.defaultTextFormat = fmt; txt.x = 10; txt.y = 10; txt.width = 600; txt.height = 100; txt.text = "Left / Right Arrows: Navigate Demos, R Key: Reset Demo"; txt.mouseEnabled = false; addChild(txt); txt = new TextField(); txt.defaultTextFormat = fmt; fps = new FPS(); fps.startCalc(stage); fps.display = txt; txt.x = 650; txt.y = 10; addChild(txt); txt = new TextField(); txt.defaultTextFormat = fmt; txt.x = 10; txt.y = 30; txt.width = 600; txt.height = 100; txt.mouseEnabled = false; addChild(txt); stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame); } public static function handleEnterFrame(e:Event):void { if(Input.kp('RIGHT')) { ++current; test.destroy(); test = null; } else if(Input.kp('LEFT')) { --current; test.destroy(); test = null; } else if(Input.kp('R')) { test.destroy(); test = null; } if(!test) { current = (current + tests.length) % tests.length; test = new tests[current](); debug.graphics.clear(); debug.world = test; debug.scale = test.scale; } test.EnterFrame(); debug.Draw(); } } } -------------------------------------------------------------------------------- /TestBed/Memory.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; public class Memory extends Test { public var bodies:Vector.; public function Memory() { super(); Main.txt.text = "Memory Test (Rapidly Creating / Destroying Body & Fixture)"; b2Def.circle.m_radius = 13 / scale; b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 300 / scale; b2Def.body.type = b2Body.b2_dynamicBody; b2Def.fixture.shape = b2Def.circle; b2Def.fixture.density = 1; } public override function EnterFrame():void { var i:int = 0; if(bodies) { for(i = 0; i < bodies.length; ++i) { bodies[i].destroy(); } } bodies = new Vector.(); for(i = 0; i < 100; ++i) { var b:b2Body = b2Def.body.create(this); b2Def.fixture.create(b); bodies.push(b); } super.EnterFrame(); } } } -------------------------------------------------------------------------------- /TestBed/Raycast.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; import flash.events.*; import flash.display.MovieClip; public class Raycast extends Test { var drawOn:MovieClip = new MovieClip() var l:b2Body; var r:b2Body; var c:b2Body; public function Raycast() { super(); Main.txt.text = "Raycast:\n"; Main.debug.parent.addChild(drawOn); b2Def.body.type = b2Body.b2_dynamicBody; l = makeCircle(200,300,13) c = makeCircle(350,0,50) r = makeCircle(500,300,13) b2Def.body.type = b2Body.b2_staticBody; b2Def.fixture.isSensor = true; makeCircle(350,300,50); } public override function EnterFrame():void { super.EnterFrame(); doRaycast(); } private function makeCircle(X,Y, rad):b2Body{ b2Def.circle.m_radius = rad / scale; b2Def.body.position.x = X / scale; b2Def.body.position.y = Y / scale; var b:b2Body = b2Def.body.create(this); var f:b2Fixture; with(b2Def.fixture) { shape = b2Def.circle; density = 1.0; f = create(b); } return b } private function doRaycast():void{ var p1:V2 = l.GetWorldCenter() var p2:V2 = r.GetWorldCenter() var f:b2Fixture; var lambda:Number = 1; var cb = function(fixture:b2Fixture, point:V2, normal:V2, fraction:Number):Number{ f = fixture; if(f.IsSensor()) { return fraction; } //f.m_body.GetUserData().alpha -= .2 lambda = fraction return fraction; } this.RayCast(cb, new V2(p1.x, p1.y), new V2(p2.x, p2.y)); p1.multiplyN(30) p2.multiplyN(30) drawOn.graphics.clear(); drawOn.graphics.lineStyle(2,0xff0000,1); drawOn.graphics.moveTo(p1.x, p1.y); drawOn.graphics.lineTo( (p2.x * lambda + (1 - lambda) * p1.x), (p2.y * lambda + (1 - lambda) * p1.y) ); } } } -------------------------------------------------------------------------------- /TestBed/TestBed.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/TestBed/TestBed.fla -------------------------------------------------------------------------------- /TestBed/TestBed.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/TestBed/TestBed.swc -------------------------------------------------------------------------------- /TestBed/TestBed.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/TestBed/TestBed.swf -------------------------------------------------------------------------------- /TestBed/Wave.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import misc.*; public class Wave extends Test { public function Wave() { super(); Main.txt.text = "Wave"; var n:Number = 720 / 100 / scale; var b:b2Body = m_groundBody; var new_b:b2Body; b2Def.body.position.y = 200 / scale; b2Def.body.type = b2Body.b2_dynamicBody; b2Def.polygon.SetAsBox(n / 2, 0.01); b2Def.fixture.shape = b2Def.polygon; b2Def.fixture.density = 0; for(var i:int = 0; i < 100; ++i) { b2Def.body.position.x = (i * n) + (.5 * n); new_b = CreateBody(b2Def.body); new_b.CreateFixture(b2Def.fixture); b2Def.revoluteJoint.Initialize(b, new_b, new V2(i * n, 200 / scale)); CreateJoint(b2Def.revoluteJoint); b = new_b; } b2Def.revoluteJoint.Initialize(b, m_groundBody, new V2(i * n, 200 / scale)); CreateJoint(b2Def.revoluteJoint); b2Def.body.position.x = 300 / scale; b2Def.body.position.y = 100 / scale; b = CreateBody(b2Def.body); b2Def.fixture.shape = b2Def.circle; b2Def.circle.m_radius = 50 / scale; b.CreateFixture(b2Def.fixture); } } } -------------------------------------------------------------------------------- /demo/BoxAndCircle.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import shapes.*; import misc.*; import extras.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class BoxAndCircle extends BodyShape { public override function shapes():void { box(40, 40, new V2(-20, 20)); circle(20, new V2(20, -20)); } } } -------------------------------------------------------------------------------- /demo/Demo.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import shapes.*; import misc.*; import extras.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class Demo extends WCK { var fps:FPS = new FPS(); public function Demo() { stop(); var f:String = loaderInfo.parameters.f; if(f) { gotoAndStop(f); } } public override function create():void { super.create(); fps.startCalc(stage); fps.display = getChildByName('fpstxt') as TextField; var nxt:SimpleButton = getChildByName('next') as SimpleButton; var prv:SimpleButton = getChildByName('prev') as SimpleButton; nxt.addEventListener(MouseEvent.CLICK, nextDemo); prv.addEventListener(MouseEvent.CLICK, prevDemo); nxt.tabEnabled = false; prv.tabEnabled = false; wck.World.dragJointClass = Joint2; } public function nextDemo(e:Event):void { gotoAndStop(currentFrame == totalFrames ? 1 : currentFrame + 1); } public function prevDemo(e:Event):void { gotoAndStop(currentFrame == 1 ? totalFrames : currentFrame - 1); } } } -------------------------------------------------------------------------------- /demo/Preload.as: -------------------------------------------------------------------------------- 1 | package { import flash.display.*; import flash.events.*; import flash.text.TextField; public class Preload extends MovieClip { public function Preload() { stop(); root.loaderInfo.addEventListener(ProgressEvent.PROGRESS, handleProgress); root.loaderInfo.addEventListener(Event.COMPLETE, handleComplete); } public function handleProgress(e:ProgressEvent):void { (getChildByName('loading') as TextField).text = Math.floor(e.bytesLoaded / e.bytesTotal * 100) + '%'; } public function handleComplete(e:Event):void { gotoAndStop(2); root.removeEventListener(ProgressEvent.PROGRESS, handleProgress); root.removeEventListener(Event.COMPLETE, handleComplete); } } } -------------------------------------------------------------------------------- /demo/RemoveButton.as: -------------------------------------------------------------------------------- 1 | package { import flash.display.*; import flash.events.*; import misc.*; import wck.*; /** * A button that will remove its parent. */ public class RemoveButton extends SimpleButton { public function RemoveButton() { addEventListener(MouseEvent.MOUSE_DOWN, handleClick, false, 0, true); } public function handleClick(e:Event):void { e.stopImmediatePropagation(); Util.addChildAtPosOf(Util.findAncestorOfClass(this, wck.World) as DisplayObjectContainer, new FX1(), this.parent); Util.remove(this.parent); } } } -------------------------------------------------------------------------------- /demo/Vehicle.as: -------------------------------------------------------------------------------- 1 | package { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import shapes.*; import misc.*; import extras.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class Vehicle extends ScrollerChild { public var body:BodyShape; public var frontWheel:BodyShape; public var backWheel:BodyShape; public var rollTorque:Number = 13.0; public var maxWheelSpeed:Number = 200.0; public var wheelSpeedInc:Number = 10.0; public override function create():void { super.create(); listenWhileVisible(this, Event.ENTER_FRAME, parseInput, false, 10); body = getChildByName('b') as BodyShape; frontWheel = getChildByName('fw') as BodyShape; backWheel = getChildByName('bw') as BodyShape; } public function parseInput(e:Event):void { var left:Boolean = Input.kd('A', 'LEFT'); var right:Boolean = Input.kd('D', 'RIGHT'); var up:Boolean = Input.kd('W', 'UP'); var down:Boolean = Input.kd('S', 'DOWN'); if(left) { body.b2body.ApplyTorque(-rollTorque); } if(right) { body.b2body.ApplyTorque(rollTorque); } var av:Number = frontWheel.b2body.m_angularVelocity; if(up) { if(av < 0) { av = 0; } if(!(av > maxWheelSpeed)) { av = Math.min(maxWheelSpeed, av + wheelSpeedInc); } } if(down) { if(av > 0) { av = 0; } if(!(av < -maxWheelSpeed)) { av = Math.max(-maxWheelSpeed, av - wheelSpeedInc); } } frontWheel.b2body.m_angularVelocity = av; backWheel.b2body.m_angularVelocity = av; } } } -------------------------------------------------------------------------------- /demo/WorldBuoyancy.as: -------------------------------------------------------------------------------- 1 | package { import wck.*; import misc.*; import flash.utils.*; public class WorldBuoyancy extends wck.World { var i:int; public override function create():void { super.create(); i = setInterval(addWave, 4000); } public override function destroy():void { super.destroy(); clearInterval(i); } public function addWave():void { var b:Buoyancy = getChildByName('bwaves') as Buoyancy; var w:Wave = new Wave(); w.amplitude = -200; w.wavelength = 200; w.clampFunc = Util.sinEaseInOut; w.velocity = 5; w.left = -300; w.right = 0; b.water.addWave(w); } } } -------------------------------------------------------------------------------- /demo/demo.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/demo/demo.fla -------------------------------------------------------------------------------- /demo/demo.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/demo/demo.swc -------------------------------------------------------------------------------- /demo/demo.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/demo/demo.swf -------------------------------------------------------------------------------- /demo/pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/demo/pattern.png -------------------------------------------------------------------------------- /extras/Crayon.as: -------------------------------------------------------------------------------- 1 | package extras { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; /** * Base crayon class - doesn't create any shapes. */ public class Crayon extends BodyShape { public var lineThickness:Number = 5; public var lineColor:Number = 0xffffff; var tracer:XYTracer; var source:XYSource; public override function create():void { type = 'Static'; super.create(); tracer = new XYTracer(source); tracer.addPoint(new Point(0, 0), false); tracer.localTo = this; listenWhileVisible(tracer, XYTracer.TEMP_POINT, onTempPoint); listenWhileVisible(tracer, XYTracer.PERM_POINT, onPermPoint); listenWhileVisible(tracer, XYTracer.FINISHED, onFinished); } public function onTempPoint(e:Event):void { onPoint(e); } public function onPermPoint(e:Event):void { onPoint(e); } public function onPoint(e:Event):void { graphics.clear(); graphics.lineStyle(lineThickness, lineColor); graphics.drawGraphicsData(Vector.([tracer.path])); } public function onFinished(e:Event):void { listenWhileVisible(world, StepEvent.STEP, updateBodyMatrixSimple, false, -10); } } } -------------------------------------------------------------------------------- /extras/CrayonSolid.as: -------------------------------------------------------------------------------- 1 | package extras { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; public class CrayonSolid extends Crayon { public var confirm:Boolean = true; public override function create():void { source = new XYSource(); listenOnceWhileVisible(stage, Input.MOUSE_UP_OR_LOST, function() { tracer.finish(); }); super.create(); tracer.loop = true; } public override function onFinished(e:Event):void { isSensor = true; super.onFinished(e); if(tracer.points.length < 3) { remove(); return; } if(tracer.circle) { circle(tracer.circleRadius, V2.fromP(tracer.center)); } else { var coords:Vector. = new Vector.; for(var i:int = 0; i < tracer.points.length; ++i) { coords.push(tracer.points[i].x); coords.push(tracer.points[i].y); } decomposedPoly(coords); if(b2fixtures.length == 0) { Util.remove(this); return; } } var p:Point = tracer.points[0]; graphics.clear(); for(i = 0; i < b2fixtures.length; ++i) { graphics.lineStyle(1, 0xffffff); graphics.beginFill(0x5b9ef4); b2fixtures[i].Draw(graphics, new XF(new V2(), M22.identity()), world.scale); graphics.endFill(); b2fixtures[i].m_reportBeginContact = true; } listenWhileVisible(this, ContactEvent.BEGIN_CONTACT, detectContact); listenOnceWhileVisible(world, StepEvent.STEP, confirmShape, false, -1); } public function detectContact(e:Event):void { e.preventDefault(); confirm = false; } public function confirmShape(e:Event):void { stopListening(this, ContactEvent.BEGIN_CONTACT, detectContact); if(confirm) { b2body.SetType(b2Body.b2_dynamicBody); for(var i:int = 0; i < b2fixtures.length; ++i) { b2fixtures[i].SetSensor(false); } } else { remove(); } } } } -------------------------------------------------------------------------------- /extras/CrayonTip.as: -------------------------------------------------------------------------------- 1 | package extras { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; import shapes.*; public class CrayonTip extends Circle { public var radius:Number = 2.5; public var color:Number = 0xffffff; public override function create():void { graphics.drawCircle(0, 0, radius); bullet = true; super.create(); world.createDragJoint(this); listenWhileVisible(stage, Input.MOUSE_UP_OR_LOST, remove); } } } -------------------------------------------------------------------------------- /extras/Platform.as: -------------------------------------------------------------------------------- 1 | package extras { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import shapes.*; import misc.*; import extras.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class Platform extends Box { public override function create():void { reportBeginContact = true; super.create(); listenWhileVisible(this, ContactEvent.BEGIN_CONTACT, handleBeginContact); listenWhileVisible(this, ContactEvent.END_CONTACT, handleEndContact); } public function handleBeginContact(e:ContactEvent):void { if(e.normal) { var m:Matrix = matrix.clone(); m.tx = 0; m.ty = 0; m.invert(); var n:V2 = b2body.GetLocalVector(e.normal); var p:Point = m.transformPoint(n.toP()); e.contact.SetEnabled(p.y < -0.8); } } public function handleEndContact(e:ContactEvent):void { e.contact.SetEnabled(true); } } } -------------------------------------------------------------------------------- /extras/WorldClickAdd.as: -------------------------------------------------------------------------------- 1 | package extras { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import shapes.*; import misc.*; import extras.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class WorldClickAdd extends wck.World { [Inspectable(defaultValue='')] public var clickClassName:String = ''; [Inspectable(defaultValue='')] public var clickClassFXName:String = ''; public var clickClass:Class; public var clickClassFX:Class; public override function create():void { if(!clickClass && clickClassName != '') { clickClass = getDefinitionByName(clickClassName) as Class; if(!clickClassFX && clickClassFXName != '') { clickClassFX = getDefinitionByName(clickClassFXName) as Class; } listenWhileVisible(stage, MouseEvent.MOUSE_DOWN, handleMouseDown); } super.create(); } public function handleMouseDown(e:Event):void { if(e.target == stage) { var p:Point = Input.mousePositionIn(this); if(clickClass) { Util.addChildAtPos(this, new clickClass(), p); } if(clickClassFX) { Util.addChildAtPos(this, new clickClassFX(), p); } } } } } -------------------------------------------------------------------------------- /gravity/GravityLinear.as: -------------------------------------------------------------------------------- 1 | package gravity { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; /** * */ public class GravityLinear extends Gravity { public var v:V2; /** * */ public override function initStep(e:Event):void { v = V2.rotate(base, rotation * Util.D2R); } /** * */ public override function gravity(p:V2, b:b2Body = null, b2:BodyShape = null):V2 { return v; } } } -------------------------------------------------------------------------------- /gravity/GravityRadial.as: -------------------------------------------------------------------------------- 1 | package gravity { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import gravity.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; /** * Provides radial gravity. */ public class GravityRadial extends Gravity { public var origin:V2; public var v:V2; /** * Get the gravity origin in b2World coordinates. */ public override function initStep(e:Event):void { origin = V2.fromP(Util.localizePoint(world, this)).divideN(world.scale); v = V2.rotate(base, rotation * Util.D2R); // Added so rotating can change the gravity direction. } /** * Rotate the base vector gravity based on the direction of the point to the origin. */ public override function gravity(p:V2, b:b2Body = null, b2:BodyShape = null):V2 { return V2.rotate(v, (V2.subtract(p, origin)).angle() + Math.PI / 2); } } } -------------------------------------------------------------------------------- /gravity/GravitySine.as: -------------------------------------------------------------------------------- 1 | package gravity { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import gravity.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; /** * Provides gravity that changes direction along an axis based on a sine wave. */ public class GravitySine extends Gravity { public var waveLen:Number; public var v:V2; /** * */ public override function initStep(e:Event):void { var r:Rectangle = Util.bounds(this); waveLen = r.width / 2; v = V2.rotate(base, rotation * Util.D2R); } /** * */ public override function gravity(p:V2, b:b2Body = null, b2:BodyShape = null):V2 { /// Transform the point into the local coordinate space. var lp:Point = Util.localizePoint(this, world, V2.multiplyN(p, world.scale).toP()); /// Get an angle based on the x coordinate. var a:Number = lp.x / waveLen * Math.PI; /// Rotate base gravity. return V2.rotate(v, a); } } } -------------------------------------------------------------------------------- /misc/Connector.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import flash.display.*; 4 | import flash.events.*; 5 | import flash.utils.*; 6 | import flash.geom.*; 7 | import flash.ui.*; 8 | import misc.*; 9 | 10 | /** 11 | * Base display object that visually "connects" two other display objects, whereever they may 12 | * be in the display object hierarchy. Subclasses must override and implement "render" to draw 13 | * the connection. 14 | */ 15 | public class Connector extends Entity { 16 | 17 | public var from:DisplayObject; // connect from this object... 18 | public var to:DisplayObject; // ... to this object. 19 | public var localPoint1:Point = new Point(0, 0); // Local point in object 1. 20 | public var localPoint2:Point = new Point(0, 0); // Local point in object 2. 21 | public var point1:Point = new Point(0, 0); // The connector should be set to this position within it's parent. 22 | public var point2:Point = new Point(0, 0); // The destination position (within the parent) 23 | public var length:Number; // The length of the connection. The Connector should draw from zero to this far down the x axis. 24 | 25 | /** 26 | * Listen to a stage for enter frame events at a really low priority - the listener should fire 27 | * after everything else is moved around. 28 | */ 29 | public override function create():void { 30 | listenWhileVisible(stage, Event.ENTER_FRAME, handleEnterFrame, false, -1000); 31 | } 32 | 33 | /** 34 | * Positon and rotate the connector to set it up for rendering. 35 | */ 36 | public function handleEnterFrame(e:Event):void { 37 | if(from) { 38 | point1 = Util.localizePoint(parent, from, localPoint1); 39 | } 40 | if(to) { 41 | point2 = Util.localizePoint(parent, to, localPoint2); 42 | } 43 | setPos(point1); 44 | var dx:Number = point2.x - x; 45 | var dy:Number = point2.y - y; 46 | length = Math.sqrt(dx * dx + dy * dy); 47 | rotation = Math.atan2(dy, dx) * Util.R2D; 48 | render(); 49 | } 50 | 51 | /** 52 | * Override this to actually render the connector. Simply draw out from (0,0) to (length, 0). 53 | */ 54 | public function render():void { 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /misc/ConnectorLine.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import flash.display.*; 4 | import flash.utils.*; 5 | import flash.geom.*; 6 | 7 | /** 8 | * Connects two display objects via a line. 9 | */ 10 | public class ConnectorLine extends Connector { 11 | 12 | public var thickness:Number = 2; 13 | public var color:Number = 0x888888; 14 | 15 | /** 16 | * Draw a line from (0, 0) to (length, 0). 17 | */ 18 | public override function render():void { 19 | graphics.clear(); 20 | graphics.lineStyle(thickness, color); 21 | graphics.moveTo(0, 0); 22 | graphics.lineTo(length, 0); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /misc/ConnectorMask.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import flash.display.*; 4 | import flash.utils.*; 5 | import flash.geom.*; 6 | 7 | /** 8 | * Connector that uses a mask to display a pre-drawn "line" only to the length between the 9 | * two objects. 10 | */ 11 | public class ConnectorMask extends Connector { 12 | 13 | public var m:Sprite; 14 | 15 | /** 16 | * Set up the mask object. 17 | */ 18 | public function ConnectorMask() { 19 | m = new Sprite(); 20 | addChild(m); 21 | mask = m; 22 | } 23 | 24 | /** 25 | * Draw the mask. 26 | */ 27 | public override function render():void { 28 | m.graphics.clear(); 29 | m.graphics.beginFill(0xffffff); 30 | m.graphics.drawRect(0, -5000, length, 10000); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /misc/ConnectorStretch.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import flash.display.*; 4 | import flash.utils.*; 5 | import flash.geom.*; 6 | 7 | /** 8 | * A connector that "stretches" a predrawn "line" between two objects. 9 | */ 10 | public class ConnectorStretch extends Connector { 11 | 12 | /** 13 | * Set the width of the connector to the distance between the objects. 14 | */ 15 | public override function render():void { 16 | var r:Number = rotation; 17 | rotation = 0; 18 | width = length; 19 | rotation = r; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /misc/Cursor.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import misc.*; 4 | import flash.display.*; 5 | import flash.events.*; 6 | import flash.utils.*; 7 | import flash.geom.*; 8 | import flash.ui.*; 9 | 10 | public class Cursor extends Entity { 11 | 12 | public override function create():void { 13 | mouseEnabled = false; 14 | mouseChildren = false; 15 | Mouse.hide(); 16 | super.create(); 17 | listenWhileVisible(stage, Event.ENTER_FRAME, handleEnterFrame); 18 | } 19 | 20 | public function handleEnterFrame(e:Event):void { 21 | Util.setPos(this, parent.globalToLocal(Input.mousePos)); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /misc/FX.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import misc.*; 4 | import flash.display.*; 5 | import flash.events.*; 6 | import flash.utils.*; 7 | import flash.geom.*; 8 | 9 | public class FX extends MovieClip { 10 | 11 | public var onDone:Function = null; 12 | 13 | public function FX() { 14 | mouseEnabled = false; 15 | mouseChildren = false; 16 | addEventListener(Event.ENTER_FRAME, checkDone); 17 | } 18 | 19 | public function checkDone(e:Event):void { 20 | if(isDone()) { 21 | Util.remove(this); 22 | removeEventListener(Event.ENTER_FRAME, checkDone); 23 | if(onDone != null) { 24 | onDone(); 25 | } 26 | } 27 | } 28 | 29 | public function isDone():Boolean { 30 | return (currentFrame == totalFrames); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /misc/FX3DSpinner.as: -------------------------------------------------------------------------------- 1 | package misc { import misc.*; import flash.display.*; import flash.events.*; import flash.utils.*; import flash.geom.*; public class FX3DSpinner extends FXContainer { public function FX3DSpinner() { for(var i:int = 0; i < numChildren; ++i) { var m:Matrix3D = new Matrix3D(); var v:Vector3D = new Vector3D(Math.random(), Math.random(), Math.random()); v.normalize(); m.appendRotation(Math.random() * 180, v); getChildAt(i).transform.matrix3D = m; } } } } -------------------------------------------------------------------------------- /misc/FXContainer.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import misc.*; 4 | import flash.display.*; 5 | import flash.events.*; 6 | import flash.utils.*; 7 | import flash.geom.*; 8 | 9 | public class FXContainer extends FX { 10 | 11 | public override function isDone():Boolean { 12 | return numChildren == 0; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /misc/Parallax.as: -------------------------------------------------------------------------------- 1 | package misc { import misc.*; import flash.display.*; import flash.events.*; import flash.utils.*; import flash.geom.*; import flash.ui.*; public class Parallax extends Entity { [Inspectable(defaultValue=0.5)] public var factorX:Number = 0.5; [Inspectable(defaultValue=0.5)] public var factorY:Number = 0.5; public var parentInitPos:Point; public var initPos:Point; public var offset:Point; public override function create():void { offset = new Point(x, y); initPos = parent.localToGlobal(new Point(0, 0)); parentInitPos = new Point(parent.x, parent.y); listenWhileVisible(stage, Event.ENTER_FRAME, update, false, -99999); } public function update(e:Event):void { var newPos:Point = parent.globalToLocal(initPos); x = newPos.x * factorX + offset.x; y = newPos.y * factorY + offset.y; } } } -------------------------------------------------------------------------------- /misc/ScrollerChild.as: -------------------------------------------------------------------------------- 1 | package misc { 2 | 3 | import misc.*; 4 | import flash.display.*; 5 | import flash.events.*; 6 | import flash.utils.*; 7 | import flash.geom.*; 8 | import flash.ui.*; 9 | 10 | /** 11 | * An entity that is a descendent of a "Scroller" entity. 12 | */ 13 | public class ScrollerChild extends Entity { 14 | 15 | /// Setting this to true will make the Scroller focus on this object. If you set this to true 16 | /// for more than one ScrollerChild in a Scroller, only one will become the focus. 17 | [Inspectable(defaultValue=false)] 18 | public var focusOn:Boolean = false; 19 | 20 | /** 21 | * Tell the Scroller to focus on this object if focusOn == true. 22 | */ 23 | public override function create():void { 24 | super.create(); 25 | if(focusOn) { 26 | var s:Scroller = Util.findAncestorOfClass(this, Scroller) as Scroller; 27 | if(s) { 28 | s.focus = this; 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /misc/XYSource.as: -------------------------------------------------------------------------------- 1 | package misc { import misc.*; import flash.display.*; import flash.events.*; import flash.utils.*; import flash.geom.*; import flash.events.*; /** * Base class for object that act as a source for XY coordinates. The default behavior is to * return the position of the mouse. */ public class XYSource { public function get point():Point { return Input.mousePos; } } } -------------------------------------------------------------------------------- /misc/XYSourceDisplayObject.as: -------------------------------------------------------------------------------- 1 | package misc { import misc.*; import flash.display.*; import flash.events.*; import flash.utils.*; import flash.geom.*; import flash.events.*; /** * An XY source that returns the global coordinates of a display object (obj must be set). */ public class XYSourceDisplayObject extends XYSource { public var obj:DisplayObject; public override function get point():Point { return obj.localToGlobal(new Point()); } } } -------------------------------------------------------------------------------- /probe/Box2D.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/probe/Box2D.swc -------------------------------------------------------------------------------- /probe/probe.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/probe/probe.fla -------------------------------------------------------------------------------- /probe/probe.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/probe/probe.swc -------------------------------------------------------------------------------- /probe/probe.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesses/wck/5945c358c898a43c1c7f744f9f7647b025fa2074/probe/probe.swf -------------------------------------------------------------------------------- /script/Clear Outline.jsfl: -------------------------------------------------------------------------------- 1 | fl.drawingLayer.beginDraw(false); 2 | fl.drawingLayer.endDraw(); -------------------------------------------------------------------------------- /script/Set Component Property.jsfl: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Sets a component property on multiple selected components 4 | 5 | */ 6 | 7 | 8 | var sel = fl.getDocumentDOM().selection; 9 | var pname = prompt('What property do you want to set?'); 10 | if(pname) { 11 | var pvalue = prompt('What value do you want to set it to?'); 12 | if(pvalue != null) { 13 | for(var i = 0; i < sel.length; ++i) { 14 | var s = sel[i]; 15 | if(s.parameters) { 16 | var j = 0; 17 | var p = null; 18 | while(j < s.parameters.length && !p) { 19 | if(s.parameters[j].name == pname) { 20 | p = s.parameters[j]; 21 | } 22 | j++; 23 | } 24 | if(p) { 25 | p.value = pvalue; 26 | } 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /script/Trace Edges.jsfl: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Adapted from: 4 | http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00003808.html#wp461362 5 | 6 | */ 7 | 8 | var selArray = fl.getDocumentDOM().selection; 9 | fl.trace( "selection length: " + selArray.length ); 10 | 11 | var elt = selArray[0]; 12 | fl.trace( "selected element" + elt ); 13 | fl.trace( "element type: " + elt.elementType ); 14 | 15 | var contourArray = elt.contours; 16 | //fl.trace("contour array length: " + contourArray.length); 17 | 18 | for (i=0; i 0; } return (maskBits & flt.categoryBits) != 0 && (categoryBits & flt.maskBits) != 0; } } } -------------------------------------------------------------------------------- /wck/WCK.as: -------------------------------------------------------------------------------- 1 | package wck { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import cmodule.Box2D.*; import wck.*; import misc.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; import flash.ui.*; /** * A base document class for WCK based Flash SWFs */ public class WCK extends Entity { public override function create():void { b2Base.initialize(); Input.initialize(stage); } } } -------------------------------------------------------------------------------- /wck/WavesEffect.as: -------------------------------------------------------------------------------- 1 | package extras { import Box2DAS.*; import Box2DAS.Collision.*; import Box2DAS.Collision.Shapes.*; import Box2DAS.Common.*; import Box2DAS.Controllers.*; import Box2DAS.Dynamics.*; import Box2DAS.Dynamics.Contacts.*; import Box2DAS.Dynamics.Joints.*; import wck.*; import shapes.*; import misc.*; import extras.*; import flash.utils.*; import flash.events.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class WavesEffect extends b2BuoyancyEffect { public var waves:Waves; /*public var wavesScale:Number; public var surface:V2; public var surfaceOffset:Number; */ public var bs:BodyShape; public override function Apply(body:b2Body):void { var p:Point = Util.localizePoint(bs, body.m_userData as BodyShape); /*var local:Number = body.m_xf.position.v2.dot(surface) - surfaceOffset; */ var x:Number = p.x + Util.bounds(bs).width / 2; var y:Number = waves.valueAt(x) / bs.world.scale; if(y) { offset -= y; super.Apply(body); offset += y; } } } } --------------------------------------------------------------------------------