This is a small object allocator used for allocating small
objects that persist for more than one time step.
See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp
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.
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.
A chain shape is a free form sequence of line segments.
The chain has one-sided collision, with the surface normal pointing to the right of the edge.
This provides a counter-clockwise winding like the polygon shape.
Connectivity information is used to create smooth collisions.
@warning the chain will not collide properly if there are self-intersections.
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.
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.
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.
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.
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 joint definition. This requires defining an anchor point on both
bodies and the non-zero distance 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.
A line segment (edge) shape. These can be connected in chains or loops
to other edge shapes. Edges created independently are two-sided and do
no provide smooth movement across junctions.
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 b2Body::CreateFixture.
@warning you cannot reuse fixtures.
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.
@warning You have to manually destroy the gear joint if joint1 or joint2
is destroyed.
Gear joint definition. This definition requires two existing
revolute or prismatic joints (any combination will work).
@warning bodyB on the input joints must both be dynamic
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.
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.
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.
Handle to a particle. Particle indices are ephemeral: the same index might
refer to a different particle, from frame-to-frame. If you need to keep a
reference to a particular particle across frames, you should acquire a
b2ParticleHandle. Use #b2ParticleSystem::GetParticleHandleFromIndex() to
retrieve the b2ParticleHandle of a particle from the particle system.
A solid convex polygon. It is assumed that the interior of the polygon is to
the left of each edge.
Polygons have a maximum number of vertices equal to b2_maxPolygonVertices.
In most cases you should not need many vertices for a convex polygon.
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.
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.
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.
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.
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:
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.
A wheel joint. This joint provides two degrees of freedom: translation
along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to
line constraint with a rotational motor and a linear spring/damper. The spring/damper is
initialized upon creation. This joint is designed for vehicle suspensions.
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.
The world class manages all physics entities, dynamic simulation,
and asynchronous queries. The world also contains efficient memory
management facilities.
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