box2d library


Copyright (c) 2015, Daniel Murphy, Google All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Classes

AABB
An axis-aligned bounding box.
Body
A rigid body. These are created via World.createBody.
BodyDef
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction.
BroadPhase
BroadPhaseStrategy
ChainAndCircleContact
ChainAndPolygonContact
ChainShape
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions. WARNING: The chain will not collide properly if there are self-intersections.
CircleContact
CircleShape
A circle shape.
ClipVertex
Used for computing contact manifolds.
Collision
Functions used for computing contact points, distance queries, and TOI queries. Collision methods are non-static for pooling speed, retrieve a collision object from the {@link SingletonPool}. Should not be finalructed.
Color3i
ConstantVolumeJoint
ConstantVolumeJointDef
Definition for a {@link ConstantVolumeJoint}, which connects a group a bodies together so they maintain a constant volume within them.
Contact
The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.
ContactCreator
ContactEdge
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.
ContactFilter
Implement this class to provide collision filtering. In other words, you can implement this class if you want finer control over contact creation.
ContactID
ContactImpulse
Contact impulses for reporting. Impulses are used instead of forces because sub-step forces may approach infinity for rigid body collisions. These match up one-to-one with the contact points in b2Manifold.
ContactListener
Implement this class to get contact information. You can use these results for things like sounds and game logic. You can also get contact results by traversing the contact lists after the time step. However, you might miss some contacts because continuous physics leads to sub-stepping. Additionally you may receive multiple callbacks for the same contact in a single time step. You should strive to make your callbacks efficient because there may be many callbacks per time step. @warning You cannot create/destroy Box2D entities inside these callbacks.
ContactManager
Delegate of World.
ContactPositionConstraint
ContactRegister
ContactSolver
ContactSolverDef
ContactVelocityConstraint
CreateParticleGroupCallback
DebugDraw
Implement this abstract class to allow DBox2d to automatically draw your physics for debugging purposes. Not intended to replace your own custom rendering routines!
DefaultBroadPhaseBuffer
The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap.
DefaultWorldPool
DestroyParticlesInShapeCallback
DestructionListener
Joints and fixtures are destroyed when their associated body is destroyed. Implement this listener so that you may nullify references to these joints and shapes.
Distance
DistanceInput
Input for Distance. You have to option to use the shape radii in the computation.
DistanceJoint
A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.
DistanceJointDef
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. [...]
DistanceOutput
Output for Distance.
DistanceProxy
DynamicTree
A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leafs are proxies with an AABB. In the tree we expand the proxy AABB by _fatAABBFactor so that the proxy AABB is bigger than the client object. This allows the client object to move by small amounts without triggering a tree update.
DynamicTreeFlatNodes
DynamicTreeNode
EdgeAndCircleContact
EdgeAndPolygonContact
EdgeShape
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.
EPAxis
EPCollider
Filter
This holds contact filtering data.
Fixture
A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via Body::CreateFixture. [...]
FixtureDef
A fixture definition is used to create a fixture. This class defines an abstract fixture definition. You can reuse fixture definitions safely.
FixtureProxy
This proxy is used internally to connect fixtures to the broad-phase.
FrictionJoint
FrictionJointDef
Friction joint definition.
GearJoint
A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length. [...]
GearJointDef
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.
IDynamicStack<E>
IntArray
IOrderedStack<E>
Island
This is an internal class.
IWorldPool
Jacobian
JoinParticleGroupsCallback
Joint
The base joint class. Joints are used to constrain two bodies together in various fashions. Some joints also feature limits and motors.
JointDef
Joint definitions are used to construct joints.
JointEdge
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.
Manifold
ManifoldPoint
A manifold point is a contact point belonging to a contact manifold. It holds details related to the geometry and dynamics of the contact points. The local point usage depends on the manifold type: [...]
MassData
This holds the mass data computed for a shape.
Matrix2
2D Matrix. Values are stored in column major order.
Matrix3
3D Matrix. Values are stored in column major order.
MotorJoint
A motor joint is used to control the relative motion between two bodies. A typical usage is to control the movement of a dynamic body with respect to the ground.
MotorJointDef
Motor joint definition.
MouseJoint
A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces. NOTE: this joint is not documented in the manual because it was developed to be used in the testbed. If you want to learn how to use the mouse joint, look at the testbed.
MouseJointDef
Mouse joint definition. This requires a world target point, tuning parameters, and the time step.
MutableStack<E>
MutableStackChainAndCircleContact
MutableStackChainAndPolygonContact
MutableStackCircleContact
MutableStackEdgeAndCircleContact
MutableStackEdgeAndPolygonContact
MutableStackPolygonAndCircleContact
MutableStackPolygonContact
MutableStackWithPool<T>
NewIndices
OrderedStack<E>
OrderedStackAABB
OrderedStackMat22
OrderedStackMat33
OrderedStackRot
OrderedStackVec2
Provides object pooling for all objects used in the engine. Objects retrieved from here should only be used temporarily, and then pushed back (with the exception of arrays).
OrderedStackVec3
Pair
Java note: at the "creation" of each node, a random key is given to that node, and that's what we sort from.
PairCallback
ParticleBodyContact
ParticleBuffer<T>
ParticleBufferInt
ParticleColor
Small color object for each particle
ParticleContact
ParticleDef
ParticleDestructionListener
ParticleGroup
ParticleGroupDef
A particle group definition holds all the data needed to construct a particle group. You can safely re-use these definitions.
ParticleGroupType
ParticleQueryCallback
Callback class for AABB queries. See {@link World#queryAABB(QueryCallback, org.jbox2d.collision.AABB)}.
ParticleRaycastCallback
ParticleSystem
ParticleSystemTest
ParticleType
The particle type. Can be combined with | operator. Zero means liquid.
PolygonAndCircleContact
PolygonContact
PolygonShape
A convex polygon shape. Polygons have a maximum number of vertices equal to _maxPolygonVertices. In most cases you should not need many vertices for a convex polygon.
Position
PositionSolverManifold
PrismaticJoint
A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in bodyA. Relative rotation is prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction.
PrismaticJointDef
Prismatic joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game. [...]
Profile
ProfileEntry
PsPair
Connection between two particles
PsProxy
Used for detecting particle contacts
PsTriad
Connection between three particles
PulleyJoint
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2 <= constant Yes, the force transmitted is scaled by the ratio. Warning: the pulley joint can get a bit squirrelly by itself. They often work better when combined with prismatic joints. You should also cover the the anchor points with static shapes to prevent one side from going to zero length.
PulleyJointDef
Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, and a pulley ratio.
QueryCallback
Callback class for AABB queries. See {@link World#queryAABB(QueryCallback, org.jbox2d.collision.AABB)}.
RayCastCallback
Callback class for ray casts. See {@link World#raycast(RayCastCallback, Vec2, Vec2)}
RayCastInput
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
RayCastOutput
Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and p2 come from b2RayCastInput.
RaycastResult
RevoluteJoint
A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.
RevoluteJointDef
Revolute joint definition. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because:<br/> [...]
RopeJoint
A rope joint enforces a maximum distance between two points on two bodies. It has no other effect. Warning: if you attempt to change the maximum length during the simulation you will get some non-physical behavior. A model that would allow you to dynamically modify the length would have some sponginess, so I chose not to implement it that way. See DistanceJoint if you want to dynamically control length.
RopeJointDef
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.
Rot
SeparationFunction
Shape
A shape is used for collision detection. You can create a shape however you like. Shapes used for simulation in World are created automatically when a Fixture is created. Shapes may encapsulate a one or more child shapes.
SimplexCache
SolveCollisionCallback
SolverData
StackQueue<T>
Sweep
This describes the motion of a body/shape for TOI computation. Shapes are defined with respect to the body origin, which may not coincide with the center of mass. However, to support dynamics we must interpolate the center of mass position.
TempPolygon
This holds polygon B expressed in frame A.
TimeOfImpact
Class used for computing the time of impact. This class should not be constructed usually, just retrieve from the {@link SingletonPool#getTOI()}.
Timer
TimeStep
This is an internal structure.
TOIInput
Input parameters for TOI
TOIOutput
Output parameters for TimeOfImpact
Transform
A transform contains translation and rotation. It is used to represent the position and orientation of rigid frames.
TreeCallback
Callback for {@link DynamicTree}
TreeRayCastCallback
Callback for {@link DynamicTree}
UpdateBodyContactsCallback
Vec2Array
Vector2
2D column vector.
Vector3
3D column vector.
Velocity
VelocityConstraintPoint
ViewportTransform
VoronoiDiagram
VoronoiDiagramCallback
VoronoiDiagramTask
VoronoiDiagramTaskMutableStack
VoronoiGenerator
WeldJoint
A weld joint essentially glues two bodies together. A weld joint may distort somewhat because the island constraint solver is approximate.
WeldJointDef
WheelJoint
A wheel joint. This joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. You can use a joint limit to restrict the range of motion and a joint motor to drive the rotation or to model rotational friction. This joint is designed for vehicle suspensions.
WheelJointDef
Wheel joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
World
The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.
WorldManifold
This is used to compute the current state of a contact manifold.
WorldQueryWrapper
WorldRayCastWrapper

Functions

allocPsTriad() PsTriad

Enums

BodyType
The body type. static: zero mass, zero velocity, may be manually moved kinematic: zero mass, non-zero velocity set by user, moved by solver dynamic: positive mass, non-zero velocity determined by forces, moved by solver
ContactIDType
EPAxisType
This structure is used to keep track of the best separating axis.
JointType
LimitState
ManifoldType
A manifold for two touching convex shapes. Box2D supports multiple types of contact: [...]
PointState
This is used for determining the state of contact points.
SeparationFunctionType
ShapeType
Types of shapes
TOIOutputState
VertexType

Typedefs

AllocClosure<T> = T Function()