|  | Box2D
    2.3.0
    A 2D Physics Engine for Games | 
 
 
 
   22 #include <Box2D/Common/b2Math.h> 
   23 #include <Box2D/Collision/Shapes/b2Shape.h> 
  409         e_islandFlag        = 0x0001,
 
  410         e_awakeFlag         = 0x0002,
 
  411         e_autoSleepFlag     = 0x0004,
 
  412         e_bulletFlag        = 0x0008,
 
  413         e_fixedRotationFlag = 0x0010,
 
  414         e_activeFlag        = 0x0020,
 
  421     void SynchronizeFixtures();
 
  422     void SynchronizeTransform();
 
  426     bool ShouldCollide(
const b2Body* other) 
const;
 
  428     void Advance(float32 t);
 
  440     float32 m_angularVelocity;
 
  450     int32 m_fixtureCount;
 
  455     float32 m_mass, m_invMass;
 
  460     float32 m_linearDamping;
 
  461     float32 m_angularDamping;
 
  462     float32 m_gravityScale;
 
  501     if (m_type == b2_staticBody)
 
  506     if (b2Dot(v,v) > 0.0f)
 
  511     m_linearVelocity = v;
 
  516     return m_linearVelocity;
 
  521     if (m_type == b2_staticBody)
 
  531     m_angularVelocity = w;
 
  536     return m_angularVelocity;
 
  558     return b2Mul(m_xf, localPoint);
 
  563     return b2Mul(m_xf.q, localVector);
 
  568     return b2MulT(m_xf, worldPoint);
 
  573     return b2MulT(m_xf.q, worldVector);
 
  578     return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.
c);
 
  588     return m_linearDamping;
 
  593     m_linearDamping = linearDamping;
 
  598     return m_angularDamping;
 
  603     m_angularDamping = angularDamping;
 
  608     return m_gravityScale;
 
  613     m_gravityScale = scale;
 
  620         m_flags |= e_bulletFlag;
 
  624         m_flags &= ~e_bulletFlag;
 
  630     return (m_flags & e_bulletFlag) == e_bulletFlag;
 
  637         if ((m_flags & e_awakeFlag) == 0)
 
  639             m_flags |= e_awakeFlag;
 
  645         m_flags &= ~e_awakeFlag;
 
  648         m_angularVelocity = 0.0f;
 
  656     return (m_flags & e_awakeFlag) == e_awakeFlag;
 
  661     return (m_flags & e_activeFlag) == e_activeFlag;
 
  666     return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
 
  673         m_flags |= e_autoSleepFlag;
 
  677         m_flags &= ~e_autoSleepFlag;
 
  684     return (m_flags & e_autoSleepFlag) == e_autoSleepFlag;
 
  689     return m_fixtureList;
 
  694     return m_fixtureList;
 
  709     return m_contactList;
 
  714     return m_contactList;
 
  739     if (m_type != b2_dynamicBody)
 
  744     if (wake && (m_flags & e_awakeFlag) == 0)
 
  750     if (m_flags & e_awakeFlag)
 
  753         m_torque += b2Cross(point - m_sweep.
c, force);
 
  759     if (m_type != b2_dynamicBody)
 
  764     if (wake && (m_flags & e_awakeFlag) == 0)
 
  770     if (m_flags & e_awakeFlag)
 
  778     if (m_type != b2_dynamicBody)
 
  783     if (wake && (m_flags & e_awakeFlag) == 0)
 
  789     if (m_flags & e_awakeFlag)
 
  797     if (m_type != b2_dynamicBody)
 
  802     if (wake && (m_flags & e_awakeFlag) == 0)
 
  808     if (m_flags & e_awakeFlag)
 
  810         m_linearVelocity += m_invMass * impulse;
 
  811         m_angularVelocity += m_invI * b2Cross(point - m_sweep.
c, impulse);
 
  817     if (m_type != b2_dynamicBody)
 
  822     if (wake && (m_flags & e_awakeFlag) == 0)
 
  828     if (m_flags & e_awakeFlag)
 
  830         m_angularVelocity += m_invI * impulse;
 
  834 inline void b2Body::SynchronizeTransform()
 
  836     m_xf.q.
Set(m_sweep.
a);
 
  837     m_xf.p = m_sweep.
c - b2Mul(m_xf.q, m_sweep.
localCenter);
 
  840 inline void b2Body::Advance(float32 alpha)
 
  844     m_sweep.
c = m_sweep.c0;
 
  845     m_sweep.
a = m_sweep.a0;
 
  846     m_xf.q.
Set(m_sweep.
a);
 
  847     m_xf.p = m_sweep.
c - b2Mul(m_xf.q, m_sweep.
localCenter);
 
  
A 2D column vector.
Definition: b2Math.h:53
Definition: b2FrictionJoint.h:55
bool IsAwake() const
Definition: b2Body.h:654
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
void GetMassData(b2MassData *data) const
Definition: b2Body.h:549
void SetBullet(bool flag)
Should this body be treated like a bullet for continuous collision detection?
Definition: b2Body.h:616
b2Fixture * GetFixtureList()
Get the list of all fixtures attached to this body.
Definition: b2Body.h:687
Definition: b2DistanceJoint.h:67
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:65
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition: b2Body.h:566
const b2Transform & GetTransform() const
Definition: b2Body.h:474
b2JointEdge * GetJointList()
Get the list of all joints attached to this body.
Definition: b2Body.h:697
b2BodyType GetType() const
Get the type of this body.
Definition: b2Body.h:469
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition: b2Body.h:556
b2Body * GetNext()
Get the next body in the world's body list.
Definition: b2Body.h:717
float32 GetAngularVelocity() const
Definition: b2Body.h:534
b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2 &worldPoint) const
Definition: b2Body.h:576
Definition: b2PrismaticJoint.h:86
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition: b2Body.h:107
float32 angularVelocity
The angular velocity of the body.
Definition: b2Body.h:87
b2BodyDef()
This constructor sets the body definition default values.
Definition: b2Body.h:54
const b2Vec2 & GetLinearVelocity() const
Definition: b2Body.h:514
void SetType(b2BodyType type)
Set the type of this body. This may alter the mass and velocity.
Definition: b2Body.cpp:113
b2Vec2 GetLocalVector(const b2Vec2 &worldVector) const
Definition: b2Body.h:571
b2Vec2 c
center world positions
Definition: b2Math.h:394
void * userData
Use this to store application specific body data.
Definition: b2Body.h:119
Definition: b2WheelJoint.h:79
void SetSleepingAllowed(bool flag)
Definition: b2Body.h:669
float32 GetAngularDamping() const
Get the angular damping of the body.
Definition: b2Body.h:596
float32 angularDamping
Definition: b2Body.h:97
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
Definition: b2Body.h:628
bool IsSleepingAllowed() const
Is this body allowed to sleep.
Definition: b2Body.h:682
void * GetUserData() const
Get the user data pointer that was provided in the body definition.
Definition: b2Body.h:732
void SetGravityScale(float32 scale)
Set the gravity scale of the body.
Definition: b2Body.h:611
Definition: b2Fixture.h:56
Definition: b2WeldJoint.h:62
void SetLinearVelocity(const b2Vec2 &v)
Definition: b2Body.h:499
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
Definition: b2Body.h:561
void Set(float32 angle)
Set using an angle in radians.
Definition: b2Math.h:312
void Dump()
Dump this body to a log file.
Definition: b2Body.cpp:521
void SetUserData(void *data)
Set the user data. Use this to store your application specific data.
Definition: b2Body.h:727
b2BodyType type
Definition: b2Body.h:74
b2World * GetWorld()
Get the parent world of this body.
Definition: b2Body.h:850
Definition: b2Fixture.h:107
b2Vec2 linearVelocity
The linear velocity of the body's origin in world co-ordinates.
Definition: b2Body.h:84
bool bullet
Definition: b2Body.h:113
void SetLinearDamping(float32 linearDamping)
Set the linear damping of the body.
Definition: b2Body.h:591
float32 GetInertia() const
Definition: b2Body.h:544
float32 mass
The mass of the shape, usually in kilograms.
Definition: b2Shape.h:30
void SetActive(bool flag)
Definition: b2Body.cpp:454
Definition: b2RevoluteJoint.h:90
const b2Vec2 & GetWorldCenter() const
Get the world position of the center of mass.
Definition: b2Body.h:489
bool awake
Is this body initially awake or sleeping?
Definition: b2Body.h:104
bool allowSleep
Definition: b2Body.h:101
void SetAngularVelocity(float32 omega)
Definition: b2Body.h:519
float32 GetMass() const
Definition: b2Body.h:539
void ApplyAngularImpulse(float32 impulse, bool wake)
Definition: b2Body.h:815
b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2 &localPoint) const
Definition: b2Body.h:581
float32 GetGravityScale() const
Get the gravity scale of the body.
Definition: b2Body.h:606
b2ContactEdge * GetContactList()
Definition: b2Body.h:707
Definition: b2MotorJoint.h:59
void Advance(float32 alpha)
Definition: b2Math.h:702
void SetTransform(const b2Vec2 &position, float32 angle)
Definition: b2Body.cpp:417
void SetAngularDamping(float32 angularDamping)
Set the angular damping of the body.
Definition: b2Body.h:601
void DestroyFixture(b2Fixture *fixture)
Definition: b2Body.cpp:214
void ApplyTorque(float32 torque, bool wake)
Definition: b2Body.h:776
b2Fixture * CreateFixture(const b2FixtureDef *def)
Definition: b2Body.cpp:166
float32 linearDamping
Definition: b2Body.h:92
float32 GetAngle() const
Definition: b2Body.h:484
bool IsFixedRotation() const
Does this body have fixed rotation?
Definition: b2Body.h:664
float32 I
The rotational inertia of the shape about the local origin.
Definition: b2Shape.h:36
void ApplyLinearImpulse(const b2Vec2 &impulse, const b2Vec2 &point, bool wake)
Definition: b2Body.h:795
Definition: b2GearJoint.h:56
bool IsActive() const
Get the active state of the body.
Definition: b2Body.h:659
Definition: b2RopeJoint.h:58
float32 angle
The world angle of the body in radians.
Definition: b2Body.h:81
This holds the mass data computed for a shape.
Definition: b2Shape.h:27
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
Definition: b2Shape.h:33
void SetAwake(bool flag)
Definition: b2Body.h:633
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:62
void SetMassData(const b2MassData *data)
Definition: b2Body.cpp:353
Definition: b2MouseJoint.h:60
void SetFixedRotation(bool flag)
Definition: b2Body.cpp:499
Definition: b2Joint.h:103
const b2Vec2 & GetLocalCenter() const
Get the local position of the center of mass.
Definition: b2Body.h:494
b2Vec2 localCenter
local center of mass position
Definition: b2Math.h:393
bool active
Does this body start out active?
Definition: b2Body.h:116
float32 a
world angles
Definition: b2Math.h:395
void ResetMassData()
Definition: b2Body.cpp:281
const b2Vec2 & GetPosition() const
Definition: b2Body.h:479
This is an internal class.
Definition: b2Island.h:34
float32 GetLinearDamping() const
Get the linear damping of the body.
Definition: b2Body.h:586
void ApplyForce(const b2Vec2 &force, const b2Vec2 &point, bool wake)
Definition: b2Body.h:737
Definition: b2PulleyJoint.h:79
b2Vec2 position
Definition: b2Body.h:78
float32 gravityScale
Scale the gravity applied to this body.
Definition: b2Body.h:122
void ApplyForceToCenter(const b2Vec2 &force, bool wake)
Definition: b2Body.h:757