A rigid body. These are created via b2World::CreateBody. More...
#include <b2Body.h>
Public Member Functions | |
void | ApplyAngularImpulse (float32 impulse, bool wake) |
void | ApplyForce (const b2Vec2 &force, const b2Vec2 &point, bool wake) |
void | ApplyForceToCenter (const b2Vec2 &force, bool wake) |
void | ApplyLinearImpulse (const b2Vec2 &impulse, const b2Vec2 &point, bool wake) |
void | ApplyTorque (float32 torque, bool wake) |
b2Fixture * | CreateFixture (const b2FixtureDef *def) |
b2Fixture * | CreateFixture (const b2Shape *shape, float32 density) |
void | DestroyFixture (b2Fixture *fixture) |
void | Dump () |
Dump this body to a log file. More... | |
float32 | GetAngle () const |
float32 | GetAngularDamping () const |
Get the angular damping of the body. More... | |
float32 | GetAngularVelocity () const |
b2ContactEdge * | GetContactList () |
const b2ContactEdge * | GetContactList () const |
b2Fixture * | GetFixtureList () |
Get the list of all fixtures attached to this body. More... | |
const b2Fixture * | GetFixtureList () const |
float32 | GetGravityScale () const |
Get the gravity scale of the body. More... | |
float32 | GetInertia () const |
b2JointEdge * | GetJointList () |
Get the list of all joints attached to this body. More... | |
const b2JointEdge * | GetJointList () const |
float32 | GetLinearDamping () const |
Get the linear damping of the body. More... | |
const b2Vec2 & | GetLinearVelocity () const |
b2Vec2 | GetLinearVelocityFromLocalPoint (const b2Vec2 &localPoint) const |
b2Vec2 | GetLinearVelocityFromWorldPoint (const b2Vec2 &worldPoint) const |
const b2Vec2 & | GetLocalCenter () const |
Get the local position of the center of mass. More... | |
b2Vec2 | GetLocalPoint (const b2Vec2 &worldPoint) const |
b2Vec2 | GetLocalVector (const b2Vec2 &worldVector) const |
float32 | GetMass () const |
void | GetMassData (b2MassData *data) const |
b2Body * | GetNext () |
Get the next body in the world's body list. More... | |
const b2Body * | GetNext () const |
const b2Vec2 & | GetPosition () const |
const b2Transform & | GetTransform () const |
b2BodyType | GetType () const |
Get the type of this body. More... | |
void * | GetUserData () const |
Get the user data pointer that was provided in the body definition. More... | |
b2World * | GetWorld () |
Get the parent world of this body. More... | |
const b2World * | GetWorld () const |
const b2Vec2 & | GetWorldCenter () const |
Get the world position of the center of mass. More... | |
b2Vec2 | GetWorldPoint (const b2Vec2 &localPoint) const |
b2Vec2 | GetWorldVector (const b2Vec2 &localVector) const |
bool | IsActive () const |
Get the active state of the body. More... | |
bool | IsAwake () const |
bool | IsBullet () const |
Is this body treated like a bullet for continuous collision detection? More... | |
bool | IsFixedRotation () const |
Does this body have fixed rotation? More... | |
bool | IsSleepingAllowed () const |
Is this body allowed to sleep. More... | |
void | ResetMassData () |
void | SetActive (bool flag) |
void | SetAngularDamping (float32 angularDamping) |
Set the angular damping of the body. More... | |
void | SetAngularVelocity (float32 omega) |
void | SetAwake (bool flag) |
void | SetBullet (bool flag) |
Should this body be treated like a bullet for continuous collision detection? More... | |
void | SetFixedRotation (bool flag) |
void | SetGravityScale (float32 scale) |
Set the gravity scale of the body. More... | |
void | SetLinearDamping (float32 linearDamping) |
Set the linear damping of the body. More... | |
void | SetLinearVelocity (const b2Vec2 &v) |
void | SetMassData (const b2MassData *data) |
void | SetSleepingAllowed (bool flag) |
void | SetTransform (const b2Vec2 &position, float32 angle) |
void | SetType (b2BodyType type) |
Set the type of this body. This may alter the mass and velocity. More... | |
void | SetUserData (void *data) |
Set the user data. Use this to store your application specific data. More... | |
Private Types | |
enum | { e_islandFlag = 0x0001, e_awakeFlag = 0x0002, e_autoSleepFlag = 0x0004, e_bulletFlag = 0x0008, e_fixedRotationFlag = 0x0010, e_activeFlag = 0x0020, e_toiFlag = 0x0040 } |
Private Member Functions | |
void | Advance (float32 t) |
b2Body (const b2BodyDef *bd, b2World *world) | |
bool | ShouldCollide (const b2Body *other) const |
void | SynchronizeFixtures () |
void | SynchronizeTransform () |
~b2Body () | |
Friends | |
class | b2Contact |
class | b2ContactManager |
class | b2ContactSolver |
class | b2DistanceJoint |
class | b2FrictionJoint |
class | b2GearJoint |
class | b2Island |
class | b2MotorJoint |
class | b2MouseJoint |
class | b2PrismaticJoint |
class | b2PulleyJoint |
class | b2RevoluteJoint |
class | b2RopeJoint |
class | b2WeldJoint |
class | b2WheelJoint |
class | b2World |
A rigid body. These are created via b2World::CreateBody.
|
private |
Definition at line 25 of file b2Body.cpp.
|
private |
Definition at line 108 of file b2Body.cpp.
|
inline |
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.
force | the world force vector, usually in Newtons (N). |
point | the world position of the point of application. |
wake | also wake up the body |
|
inline |
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.
impulse | the world impulse vector, usually in N-seconds or kg-m/s. |
point | the world position of the point of application. |
wake | also wake up the body |
|
inline |
b2Fixture * b2Body::CreateFixture | ( | const b2FixtureDef * | def | ) |
Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step.
def | the fixture definition. |
Definition at line 166 of file b2Body.cpp.
Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body.
shape | the shape to be cloned. |
density | the shape density (set to zero for static bodies). |
Definition at line 205 of file b2Body.cpp.
void b2Body::DestroyFixture | ( | b2Fixture * | fixture | ) |
Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed.
fixture | the fixture to be removed. |
Definition at line 214 of file b2Body.cpp.
void b2Body::Dump | ( | ) |
Dump this body to a log file.
Definition at line 521 of file b2Body.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
Get the list of all contacts attached to this body.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void b2Body::ResetMassData | ( | ) |
This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass.
Definition at line 281 of file b2Body.cpp.
void b2Body::SetActive | ( | bool | flag | ) |
Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.
Definition at line 454 of file b2Body.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
void b2Body::SetFixedRotation | ( | bool | flag | ) |
Set this body to have fixed rotation. This causes the mass to be reset.
Definition at line 499 of file b2Body.cpp.
|
inline |
|
inline |
|
inline |
void b2Body::SetMassData | ( | const b2MassData * | data | ) |
Set the mass properties to override the mass properties of the fixtures. Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn't dynamic.
massData | the mass properties. |
Definition at line 353 of file b2Body.cpp.
|
inline |
Set the position of the body's origin and rotation. Manipulating a body's transform may cause non-physical behavior. Note: contacts are updated on the next call to b2World::Step.
position | the world position of the body's local origin. |
angle | the world rotation in radians. |
Definition at line 417 of file b2Body.cpp.
void b2Body::SetType | ( | b2BodyType | type | ) |
Set the type of this body. This may alter the mass and velocity.
Definition at line 113 of file b2Body.cpp.
|
inline |
|
private |
Definition at line 394 of file b2Body.cpp.
|
private |
Definition at line 441 of file b2Body.cpp.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |