A rigid body. These are created via b2World::CreateBody. More...
#include <b2_body.h>
Public Member Functions | |
void | ApplyAngularImpulse (float 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 | ApplyLinearImpulseToCenter (const b2Vec2 &impulse, bool wake) |
void | ApplyTorque (float torque, bool wake) |
b2Fixture * | CreateFixture (const b2FixtureDef *def) |
b2Fixture * | CreateFixture (const b2Shape *shape, float density) |
void | DestroyFixture (b2Fixture *fixture) |
void | Dump () |
Dump this body to a file. More... | |
float | GetAngle () const |
float | GetAngularDamping () const |
Get the angular damping of the body. More... | |
float | 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 |
float | GetGravityScale () const |
Get the gravity scale of the body. More... | |
float | GetInertia () const |
b2JointEdge * | GetJointList () |
Get the list of all joints attached to this body. More... | |
const b2JointEdge * | GetJointList () const |
float | 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 |
float | 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... | |
b2BodyUserData & | GetUserData () |
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 | IsAwake () const |
bool | IsBullet () const |
Is this body treated like a bullet for continuous collision detection? More... | |
bool | IsEnabled () const |
Get the active state of the body. More... | |
bool | IsFixedRotation () const |
Does this body have fixed rotation? More... | |
bool | IsSleepingAllowed () const |
Is this body allowed to sleep. More... | |
void | ResetMassData () |
void | SetAngularDamping (float angularDamping) |
Set the angular damping of the body. More... | |
void | SetAngularVelocity (float omega) |
void | SetAwake (bool flag) |
void | SetBullet (bool flag) |
Should this body be treated like a bullet for continuous collision detection? More... | |
void | SetEnabled (bool flag) |
void | SetFixedRotation (bool flag) |
void | SetGravityScale (float scale) |
Set the gravity scale of the body. More... | |
void | SetLinearDamping (float 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, float 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_enabledFlag = 0x0020, e_toiFlag = 0x0040 } |
Private Member Functions | |
void | Advance (float t) |
b2Body (const b2BodyDef *bd, b2World *world) | |
bool | ShouldCollide (const b2Body *other) const |
void | SynchronizeFixtures () |
void | SynchronizeTransform () |
~b2Body () | |
Private Attributes | |
float | m_angularDamping |
float | m_angularVelocity |
b2ContactEdge * | m_contactList |
int32 | m_fixtureCount |
b2Fixture * | m_fixtureList |
uint16 | m_flags |
b2Vec2 | m_force |
float | m_gravityScale |
float | m_I |
float | m_invI |
float | m_invMass |
int32 | m_islandIndex |
b2JointEdge * | m_jointList |
float | m_linearDamping |
b2Vec2 | m_linearVelocity |
float | m_mass |
b2Body * | m_next |
b2Body * | m_prev |
float | m_sleepTime |
b2Sweep | m_sweep |
float | m_torque |
b2BodyType | m_type |
b2BodyUserData | 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.
|
private |
Definition at line 31 of file b2_body.cpp.
|
private |
Definition at line 106 of file b2_body.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 |
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 165 of file b2_body.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 204 of file b2_body.cpp.
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 213 of file b2_body.cpp.
void b2Body::Dump | ( | ) |
Dump this body to a file.
Definition at line 534 of file b2_body.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 285 of file b2_body.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
void b2Body::SetEnabled | ( | bool | flag | ) |
Allow a body to be disabled. A disabled 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 disabled bodies. Fixtures on a disabled body are implicitly disabled and will not participate in collisions, ray-casts, or queries. Joints connected to a disabled body are implicitly disabled. An diabled body is still owned by a b2World object and remains in the body list.
Definition at line 466 of file b2_body.cpp.
void b2Body::SetFixedRotation | ( | bool | flag | ) |
Set this body to have fixed rotation. This causes the mass to be reset.
Definition at line 512 of file b2_body.cpp.
|
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.
data | the mass properties. |
Definition at line 351 of file b2_body.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 415 of file b2_body.cpp.
void b2Body::SetType | ( | b2BodyType | type | ) |
Set the type of this body. This may alter the mass and velocity.
Definition at line 111 of file b2_body.cpp.
Set the user data. Use this to store your application specific data.
|
private |
Definition at line 392 of file b2_body.cpp.
|
private |
Definition at line 442 of file b2_body.cpp.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |