Box2D  2.4.0
A 2D physics engine for games
b2_body.h
1 // MIT License
2 
3 // Copyright (c) 2019 Erin Catto
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef B2_BODY_H
24 #define B2_BODY_H
25 
26 #include "b2_math.h"
27 #include "b2_shape.h"
28 
29 class b2Fixture;
30 class b2Joint;
31 class b2Contact;
32 class b2Controller;
33 class b2World;
34 struct b2FixtureDef;
35 struct b2JointEdge;
36 struct b2ContactEdge;
37 
42 enum b2BodyType
43 {
44  b2_staticBody = 0,
45  b2_kinematicBody,
46  b2_dynamicBody
47 
48  // TODO_ERIN
49  //b2_bulletBody,
50 };
51 
54 struct b2BodyDef
55 {
58  {
59  userData = nullptr;
60  position.Set(0.0f, 0.0f);
61  angle = 0.0f;
62  linearVelocity.Set(0.0f, 0.0f);
63  angularVelocity = 0.0f;
64  linearDamping = 0.0f;
65  angularDamping = 0.0f;
66  allowSleep = true;
67  awake = true;
68  fixedRotation = false;
69  bullet = false;
70  type = b2_staticBody;
71  active = true;
72  gravityScale = 1.0f;
73  }
74 
77  b2BodyType type;
78 
82 
84  float angle;
85 
88 
91 
97 
103 
107 
109  bool awake;
110 
113 
118  bool bullet;
119 
121  bool active;
122 
124  void* userData;
125 
128 };
129 
131 class b2Body
132 {
133 public:
141  b2Fixture* CreateFixture(const b2FixtureDef* def);
142 
150  b2Fixture* CreateFixture(const b2Shape* shape, float density);
151 
159  void DestroyFixture(b2Fixture* fixture);
160 
166  void SetTransform(const b2Vec2& position, float angle);
167 
170  const b2Transform& GetTransform() const;
171 
174  const b2Vec2& GetPosition() const;
175 
178  float GetAngle() const;
179 
181  const b2Vec2& GetWorldCenter() const;
182 
184  const b2Vec2& GetLocalCenter() const;
185 
188  void SetLinearVelocity(const b2Vec2& v);
189 
192  const b2Vec2& GetLinearVelocity() const;
193 
196  void SetAngularVelocity(float omega);
197 
200  float GetAngularVelocity() const;
201 
208  void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake);
209 
213  void ApplyForceToCenter(const b2Vec2& force, bool wake);
214 
219  void ApplyTorque(float torque, bool wake);
220 
227  void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
228 
232  void ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake);
233 
237  void ApplyAngularImpulse(float impulse, bool wake);
238 
241  float GetMass() const;
242 
245  float GetInertia() const;
246 
249  void GetMassData(b2MassData* data) const;
250 
256  void SetMassData(const b2MassData* data);
257 
261  void ResetMassData();
262 
266  b2Vec2 GetWorldPoint(const b2Vec2& localPoint) const;
267 
271  b2Vec2 GetWorldVector(const b2Vec2& localVector) const;
272 
276  b2Vec2 GetLocalPoint(const b2Vec2& worldPoint) const;
277 
281  b2Vec2 GetLocalVector(const b2Vec2& worldVector) const;
282 
286  b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const;
287 
291  b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const;
292 
294  float GetLinearDamping() const;
295 
297  void SetLinearDamping(float linearDamping);
298 
300  float GetAngularDamping() const;
301 
303  void SetAngularDamping(float angularDamping);
304 
306  float GetGravityScale() const;
307 
309  void SetGravityScale(float scale);
310 
312  void SetType(b2BodyType type);
313 
315  b2BodyType GetType() const;
316 
318  void SetBullet(bool flag);
319 
321  bool IsBullet() const;
322 
325  void SetSleepingAllowed(bool flag);
326 
328  bool IsSleepingAllowed() const;
329 
333  void SetAwake(bool flag);
334 
337  bool IsAwake() const;
338 
352  void SetActive(bool flag);
353 
355  bool IsActive() const;
356 
359  void SetFixedRotation(bool flag);
360 
362  bool IsFixedRotation() const;
363 
366  const b2Fixture* GetFixtureList() const;
367 
370  const b2JointEdge* GetJointList() const;
371 
376  const b2ContactEdge* GetContactList() const;
377 
379  b2Body* GetNext();
380  const b2Body* GetNext() const;
381 
383  void* GetUserData() const;
384 
386  void SetUserData(void* data);
387 
389  b2World* GetWorld();
390  const b2World* GetWorld() const;
391 
393  void Dump();
394 
395 private:
396 
397  friend class b2World;
398  friend class b2Island;
399  friend class b2ContactManager;
400  friend class b2ContactSolver;
401  friend class b2Contact;
402 
403  friend class b2DistanceJoint;
404  friend class b2FrictionJoint;
405  friend class b2GearJoint;
406  friend class b2MotorJoint;
407  friend class b2MouseJoint;
408  friend class b2PrismaticJoint;
409  friend class b2PulleyJoint;
410  friend class b2RevoluteJoint;
411  friend class b2RopeJoint;
412  friend class b2WeldJoint;
413  friend class b2WheelJoint;
414 
415  // m_flags
416  enum
417  {
418  e_islandFlag = 0x0001,
419  e_awakeFlag = 0x0002,
420  e_autoSleepFlag = 0x0004,
421  e_bulletFlag = 0x0008,
422  e_fixedRotationFlag = 0x0010,
423  e_activeFlag = 0x0020,
424  e_toiFlag = 0x0040
425  };
426 
427  b2Body(const b2BodyDef* bd, b2World* world);
428  ~b2Body();
429 
430  void SynchronizeFixtures();
431  void SynchronizeTransform();
432 
433  // This is used to prevent connected bodies from colliding.
434  // It may lie, depending on the collideConnected flag.
435  bool ShouldCollide(const b2Body* other) const;
436 
437  void Advance(float t);
438 
439  b2BodyType m_type;
440 
441  uint16 m_flags;
442 
443  int32 m_islandIndex;
444 
445  b2Transform m_xf; // the body origin transform
446  b2Sweep m_sweep; // the swept motion for CCD
447 
448  b2Vec2 m_linearVelocity;
449  float m_angularVelocity;
450 
451  b2Vec2 m_force;
452  float m_torque;
453 
454  b2World* m_world;
455  b2Body* m_prev;
456  b2Body* m_next;
457 
458  b2Fixture* m_fixtureList;
459  int32 m_fixtureCount;
460 
461  b2JointEdge* m_jointList;
462  b2ContactEdge* m_contactList;
463 
464  float m_mass, m_invMass;
465 
466  // Rotational inertia about the center of mass.
467  float m_I, m_invI;
468 
469  float m_linearDamping;
470  float m_angularDamping;
471  float m_gravityScale;
472 
473  float m_sleepTime;
474 
475  void* m_userData;
476 };
477 
478 inline b2BodyType b2Body::GetType() const
479 {
480  return m_type;
481 }
482 
483 inline const b2Transform& b2Body::GetTransform() const
484 {
485  return m_xf;
486 }
487 
488 inline const b2Vec2& b2Body::GetPosition() const
489 {
490  return m_xf.p;
491 }
492 
493 inline float b2Body::GetAngle() const
494 {
495  return m_sweep.a;
496 }
497 
498 inline const b2Vec2& b2Body::GetWorldCenter() const
499 {
500  return m_sweep.c;
501 }
502 
503 inline const b2Vec2& b2Body::GetLocalCenter() const
504 {
505  return m_sweep.localCenter;
506 }
507 
508 inline void b2Body::SetLinearVelocity(const b2Vec2& v)
509 {
510  if (m_type == b2_staticBody)
511  {
512  return;
513  }
514 
515  if (b2Dot(v,v) > 0.0f)
516  {
517  SetAwake(true);
518  }
519 
520  m_linearVelocity = v;
521 }
522 
523 inline const b2Vec2& b2Body::GetLinearVelocity() const
524 {
525  return m_linearVelocity;
526 }
527 
528 inline void b2Body::SetAngularVelocity(float w)
529 {
530  if (m_type == b2_staticBody)
531  {
532  return;
533  }
534 
535  if (w * w > 0.0f)
536  {
537  SetAwake(true);
538  }
539 
540  m_angularVelocity = w;
541 }
542 
543 inline float b2Body::GetAngularVelocity() const
544 {
545  return m_angularVelocity;
546 }
547 
548 inline float b2Body::GetMass() const
549 {
550  return m_mass;
551 }
552 
553 inline float b2Body::GetInertia() const
554 {
555  return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
556 }
557 
558 inline void b2Body::GetMassData(b2MassData* data) const
559 {
560  data->mass = m_mass;
561  data->I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
562  data->center = m_sweep.localCenter;
563 }
564 
565 inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const
566 {
567  return b2Mul(m_xf, localPoint);
568 }
569 
570 inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const
571 {
572  return b2Mul(m_xf.q, localVector);
573 }
574 
575 inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const
576 {
577  return b2MulT(m_xf, worldPoint);
578 }
579 
580 inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const
581 {
582  return b2MulT(m_xf.q, worldVector);
583 }
584 
586 {
587  return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c);
588 }
589 
591 {
593 }
594 
595 inline float b2Body::GetLinearDamping() const
596 {
597  return m_linearDamping;
598 }
599 
600 inline void b2Body::SetLinearDamping(float linearDamping)
601 {
602  m_linearDamping = linearDamping;
603 }
604 
605 inline float b2Body::GetAngularDamping() const
606 {
607  return m_angularDamping;
608 }
609 
610 inline void b2Body::SetAngularDamping(float angularDamping)
611 {
612  m_angularDamping = angularDamping;
613 }
614 
615 inline float b2Body::GetGravityScale() const
616 {
617  return m_gravityScale;
618 }
619 
620 inline void b2Body::SetGravityScale(float scale)
621 {
622  m_gravityScale = scale;
623 }
624 
625 inline void b2Body::SetBullet(bool flag)
626 {
627  if (flag)
628  {
629  m_flags |= e_bulletFlag;
630  }
631  else
632  {
633  m_flags &= ~e_bulletFlag;
634  }
635 }
636 
637 inline bool b2Body::IsBullet() const
638 {
639  return (m_flags & e_bulletFlag) == e_bulletFlag;
640 }
641 
642 inline void b2Body::SetAwake(bool flag)
643 {
644  if (flag)
645  {
646  m_flags |= e_awakeFlag;
647  m_sleepTime = 0.0f;
648  }
649  else
650  {
651  m_flags &= ~e_awakeFlag;
652  m_sleepTime = 0.0f;
653  m_linearVelocity.SetZero();
654  m_angularVelocity = 0.0f;
655  m_force.SetZero();
656  m_torque = 0.0f;
657  }
658 }
659 
660 inline bool b2Body::IsAwake() const
661 {
662  return (m_flags & e_awakeFlag) == e_awakeFlag;
663 }
664 
665 inline bool b2Body::IsActive() const
666 {
667  return (m_flags & e_activeFlag) == e_activeFlag;
668 }
669 
670 inline bool b2Body::IsFixedRotation() const
671 {
672  return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
673 }
674 
675 inline void b2Body::SetSleepingAllowed(bool flag)
676 {
677  if (flag)
678  {
679  m_flags |= e_autoSleepFlag;
680  }
681  else
682  {
683  m_flags &= ~e_autoSleepFlag;
684  SetAwake(true);
685  }
686 }
687 
688 inline bool b2Body::IsSleepingAllowed() const
689 {
690  return (m_flags & e_autoSleepFlag) == e_autoSleepFlag;
691 }
692 
694 {
695  return m_fixtureList;
696 }
697 
698 inline const b2Fixture* b2Body::GetFixtureList() const
699 {
700  return m_fixtureList;
701 }
702 
704 {
705  return m_jointList;
706 }
707 
708 inline const b2JointEdge* b2Body::GetJointList() const
709 {
710  return m_jointList;
711 }
712 
714 {
715  return m_contactList;
716 }
717 
718 inline const b2ContactEdge* b2Body::GetContactList() const
719 {
720  return m_contactList;
721 }
722 
724 {
725  return m_next;
726 }
727 
728 inline const b2Body* b2Body::GetNext() const
729 {
730  return m_next;
731 }
732 
733 inline void b2Body::SetUserData(void* data)
734 {
735  m_userData = data;
736 }
737 
738 inline void* b2Body::GetUserData() const
739 {
740  return m_userData;
741 }
742 
743 inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
744 {
745  if (m_type != b2_dynamicBody)
746  {
747  return;
748  }
749 
750  if (wake && (m_flags & e_awakeFlag) == 0)
751  {
752  SetAwake(true);
753  }
754 
755  // Don't accumulate a force if the body is sleeping.
756  if (m_flags & e_awakeFlag)
757  {
758  m_force += force;
759  m_torque += b2Cross(point - m_sweep.c, force);
760  }
761 }
762 
763 inline void b2Body::ApplyForceToCenter(const b2Vec2& force, bool wake)
764 {
765  if (m_type != b2_dynamicBody)
766  {
767  return;
768  }
769 
770  if (wake && (m_flags & e_awakeFlag) == 0)
771  {
772  SetAwake(true);
773  }
774 
775  // Don't accumulate a force if the body is sleeping
776  if (m_flags & e_awakeFlag)
777  {
778  m_force += force;
779  }
780 }
781 
782 inline void b2Body::ApplyTorque(float torque, bool wake)
783 {
784  if (m_type != b2_dynamicBody)
785  {
786  return;
787  }
788 
789  if (wake && (m_flags & e_awakeFlag) == 0)
790  {
791  SetAwake(true);
792  }
793 
794  // Don't accumulate a force if the body is sleeping
795  if (m_flags & e_awakeFlag)
796  {
797  m_torque += torque;
798  }
799 }
800 
801 inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
802 {
803  if (m_type != b2_dynamicBody)
804  {
805  return;
806  }
807 
808  if (wake && (m_flags & e_awakeFlag) == 0)
809  {
810  SetAwake(true);
811  }
812 
813  // Don't accumulate velocity if the body is sleeping
814  if (m_flags & e_awakeFlag)
815  {
816  m_linearVelocity += m_invMass * impulse;
817  m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
818  }
819 }
820 
821 inline void b2Body::ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake)
822 {
823  if (m_type != b2_dynamicBody)
824  {
825  return;
826  }
827 
828  if (wake && (m_flags & e_awakeFlag) == 0)
829  {
830  SetAwake(true);
831  }
832 
833  // Don't accumulate velocity if the body is sleeping
834  if (m_flags & e_awakeFlag)
835  {
836  m_linearVelocity += m_invMass * impulse;
837  }
838 }
839 
840 inline void b2Body::ApplyAngularImpulse(float impulse, bool wake)
841 {
842  if (m_type != b2_dynamicBody)
843  {
844  return;
845  }
846 
847  if (wake && (m_flags & e_awakeFlag) == 0)
848  {
849  SetAwake(true);
850  }
851 
852  // Don't accumulate velocity if the body is sleeping
853  if (m_flags & e_awakeFlag)
854  {
855  m_angularVelocity += m_invI * impulse;
856  }
857 }
858 
859 inline void b2Body::SynchronizeTransform()
860 {
861  m_xf.q.Set(m_sweep.a);
862  m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
863 }
864 
865 inline void b2Body::Advance(float alpha)
866 {
867  // Advance to the new safe time. This doesn't sync the broad-phase.
868  m_sweep.Advance(alpha);
869  m_sweep.c = m_sweep.c0;
870  m_sweep.a = m_sweep.a0;
871  m_xf.q.Set(m_sweep.a);
872  m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
873 }
874 
876 {
877  return m_world;
878 }
879 
880 inline const b2World* b2Body::GetWorld() const
881 {
882  return m_world;
883 }
884 
885 #endif
b2Vec2
A 2D column vector.
Definition: b2_math.h:39
b2Body::SetAngularDamping
void SetAngularDamping(float angularDamping)
Set the angular damping of the body.
Definition: b2_body.h:610
b2FrictionJoint
Definition: b2_friction_joint.h:59
b2Body::IsAwake
bool IsAwake() const
Definition: b2_body.h:660
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition: b2_body.h:131
b2BodyDef::linearDamping
float linearDamping
Definition: b2_body.h:96
b2Body::GetMassData
void GetMassData(b2MassData *data) const
Definition: b2_body.h:558
b2Body::SetBullet
void SetBullet(bool flag)
Should this body be treated like a bullet for continuous collision detection?
Definition: b2_body.h:625
b2ContactManager
Definition: b2_contact_manager.h:34
b2Body::SetTransform
void SetTransform(const b2Vec2 &position, float angle)
b2Body::GetFixtureList
b2Fixture * GetFixtureList()
Get the list of all fixtures attached to this body.
Definition: b2_body.h:693
b2DistanceJoint
Definition: b2_distance_joint.h:71
b2Body::GetLocalPoint
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition: b2_body.h:575
b2Body::GetTransform
const b2Transform & GetTransform() const
Definition: b2_body.h:483
b2Body::GetJointList
b2JointEdge * GetJointList()
Get the list of all joints attached to this body.
Definition: b2_body.h:703
b2Transform
Definition: b2_math.h:336
b2Body::GetType
b2BodyType GetType() const
Get the type of this body.
Definition: b2_body.h:478
b2Body::GetWorldPoint
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition: b2_body.h:565
b2Body::GetNext
b2Body * GetNext()
Get the next body in the world's body list.
Definition: b2_body.h:723
b2Sweep
Definition: b2_math.h:366
b2Body::GetLinearVelocityFromWorldPoint
b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2 &worldPoint) const
Definition: b2_body.h:585
b2PrismaticJoint
Definition: b2_prismatic_joint.h:90
b2BodyDef::gravityScale
float gravityScale
Scale the gravity applied to this body.
Definition: b2_body.h:127
b2BodyDef::fixedRotation
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition: b2_body.h:112
b2BodyDef::b2BodyDef
b2BodyDef()
This constructor sets the body definition default values.
Definition: b2_body.h:57
b2Body::GetLinearVelocity
const b2Vec2 & GetLinearVelocity() const
Definition: b2_body.h:523
b2Body::SetType
void SetType(b2BodyType type)
Set the type of this body. This may alter the mass and velocity.
b2BodyDef::angularDamping
float angularDamping
Definition: b2_body.h:102
b2Body::GetLocalVector
b2Vec2 GetLocalVector(const b2Vec2 &worldVector) const
Definition: b2_body.h:580
b2BodyDef::angle
float angle
The world angle of the body in radians.
Definition: b2_body.h:84
b2Body::SetAngularVelocity
void SetAngularVelocity(float omega)
Definition: b2_body.h:528
b2Sweep::c
b2Vec2 c
center world positions
Definition: b2_math.h:381
b2Body::SetGravityScale
void SetGravityScale(float scale)
Set the gravity scale of the body.
Definition: b2_body.h:620
b2Body::GetInertia
float GetInertia() const
Definition: b2_body.h:553
b2BodyDef::userData
void * userData
Use this to store application specific body data.
Definition: b2_body.h:124
b2Body::ApplyAngularImpulse
void ApplyAngularImpulse(float impulse, bool wake)
Definition: b2_body.h:840
b2WheelJoint
Definition: b2_wheel_joint.h:82
b2Body::SetSleepingAllowed
void SetSleepingAllowed(bool flag)
Definition: b2_body.h:675
b2Vec2::Set
void Set(float x_, float y_)
Set this vector to some specified coordinates.
Definition: b2_math.h:51
b2Body::IsBullet
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
Definition: b2_body.h:637
b2Body::IsSleepingAllowed
bool IsSleepingAllowed() const
Is this body allowed to sleep.
Definition: b2_body.h:688
b2Body::GetUserData
void * GetUserData() const
Get the user data pointer that was provided in the body definition.
Definition: b2_body.h:738
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2FixtureDef *def)
b2FixtureDef
Definition: b2_fixture.h:60
b2WeldJoint
Definition: b2_weld_joint.h:66
b2Body::SetLinearVelocity
void SetLinearVelocity(const b2Vec2 &v)
Definition: b2_body.h:508
b2Body::GetWorldVector
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
Definition: b2_body.h:570
b2Body::Dump
void Dump()
Dump this body to a log file.
b2Body::ApplyLinearImpulseToCenter
void ApplyLinearImpulseToCenter(const b2Vec2 &impulse, bool wake)
Definition: b2_body.h:821
b2Body::SetUserData
void SetUserData(void *data)
Set the user data. Use this to store your application specific data.
Definition: b2_body.h:733
b2BodyDef::type
b2BodyType type
Definition: b2_body.h:77
b2Body::GetWorld
b2World * GetWorld()
Get the parent world of this body.
Definition: b2_body.h:875
b2Fixture
Definition: b2_fixture.h:111
b2BodyDef::linearVelocity
b2Vec2 linearVelocity
The linear velocity of the body's origin in world co-ordinates.
Definition: b2_body.h:87
b2Sweep::Advance
void Advance(float alpha)
Definition: b2_math.h:694
b2BodyDef::bullet
bool bullet
Definition: b2_body.h:118
b2BodyDef::angularVelocity
float angularVelocity
The angular velocity of the body.
Definition: b2_body.h:90
b2Body::SetActive
void SetActive(bool flag)
b2Body::GetAngularDamping
float GetAngularDamping() const
Get the angular damping of the body.
Definition: b2_body.h:605
b2RevoluteJoint
Definition: b2_revolute_joint.h:94
b2Body::GetWorldCenter
const b2Vec2 & GetWorldCenter() const
Get the world position of the center of mass.
Definition: b2_body.h:498
b2Body::GetAngle
float GetAngle() const
Definition: b2_body.h:493
b2BodyDef::awake
bool awake
Is this body initially awake or sleeping?
Definition: b2_body.h:109
b2BodyDef::allowSleep
bool allowSleep
Definition: b2_body.h:106
b2BodyDef
Definition: b2_body.h:54
b2Body::GetLinearVelocityFromLocalPoint
b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2 &localPoint) const
Definition: b2_body.h:590
b2Body::SetLinearDamping
void SetLinearDamping(float linearDamping)
Set the linear damping of the body.
Definition: b2_body.h:600
b2Contact
Definition: b2_contact.h:81
b2Body::GetContactList
b2ContactEdge * GetContactList()
Definition: b2_body.h:713
b2JointEdge
Definition: b2_joint.h:69
b2MotorJoint
Definition: b2_motor_joint.h:63
b2Body::GetMass
float GetMass() const
Definition: b2_body.h:548
b2Body::DestroyFixture
void DestroyFixture(b2Fixture *fixture)
b2World
Definition: b2_world.h:45
b2Body::GetGravityScale
float GetGravityScale() const
Get the gravity scale of the body.
Definition: b2_body.h:615
b2Body::IsFixedRotation
bool IsFixedRotation() const
Does this body have fixed rotation?
Definition: b2_body.h:670
b2Body::ApplyLinearImpulse
void ApplyLinearImpulse(const b2Vec2 &impulse, const b2Vec2 &point, bool wake)
Definition: b2_body.h:801
b2GearJoint
Definition: b2_gear_joint.h:60
b2Body::IsActive
bool IsActive() const
Get the active state of the body.
Definition: b2_body.h:665
b2Shape
Definition: b2_shape.h:47
b2RopeJoint
Definition: b2_rope_joint.h:62
b2Rot::Set
void Set(float angle)
Set using an angle in radians.
Definition: b2_math.h:298
b2MassData
This holds the mass data computed for a shape.
Definition: b2_shape.h:32
b2MassData::center
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
Definition: b2_shape.h:38
b2Body::SetAwake
void SetAwake(bool flag)
Definition: b2_body.h:642
b2Vec2::SetZero
void SetZero()
Set this vector to all zeros.
Definition: b2_math.h:48
b2MassData::mass
float mass
The mass of the shape, usually in kilograms.
Definition: b2_shape.h:35
b2Body::SetMassData
void SetMassData(const b2MassData *data)
b2Body::ApplyTorque
void ApplyTorque(float torque, bool wake)
Definition: b2_body.h:782
b2MouseJoint
Definition: b2_mouse_joint.h:64
b2Body::SetFixedRotation
void SetFixedRotation(bool flag)
b2Joint
Definition: b2_joint.h:107
b2Body::GetLocalCenter
const b2Vec2 & GetLocalCenter() const
Get the local position of the center of mass.
Definition: b2_body.h:503
b2Sweep::localCenter
b2Vec2 localCenter
local center of mass position
Definition: b2_math.h:380
b2BodyDef::active
bool active
Does this body start out active?
Definition: b2_body.h:121
b2Body::ResetMassData
void ResetMassData()
b2Body::GetPosition
const b2Vec2 & GetPosition() const
Definition: b2_body.h:488
b2Body::GetAngularVelocity
float GetAngularVelocity() const
Definition: b2_body.h:543
b2ContactEdge
Definition: b2_contact.h:70
b2MassData::I
float I
The rotational inertia of the shape about the local origin.
Definition: b2_shape.h:41
b2Body::GetLinearDamping
float GetLinearDamping() const
Get the linear damping of the body.
Definition: b2_body.h:595
b2Body::ApplyForce
void ApplyForce(const b2Vec2 &force, const b2Vec2 &point, bool wake)
Definition: b2_body.h:743
b2Sweep::a
float a
world angles
Definition: b2_math.h:382
b2PulleyJoint
Definition: b2_pulley_joint.h:83
b2BodyDef::position
b2Vec2 position
Definition: b2_body.h:81
b2Body::ApplyForceToCenter
void ApplyForceToCenter(const b2Vec2 &force, bool wake)
Definition: b2_body.h:763