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. | |
float32 | GetAngle () const |
float32 | GetAngularDamping () const |
Get the angular damping of the body. | |
float32 | GetAngularVelocity () const |
b2ContactEdge * | GetContactList () |
const b2ContactEdge * | GetContactList () const |
b2Fixture * | GetFixtureList () |
Get the list of all fixtures attached to this body. | |
const b2Fixture * | GetFixtureList () const |
float32 | GetGravityScale () const |
Get the gravity scale of the body. | |
float32 | GetInertia () const |
b2JointEdge * | GetJointList () |
Get the list of all joints attached to this body. | |
const b2JointEdge * | GetJointList () const |
float32 | GetLinearDamping () const |
Get the linear damping of the body. | |
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. | |
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. | |
const b2Body * | GetNext () const |
const b2Vec2 & | GetPosition () const |
const b2Transform & | GetTransform () const |
b2BodyType | GetType () const |
Get the type of this body. | |
void * | GetUserData () const |
Get the user data pointer that was provided in the body definition. | |
b2World * | GetWorld () |
Get the parent world of this body. | |
const b2World * | GetWorld () const |
const b2Vec2 & | GetWorldCenter () const |
Get the world position of the center of mass. | |
b2Vec2 | GetWorldPoint (const b2Vec2 &localPoint) const |
b2Vec2 | GetWorldVector (const b2Vec2 &localVector) const |
bool | IsActive () const |
Get the active state of the body. | |
bool | IsAwake () const |
bool | IsBullet () const |
Is this body treated like a bullet for continuous collision detection? | |
bool | IsFixedRotation () const |
Does this body have fixed rotation? | |
bool | IsSleepingAllowed () const |
Is this body allowed to sleep. | |
void | ResetMassData () |
void | SetActive (bool flag) |
void | SetAngularDamping (float32 angularDamping) |
Set the angular damping of the body. | |
void | SetAngularVelocity (float32 omega) |
void | SetAwake (bool flag) |
void | SetBullet (bool flag) |
Should this body be treated like a bullet for continuous collision detection? | |
void | SetFixedRotation (bool flag) |
void | SetGravityScale (float32 scale) |
Set the gravity scale of the body. | |
void | SetLinearDamping (float32 linearDamping) |
Set the linear damping of the body. | |
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. | |
void | SetUserData (void *data) |
Set the user data. Use this to store your application specific data. | |
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 () | |
Private Attributes | |
float32 | m_angularDamping |
float32 | m_angularVelocity |
b2ContactEdge * | m_contactList |
int32 | m_fixtureCount |
b2Fixture * | m_fixtureList |
uint16 | m_flags |
b2Vec2 | m_force |
float32 | m_gravityScale |
float32 | m_I |
float32 | m_invI |
float32 | m_invMass |
int32 | m_islandIndex |
b2JointEdge * | m_jointList |
float32 | m_linearDamping |
b2Vec2 | m_linearVelocity |
float32 | m_mass |
b2Body * | m_next |
b2Body * | m_prev |
float32 | m_sleepTime |
b2Sweep | m_sweep |
float32 | m_torque |
b2BodyType | m_type |
void * | m_userData |
b2World * | m_world |
b2Transform | m_xf |
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.
anonymous enum [private] |
b2Body::b2Body | ( | const b2BodyDef * | bd, |
b2World * | world | ||
) | [private] |
Definition at line 25 of file b2Body.cpp.
b2Body::~b2Body | ( | ) | [private] |
Definition at line 108 of file b2Body.cpp.
void b2Body::Advance | ( | float32 | t | ) | [inline, private] |
void b2Body::ApplyAngularImpulse | ( | float32 | impulse, |
bool | wake | ||
) | [inline] |
void b2Body::ApplyForce | ( | const b2Vec2 & | force, |
const b2Vec2 & | point, | ||
bool | wake | ||
) | [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 |
void b2Body::ApplyForceToCenter | ( | const b2Vec2 & | force, |
bool | wake | ||
) | [inline] |
void b2Body::ApplyLinearImpulse | ( | const b2Vec2 & | impulse, |
const b2Vec2 & | point, | ||
bool | wake | ||
) | [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 |
void b2Body::ApplyTorque | ( | float32 | torque, |
bool | wake | ||
) | [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.
b2Fixture * b2Body::CreateFixture | ( | const b2Shape * | shape, |
float32 | density | ||
) |
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.
float32 b2Body::GetAngle | ( | ) | const [inline] |
float32 b2Body::GetAngularDamping | ( | ) | const [inline] |
float32 b2Body::GetAngularVelocity | ( | ) | const [inline] |
b2ContactEdge * b2Body::GetContactList | ( | ) | [inline] |
Get the list of all contacts attached to this body.
const b2ContactEdge * b2Body::GetContactList | ( | ) | const [inline] |
b2Fixture * b2Body::GetFixtureList | ( | ) | [inline] |
const b2Fixture * b2Body::GetFixtureList | ( | ) | const [inline] |
float32 b2Body::GetGravityScale | ( | ) | const [inline] |
float32 b2Body::GetInertia | ( | ) | const [inline] |
b2JointEdge * b2Body::GetJointList | ( | ) | [inline] |
const b2JointEdge * b2Body::GetJointList | ( | ) | const [inline] |
float32 b2Body::GetLinearDamping | ( | ) | const [inline] |
const b2Vec2 & b2Body::GetLinearVelocity | ( | ) | const [inline] |
b2Vec2 b2Body::GetLinearVelocityFromLocalPoint | ( | const b2Vec2 & | localPoint | ) | const [inline] |
b2Vec2 b2Body::GetLinearVelocityFromWorldPoint | ( | const b2Vec2 & | worldPoint | ) | const [inline] |
const b2Vec2 & b2Body::GetLocalCenter | ( | ) | const [inline] |
b2Vec2 b2Body::GetLocalPoint | ( | const b2Vec2 & | worldPoint | ) | const [inline] |
b2Vec2 b2Body::GetLocalVector | ( | const b2Vec2 & | worldVector | ) | const [inline] |
float32 b2Body::GetMass | ( | ) | const [inline] |
void b2Body::GetMassData | ( | b2MassData * | data | ) | const [inline] |
b2Body * b2Body::GetNext | ( | ) | [inline] |
const b2Body * b2Body::GetNext | ( | ) | const [inline] |
const b2Vec2 & b2Body::GetPosition | ( | ) | const [inline] |
const b2Transform & b2Body::GetTransform | ( | ) | const [inline] |
b2BodyType b2Body::GetType | ( | ) | const [inline] |
void * b2Body::GetUserData | ( | ) | const [inline] |
b2World * b2Body::GetWorld | ( | ) | [inline] |
const b2World * b2Body::GetWorld | ( | ) | const [inline] |
const b2Vec2 & b2Body::GetWorldCenter | ( | ) | const [inline] |
b2Vec2 b2Body::GetWorldPoint | ( | const b2Vec2 & | localPoint | ) | const [inline] |
b2Vec2 b2Body::GetWorldVector | ( | const b2Vec2 & | localVector | ) | const [inline] |
bool b2Body::IsActive | ( | ) | const [inline] |
bool b2Body::IsAwake | ( | ) | const [inline] |
bool b2Body::IsBullet | ( | ) | const [inline] |
bool b2Body::IsFixedRotation | ( | ) | const [inline] |
bool b2Body::IsSleepingAllowed | ( | ) | const [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.
void b2Body::SetAngularDamping | ( | float32 | angularDamping | ) | [inline] |
void b2Body::SetAngularVelocity | ( | float32 | omega | ) | [inline] |
void b2Body::SetAwake | ( | bool | flag | ) | [inline] |
void b2Body::SetBullet | ( | bool | flag | ) | [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.
void b2Body::SetGravityScale | ( | float32 | scale | ) | [inline] |
void b2Body::SetLinearDamping | ( | float32 | linearDamping | ) | [inline] |
void b2Body::SetLinearVelocity | ( | const b2Vec2 & | v | ) | [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.
void b2Body::SetSleepingAllowed | ( | bool | flag | ) | [inline] |
void b2Body::SetTransform | ( | const b2Vec2 & | position, |
float32 | angle | ||
) |
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.
void b2Body::SetUserData | ( | void * | data | ) | [inline] |
bool b2Body::ShouldCollide | ( | const b2Body * | other | ) | const [private] |
Definition at line 394 of file b2Body.cpp.
void b2Body::SynchronizeFixtures | ( | ) | [private] |
Definition at line 441 of file b2Body.cpp.
void b2Body::SynchronizeTransform | ( | ) | [inline, private] |
friend class b2ContactManager [friend] |
friend class b2ContactSolver [friend] |
friend class b2DistanceJoint [friend] |
friend class b2FrictionJoint [friend] |
friend class b2GearJoint [friend] |
friend class b2MotorJoint [friend] |
friend class b2MouseJoint [friend] |
friend class b2PrismaticJoint [friend] |
friend class b2PulleyJoint [friend] |
friend class b2RevoluteJoint [friend] |
friend class b2RopeJoint [friend] |
friend class b2WeldJoint [friend] |
friend class b2WheelJoint [friend] |
float32 b2Body::m_angularDamping [private] |
float32 b2Body::m_angularVelocity [private] |
b2ContactEdge* b2Body::m_contactList [private] |
int32 b2Body::m_fixtureCount [private] |
b2Fixture* b2Body::m_fixtureList [private] |
uint16 b2Body::m_flags [private] |
b2Vec2 b2Body::m_force [private] |
float32 b2Body::m_gravityScale [private] |
float32 b2Body::m_I [private] |
float32 b2Body::m_invI [private] |
float32 b2Body::m_invMass [private] |
int32 b2Body::m_islandIndex [private] |
b2JointEdge* b2Body::m_jointList [private] |
float32 b2Body::m_linearDamping [private] |
b2Vec2 b2Body::m_linearVelocity [private] |
float32 b2Body::m_mass [private] |
b2Body* b2Body::m_next [private] |
b2Body* b2Body::m_prev [private] |
float32 b2Body::m_sleepTime [private] |
b2Sweep b2Body::m_sweep [private] |
float32 b2Body::m_torque [private] |
b2BodyType b2Body::m_type [private] |
void* b2Body::m_userData [private] |
b2World* b2Body::m_world [private] |
b2Transform b2Body::m_xf [private] |