Package pybox2d :: Module Box2D :: Class b2World |
[hide private]
[frames] | no frames]

# type b2World

source code

The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.

Instance Methods | [hide private]
__init__(self, *args) __init__(self, b2AABB worldAABB, b2Vec2 gravity, bool doSleep) -> b2World | source code
__swig_destroy__(...) delete_b2World(b2World self) |
__repr__(self) | source code
__getstate__(self) Get the state of the world. | source code
__setstate__(self, data) The factory output cannot be created just yet, so store the necessary information to create it later. | source code
_pickle_finalize(self) Finalize a b2World. | source code
GetJointList(self) Get a list of the joints in this world | source code
GetBodyList(self) Get a list of the bodies in this world | source code
GetControllerList(self) Get a list of the controllers in this world | source code
__iter__(self) Iterates over the bodies in the world | source code
SetDestructionListener(...) b2World_SetDestructionListener(b2World self, b2DestructionListener listener) | source code
SetBoundaryListener(...) b2World_SetBoundaryListener(b2World self, b2BoundaryListener listener) | source code
SetContactFilter(...) b2World_SetContactFilter(b2World self, b2ContactFilter filter) | source code
SetContactListener(...) b2World_SetContactListener(b2World self, b2ContactListener listener) | source code
SetDebugDraw(...) b2World_SetDebugDraw(b2World self, b2DebugDraw debugDraw) | source code
CreateController(...) b2World_CreateController(b2World self, b2ControllerDef _def) -> b2Controller | source code
DestroyController(...) b2World_DestroyController(b2World self, b2Controller controller) | source code
GetGroundBody(...) b2World_GetGroundBody(b2World self) -> b2Body | source code
Step(...) b2World_Step(b2World self, float32 timeStep, int32 velocityIterations, int32 positionIterations) | source code
InRange(...) b2World_InRange(b2World self, b2AABB aabb) -> bool | source code
_GetBodyList(...) b2World__GetBodyList(b2World self) -> b2Body | source code
_GetJointList(...) b2World__GetJointList(b2World self) -> b2Joint | source code
_GetControllerList(...) b2World__GetControllerList(b2World self) -> b2Controller | source code
Refilter(...) b2World_Refilter(b2World self, b2Shape shape) | source code
SetWarmStarting(...) b2World_SetWarmStarting(b2World self, bool flag) | source code
SetContinuousPhysics(...) b2World_SetContinuousPhysics(b2World self, bool flag) | source code
Validate(...) b2World_Validate(b2World self) | source code
GetProxyCount(...) b2World_GetProxyCount(b2World self) -> int32 | source code
GetPairCount(...) b2World_GetPairCount(b2World self) -> int32 | source code
GetBodyCount(...) b2World_GetBodyCount(b2World self) -> int32 | source code
GetJointCount(...) b2World_GetJointCount(b2World self) -> int32 | source code
GetContactCount(...) b2World_GetContactCount(b2World self) -> int32 | source code
GetControllerCount(...) b2World_GetControllerCount(b2World self) -> int32 | source code
SetGravity(...) b2World_SetGravity(b2World self, b2Vec2 gravity) | source code
GetGravity(...) b2World_GetGravity(b2World self) -> b2Vec2 | source code
GetWorldAABB(...) b2World_GetWorldAABB(b2World self) -> b2AABB | source code
CanSleep(...) b2World_CanSleep(b2World self) -> bool | source code
CreateBody(...) b2World_CreateBody(b2World self, b2BodyDef defn) -> b2Body | source code
CreateJoint(...) b2World_CreateJoint(b2World self, b2JointDef defn) -> b2Joint | source code
DestroyBody(...) b2World_DestroyBody(b2World self, b2Body body) | source code
DestroyJoint(...) b2World_DestroyJoint(b2World self, b2Joint joint) | source code
Raycast(...) Raycast(b2Segment segment, b2Shape shapes, int32 maxCount, bool solidShapes, void $ignore) -> int32 b2World_Raycast(b2World self, b2Segment segment, int32 maxCount, bool solidShapes, PyObject $ignore) -> PyObject | source code
RaycastOne(...) RaycastOne(b2Segment segment, float32 _lambda, b2Vec2 normal, bool solidShapes, void $ignore) -> b2Shape b2World_RaycastOne(b2World self, b2Segment segment, bool solidShapes, PyObject $ignore) -> PyObject | source code
Query(...) Query(b2AABB aabb, b2Shape shapes, int32 maxCount) -> int32 b2World_Query(b2World self, b2AABB aabb, uint32 maxCount) -> PyObject | source code

