#include <b2World.h>
Public Member Functions | |
b2World (const b2Vec2 &gravity) | |
void | ClearForces () |
b2Body * | CreateBody (const b2BodyDef *def) |
b2Joint * | CreateJoint (const b2JointDef *def) |
void | DestroyBody (b2Body *body) |
void | DestroyJoint (b2Joint *joint) |
void | DrawDebugData () |
Call this to draw shapes and other debug draw data. This is intentionally non-const. | |
void | Dump () |
bool | GetAllowSleeping () const |
bool | GetAutoClearForces () const |
Get the flag that controls automatic clearing of forces after each time step. | |
int32 | GetBodyCount () const |
Get the number of bodies. | |
b2Body * | GetBodyList () |
const b2Body * | GetBodyList () const |
int32 | GetContactCount () const |
Get the number of contacts (each may have 0 or more contact points). | |
b2Contact * | GetContactList () |
const b2Contact * | GetContactList () const |
const b2ContactManager & | GetContactManager () const |
Get the contact manager for testing. | |
bool | GetContinuousPhysics () const |
b2Vec2 | GetGravity () const |
Get the global gravity vector. | |
int32 | GetJointCount () const |
Get the number of joints. | |
b2Joint * | GetJointList () |
const b2Joint * | GetJointList () const |
const b2Profile & | GetProfile () const |
Get the current profile. | |
int32 | GetProxyCount () const |
Get the number of broad-phase proxies. | |
bool | GetSubStepping () const |
int32 | GetTreeBalance () const |
Get the balance of the dynamic tree. | |
int32 | GetTreeHeight () const |
Get the height of the dynamic tree. | |
float32 | GetTreeQuality () const |
bool | GetWarmStarting () const |
bool | IsLocked () const |
Is the world locked (in the middle of a time step). | |
void | QueryAABB (b2QueryCallback *callback, const b2AABB &aabb) const |
void | RayCast (b2RayCastCallback *callback, const b2Vec2 &point1, const b2Vec2 &point2) const |
void | SetAllowSleeping (bool flag) |
Enable/disable sleep. | |
void | SetAutoClearForces (bool flag) |
Set flag to control automatic clearing of forces after each time step. | |
void | SetContactFilter (b2ContactFilter *filter) |
void | SetContactListener (b2ContactListener *listener) |
void | SetContinuousPhysics (bool flag) |
Enable/disable continuous physics. For testing. | |
void | SetDebugDraw (b2Draw *debugDraw) |
void | SetDestructionListener (b2DestructionListener *listener) |
void | SetGravity (const b2Vec2 &gravity) |
Change the global gravity vector. | |
void | SetSubStepping (bool flag) |
Enable/disable single stepped continuous physics. For testing. | |
void | SetWarmStarting (bool flag) |
Enable/disable warm starting. For testing. | |
void | ShiftOrigin (const b2Vec2 &newOrigin) |
void | Step (float32 timeStep, int32 velocityIterations, int32 positionIterations) |
~b2World () | |
Destruct the world. All physics entities are destroyed and all heap memory is released. | |
Private Types | |
enum | { e_newFixture = 0x0001, e_locked = 0x0002, e_clearForces = 0x0004 } |
Private Member Functions | |
void | DrawJoint (b2Joint *joint) |
void | DrawShape (b2Fixture *shape, const b2Transform &xf, const b2Color &color) |
void | Solve (const b2TimeStep &step) |
void | SolveTOI (const b2TimeStep &step) |
Private Attributes | |
b2Draw * | g_debugDraw |
bool | m_allowSleep |
b2BlockAllocator | m_blockAllocator |
int32 | m_bodyCount |
b2Body * | m_bodyList |
b2ContactManager | m_contactManager |
bool | m_continuousPhysics |
b2DestructionListener * | m_destructionListener |
int32 | m_flags |
b2Vec2 | m_gravity |
float32 | m_inv_dt0 |
int32 | m_jointCount |
b2Joint * | m_jointList |
b2Profile | m_profile |
b2StackAllocator | m_stackAllocator |
bool | m_stepComplete |
bool | m_subStepping |
bool | m_warmStarting |
Friends | |
class | b2Body |
class | b2ContactManager |
class | b2Controller |
class | b2Fixture |
The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.
anonymous enum [private] |
b2World::b2World | ( | const b2Vec2 & | gravity | ) |
Construct a world object.
gravity | the world gravity vector. |
Definition at line 37 of file b2World.cpp.
Destruct the world. All physics entities are destroyed and all heap memory is released.
Definition at line 66 of file b2World.cpp.
void b2World::ClearForces | ( | ) |
Manually clear the force buffer on all bodies. By default, forces are cleared automatically after each call to Step. The default behavior is modified by calling SetAutoClearForces. The purpose of this function is to support sub-stepping. Sub-stepping is often used to maintain a fixed sized time step under a variable frame-rate. When you perform sub-stepping you will disable auto clearing of forces and instead call ClearForces after all sub-steps are complete in one pass of your game loop.
Definition at line 965 of file b2World.cpp.
b2Body * b2World::CreateBody | ( | const b2BodyDef * | def | ) |
Create a rigid body given a definition. No reference to the definition is retained.
Definition at line 107 of file b2World.cpp.
b2Joint * b2World::CreateJoint | ( | const b2JointDef * | def | ) |
Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding.
Definition at line 212 of file b2World.cpp.
void b2World::DestroyBody | ( | b2Body * | body | ) |
Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.
Definition at line 131 of file b2World.cpp.
void b2World::DestroyJoint | ( | b2Joint * | joint | ) |
Destroy a joint. This may cause the connected bodies to begin colliding.
Definition at line 272 of file b2World.cpp.
void b2World::DrawDebugData | ( | ) |
Call this to draw shapes and other debug draw data. This is intentionally non-const.
Definition at line 1135 of file b2World.cpp.
void b2World::DrawJoint | ( | b2Joint * | joint | ) | [private] |
Definition at line 1094 of file b2World.cpp.
void b2World::DrawShape | ( | b2Fixture * | shape, |
const b2Transform & | xf, | ||
const b2Color & | color | ||
) | [private] |
Definition at line 1031 of file b2World.cpp.
void b2World::Dump | ( | ) |
Dump the world into the log file.
Definition at line 1282 of file b2World.cpp.
bool b2World::GetAllowSleeping | ( | ) | const [inline] |
bool b2World::GetAutoClearForces | ( | ) | const [inline] |
int32 b2World::GetBodyCount | ( | ) | const [inline] |
b2Body * b2World::GetBodyList | ( | ) | [inline] |
Get the world body list. With the returned body, use b2Body::GetNext to get the next body in the world list. A NULL body indicates the end of the list.
const b2Body * b2World::GetBodyList | ( | ) | const [inline] |
int32 b2World::GetContactCount | ( | ) | const [inline] |
b2Contact * b2World::GetContactList | ( | ) | [inline] |
Get the world contact list. With the returned contact, use b2Contact::GetNext to get the next contact in the world list. A NULL contact indicates the end of the list.
const b2Contact * b2World::GetContactList | ( | ) | const [inline] |
const b2ContactManager & b2World::GetContactManager | ( | ) | const [inline] |
bool b2World::GetContinuousPhysics | ( | ) | const [inline] |
b2Vec2 b2World::GetGravity | ( | ) | const [inline] |
int32 b2World::GetJointCount | ( | ) | const [inline] |
b2Joint * b2World::GetJointList | ( | ) | [inline] |
Get the world joint list. With the returned joint, use b2Joint::GetNext to get the next joint in the world list. A NULL joint indicates the end of the list.
const b2Joint * b2World::GetJointList | ( | ) | const [inline] |
const b2Profile & b2World::GetProfile | ( | ) | const [inline] |
int32 b2World::GetProxyCount | ( | ) | const |
Get the number of broad-phase proxies.
Definition at line 1239 of file b2World.cpp.
bool b2World::GetSubStepping | ( | ) | const [inline] |
int32 b2World::GetTreeBalance | ( | ) | const |
Get the balance of the dynamic tree.
Definition at line 1249 of file b2World.cpp.
int32 b2World::GetTreeHeight | ( | ) | const |
Get the height of the dynamic tree.
Definition at line 1244 of file b2World.cpp.
float32 b2World::GetTreeQuality | ( | ) | const |
Get the quality metric of the dynamic tree. The smaller the better. The minimum is 1.
Definition at line 1254 of file b2World.cpp.
bool b2World::GetWarmStarting | ( | ) | const [inline] |
bool b2World::IsLocked | ( | ) | const [inline] |
void b2World::QueryAABB | ( | b2QueryCallback * | callback, |
const b2AABB & | aabb | ||
) | const |
Query the world for all fixtures that potentially overlap the provided AABB.
callback | a user implemented callback class. |
aabb | the query box. |
Definition at line 986 of file b2World.cpp.
void b2World::RayCast | ( | b2RayCastCallback * | callback, |
const b2Vec2 & | point1, | ||
const b2Vec2 & | point2 | ||
) | const |
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.
callback | a user implemented callback class. |
point1 | the ray starting point |
point2 | the ray ending point |
Definition at line 1019 of file b2World.cpp.
void b2World::SetAllowSleeping | ( | bool | flag | ) |
Enable/disable sleep.
Definition at line 368 of file b2World.cpp.
void b2World::SetAutoClearForces | ( | bool | flag | ) | [inline] |
void b2World::SetContactFilter | ( | b2ContactFilter * | filter | ) |
Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter). The listener is owned by you and must remain in scope.
Definition at line 92 of file b2World.cpp.
void b2World::SetContactListener | ( | b2ContactListener * | listener | ) |
Register a contact event listener. The listener is owned by you and must remain in scope.
Definition at line 97 of file b2World.cpp.
void b2World::SetContinuousPhysics | ( | bool | flag | ) | [inline] |
void b2World::SetDebugDraw | ( | b2Draw * | debugDraw | ) |
Register a routine for debug drawing. The debug draw functions are called inside with b2World::DrawDebugData method. The debug draw object is owned by you and must remain in scope.
Definition at line 102 of file b2World.cpp.
void b2World::SetDestructionListener | ( | b2DestructionListener * | listener | ) |
Register a destruction listener. The listener is owned by you and must remain in scope.
Definition at line 87 of file b2World.cpp.
void b2World::SetGravity | ( | const b2Vec2 & | gravity | ) | [inline] |
void b2World::SetSubStepping | ( | bool | flag | ) | [inline] |
void b2World::SetWarmStarting | ( | bool | flag | ) | [inline] |
void b2World::ShiftOrigin | ( | const b2Vec2 & | newOrigin | ) |
Shift the world origin. Useful for large worlds. The body shift formula is: position -= newOrigin
newOrigin | the new origin with respect to the old origin |
Definition at line 1259 of file b2World.cpp.
void b2World::Solve | ( | const b2TimeStep & | step | ) | [private] |
Definition at line 386 of file b2World.cpp.
void b2World::SolveTOI | ( | const b2TimeStep & | step | ) | [private] |
Definition at line 577 of file b2World.cpp.
void b2World::Step | ( | float32 | timeStep, |
int32 | velocityIterations, | ||
int32 | positionIterations | ||
) |
Take a time step. This performs collision detection, integration, and constraint solution.
timeStep | the amount of time to simulate, this should not vary. |
velocityIterations | for the velocity constraint solver. |
positionIterations | for the position constraint solver. |
Definition at line 897 of file b2World.cpp.
friend class b2ContactManager [friend] |
friend class b2Controller [friend] |
b2Draw* b2World::g_debugDraw [private] |
bool b2World::m_allowSleep [private] |
b2BlockAllocator b2World::m_blockAllocator [private] |
int32 b2World::m_bodyCount [private] |
b2Body* b2World::m_bodyList [private] |
b2ContactManager b2World::m_contactManager [private] |
bool b2World::m_continuousPhysics [private] |
int32 b2World::m_flags [private] |
b2Vec2 b2World::m_gravity [private] |
float32 b2World::m_inv_dt0 [private] |
int32 b2World::m_jointCount [private] |
b2Joint* b2World::m_jointList [private] |
b2Profile b2World::m_profile [private] |
b2StackAllocator b2World::m_stackAllocator [private] |
bool b2World::m_stepComplete [private] |
bool b2World::m_subStepping [private] |
bool b2World::m_warmStarting [private] |