++ed by:
GARU

1 PAUSE user
1 non-PAUSE user.

Jeffrey T. Palmer
and 1 contributors

NAME

Box2D::b2World - Manages all aspects of the simulation.

SYNOPSIS

  my $world = Box2D::b2World->new( $gravity, $doSleep );

DESCRIPTION

The Box2D::b2World class contains the bodies and joints. It manages all aspects of the simulation and allows for asynchronous queries (like AABB queries and ray-casts). Much of your interactions with Box2D will be with a Box2D::b2World object.

METHODS

new( $gravity, $doSleep )

Construct a world object.

Parameters:

  • Box2D::b2Vec2 $gravity - the world gravity vector.

  • bool $doSleep - improve performance by not simulating inactive bodies.

Returns a Box2D::b2World

ClearForces()

Call this after you are done with time steps to clear the forces. You normally call this after each call to Step, unless you are performing sub-steps. By default, forces will be automatically cleared, so you don't need to call this function.

See also: SetAutoClearForces

CreateBody( $def )

Create a rigid body given a definition. No reference to the definition is retained.

Warning: This function is locked during callbacks.

Parameters:

  • Box2D::b2BodyDef $def

Returns a Box2D::b2Body

CreateJoint( $def )

Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding.

Warning: This function is locked during callbacks.

Parameters:

  • Box2D::b2JointDef $def

Returns a Box2D::b2Joint

DestroyBody( $body )

Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.

Warning: This automatically deletes all associated shapes and joints. This function is locked during callbacks.

Parameters:

  • Box2D::b2Body $body

GetGravity()

Get the global gravity vector.

Returns a Box2D::b2Vec2

RayCast( $callback, $point1, $point2 )

Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point.

Parameters:

  • Box2D::b2RayCastCallback $callback - a user implemented callback class.

  • Box2D::b2Vec2 $point1 - the ray starting point

  • Box2D::b2Vec2 $point2 - the ray ending point

SetContactListener( $listener )

Register a contact event listener. The listener is owned by you and must remain in scope.

Parameters:

  • Box2D::b2ContactListener $listener

SetGravity( $gravity )

Change the global gravity vector.

Parameters:

  • Box2D::b2Vec2 $gravity

Step( $timeStep, $velocityIterations, $positionIterations )

Take a time step. This performs collision detection, integration, and constraint solution.

Parameters:

  • float32 $timeStep - the amount of time to simulate, this should not vary.

  • int32 $velocityIterations - for the velocity constraint solver.

  • int32 $positionIterations - for the position constraint solver.

SEE ALSO

BUGS

See "BUGS" in Box2D

AUTHORS

See "AUTHORS" in Box2D

COPYRIGHT & LICENSE

See "COPYRIGHT & LICENSE" in Box2D