Properties | [hide private]
| thisown The membership flag
| gravity GetGravity(self) -> b2Vec2
| jointList Get a list of the joints in this world
| bodyList Get a list of the bodies in this world
| groundBody GetGroundBody(self) -> b2Body
| worldAABB GetWorldAABB(self) -> b2AABB
| doSleep CanSleep(self) -> bool
| controllerList Get a list of the controllers in this world

Method Details | [hide private]

### __init__(self, *args) (Constructor) | source code
    __init__(self, b2AABB worldAABB, b2Vec2 gravity, bool doSleep) -> b2World

    Construct a world object.

    Parameters:
    -----------

    worldAABB: a bounding box that completely encompasses all your shapes.

    gravity: the world gravity vector.

    doSleep: improve performance by not simulating inactive bodies.
Overrides: object.__init__

### __swig_destroy__(...) |
delete_b2World(b2World self) Destruct the world. All physics entities are destroyed and all heap memory is released.

### __repr__(self) (Representation operator) | source code
Overrides: object.__repr__ (inherited documentation)

### SetDestructionListener(...) | source code
b2World_SetDestructionListener(b2World self, b2DestructionListener listener) Register a destruction listener.

### SetBoundaryListener(...) | source code
b2World_SetBoundaryListener(b2World self, b2BoundaryListener listener) Register a broad-phase boundary listener.

### SetContactFilter(...) | source code
b2World_SetContactFilter(b2World self, b2ContactFilter filter) Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter).

### SetContactListener(...) | source code
b2World_SetContactListener(b2World self, b2ContactListener listener) Register a contact event listener.

### SetDebugDraw(...) | source code
b2World_SetDebugDraw(b2World self, b2DebugDraw debugDraw) Register a routine for debug drawing. The debug draw functions are called inside the b2World::Stepmethod, so make sure your renderer is ready to consume draw commands when you call Step().

### CreateController(...) | source code
b2World_CreateController(b2World self, b2ControllerDef _def) -> b2Controller Add a controller to the world.

### DestroyController(...) | source code
b2World_DestroyController(b2World self, b2Controller controller) Removes a controller from the world.

### GetGroundBody(...) | source code
b2World_GetGroundBody(b2World self) -> b2Body The world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.

### Step(...) | source code
    b2World_Step(b2World self, float32 timeStep, int32 velocityIterations,
        int32 positionIterations)

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

    Parameters:
    -----------

    timeStep: the amount of time to simulate, this should not vary.

    velocityIterations: for the velocity constraint solver.

    positionIterations: for the position constraint solver.

### InRange(...) | source code
b2World_InRange(b2World self, b2AABB aabb) -> bool Check if the AABB is within the broadphase limits.

### _GetBodyList(...) | source code
b2World__GetBodyList(b2World self) -> b2Body Get the world body list. With the returned body, use b2Body::GetNextto get the next body in the world list. A NULL body indicates the end of the list. the head of the world body list.

### _GetJointList(...) | source code
b2World__GetJointList(b2World self) -> b2Joint Get the world joint list. With the returned joint, use b2Joint::GetNextto get the next joint in the world list. A NULL joint indicates the end of the list. the head of the world joint list.

### _GetControllerList(...) | source code
b2World__GetControllerList(b2World self) -> b2Controller Get the world controller list. With the returned controller, use b2Controller::GetNextto get the next controller in the world list. A NULL controller indicates the end of the list. the head of the world controller list.

### Refilter(...) | source code
b2World_Refilter(b2World self, b2Shape shape) Re-filter a shape. This re-runs contact filtering on a shape.

### SetWarmStarting(...) | source code
b2World_SetWarmStarting(b2World self, bool flag) Enable/disable warm starting. For testing.

### SetContinuousPhysics(...) | source code
b2World_SetContinuousPhysics(b2World self, bool flag) Enable/disable continuous physics. For testing.

### Validate(...) | source code
b2World_Validate(b2World self) Perform validation of internal data structures.

### GetProxyCount(...) | source code
b2World_GetProxyCount(b2World self) -> int32 Get the number of broad-phase proxies.

### GetPairCount(...) | source code
b2World_GetPairCount(b2World self) -> int32 Get the number of broad-phase pairs.

### GetBodyCount(...) | source code
b2World_GetBodyCount(b2World self) -> int32 Get the number of bodies.

### GetJointCount(...) | source code
b2World_GetJointCount(b2World self) -> int32 Get the number of joints.

### GetContactCount(...) | source code
b2World_GetContactCount(b2World self) -> int32 Get the number of contacts (each may have 0 or more contact points).

### GetControllerCount(...) | source code
b2World_GetControllerCount(b2World self) -> int32 Get the number of controllers.

### SetGravity(...) | source code
b2World_SetGravity(b2World self, b2Vec2 gravity) Change the global gravity vector.

### GetGravity(...) | source code
b2World_GetGravity(b2World self) -> b2Vec2 Get the global gravity vector.

### GetWorldAABB(...) | source code
b2World_GetWorldAABB(b2World self) -> b2AABB Get the world's AABB.

### CanSleep(...) | source code
b2World_CanSleep(b2World self) -> bool Whether or not bodies can sleep.

### CreateBody(...) | source code
b2World_CreateBody(b2World self, b2BodyDef defn) -> b2Body Create a rigid body given a definition. No reference to the definition is retained. WARNING: This function is locked during callbacks.

### CreateJoint(...) | source code
b2World_CreateJoint(b2World self, b2JointDef defn) -> b2Joint 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.

### DestroyBody(...) | source code
b2World_DestroyBody(b2World self, b2Body 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.

### DestroyJoint(...) | source code
b2World_DestroyJoint(b2World self, b2Joint joint) Destroy a joint. This may cause the connected bodies to begin colliding. WARNING: This function is locked during callbacks.

### Raycast(...) | source code
    Raycast(b2Segment segment, b2Shape shapes, int32 maxCount,
        bool solidShapes, void $ignore) -> int32
    b2World_Raycast(b2World self, b2Segment segment, int32 maxCount, bool solidShapes,
        PyObject $ignore) -> PyObject

    Query the world for all shapes that intersect a given segment. You provide a shape pointer buffer of specified size. The number of shapes found is returned, and the buffer is filled in order of intersection

    Parameters:
    -----------

    segment:
    defines the begin and end point of the ray cast, from p1 to p2. Use b2Segment.Extend to create (semi-)infinite rays

    shapes:
    a user allocated shape pointer array of size maxCount (or greater).

    maxCount:
    the capacity of the shapes array

    solidShapes:
    determines if shapes that the ray starts in are counted as hits.

    userData:
    passed through the worlds contact filter, with method RayCollide. This can be used to filter valid shapes

    the number of shapes found

### RaycastOne(...) | source code
    RaycastOne(b2Segment segment, float32 _lambda, b2Vec2 normal,
        bool solidShapes, void $ignore) -> b2Shape
    b2World_RaycastOne(b2World self, b2Segment segment, bool solidShapes,
        PyObject $ignore) -> PyObject

    Performs a raycast as with Raycast, finding the first intersecting shape.

    Parameters:
    -----------

    segment:
    defines the begin and end point of the ray cast, from p1 to p2. Use b2Segment.Extend to create (semi-)infinite rays

    lambda:
    returns the hit fraction. You can use this to compute the contact point p = (1 - lambda) * segment.p1 + lambda * segment.p2.

    normal:
    returns the normal at the contact point. If there is no intersection, the normal is not set.

    solidShapes:
    determines if shapes that the ray starts in are counted as hits.

    the colliding shape shape, or null if not found

### Query(...) | source code
    Query(b2AABB aabb, b2Shape shapes, int32 maxCount) -> int32
    b2World_Query(b2World self, b2AABB aabb, uint32 maxCount) -> PyObject

    Query the world for all shapes that potentially overlap the provided AABB. You provide a shape pointer buffer of specified size. The number of shapes found is returned.

    Parameters:
    -----------

    aabb: the query box.

    shapes: a user allocated shape pointer array of size maxCount (or greater).

    maxCount: the capacity of the shapes array.

    the number of shapes found in aabb.

Property Details | [hide private]

### thisown The membership flag

### gravity GetGravity(self) -> b2Vec2 Get the global gravity vector.

### jointList Get a list of the joints in this world Get Method: GetJointList(self) - Get a list of the joints in this world

### bodyList Get a list of the bodies in this world Get Method: GetBodyList(self) - Get a list of the bodies in this world

### groundBody GetGroundBody(self) -> b2Body The world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.

### worldAABB GetWorldAABB(self) -> b2AABB Get the world's AABB.

### doSleep CanSleep(self) -> bool Whether or not bodies can sleep.

### controllerList Get a list of the controllers in this world Get Method: GetControllerList(self) - Get a list of the controllers in this world