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_api.h"
27 #include "b2_math.h"
28 #include "b2_shape.h"
29 
30 class b2Fixture;
31 class b2Joint;
32 class b2Contact;
33 class b2Controller;
34 class b2World;
35 struct b2FixtureDef;
36 struct b2JointEdge;
37 struct b2ContactEdge;
38 
43 enum b2BodyType
44 {
45  b2_staticBody = 0,
46  b2_kinematicBody,
47  b2_dynamicBody
48 
49  // TODO_ERIN
50  //b2_bulletBody,
51 };
52 
55 struct B2_API b2BodyDef
56 {
59  {
60  userData = nullptr;
61  position.Set(0.0f, 0.0f);
62  angle = 0.0f;
63  linearVelocity.Set(0.0f, 0.0f);
64  angularVelocity = 0.0f;
65  linearDamping = 0.0f;
66  angularDamping = 0.0f;
67  allowSleep = true;
68  awake = true;
69  fixedRotation = false;
70  bullet = false;
71  type = b2_staticBody;
72  enabled = true;
73  gravityScale = 1.0f;
74  }
75 
78  b2BodyType type;
79 
83 
85  float angle;
86 
89 
92 
98 
104 
108 
110  bool awake;
111 
114 
119  bool bullet;
120 
122  bool enabled;
123 
125  void* userData;
126 
129 };
130 
132 class B2_API b2Body
133 {
134 public:
143 
151  b2Fixture* CreateFixture(const b2Shape* shape, float density);
152 
160  void DestroyFixture(b2Fixture* fixture);
161 
167  void SetTransform(const b2Vec2& position, float angle);
168 
171  const b2Transform& GetTransform() const;
172 
175  const b2Vec2& GetPosition() const;
176 
179  float GetAngle() const;
180 
182  const b2Vec2& GetWorldCenter() const;
183 
185  const b2Vec2& GetLocalCenter() const;
186 
189  void SetLinearVelocity(const b2Vec2& v);
190 
193  const b2Vec2& GetLinearVelocity() const;
194 
197  void SetAngularVelocity(float omega);
198 
201  float GetAngularVelocity() const;
202 
209  void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake);
210 
214  void ApplyForceToCenter(const b2Vec2& force, bool wake);
215 
220  void ApplyTorque(float torque, bool wake);
221 
228  void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
229 
233  void ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake);
234 
238  void ApplyAngularImpulse(float impulse, bool wake);
239 
242  float GetMass() const;
243 
246  float GetInertia() const;
247 
250  void GetMassData(b2MassData* data) const;
251 
257  void SetMassData(const b2MassData* data);
258 
263 
267  b2Vec2 GetWorldPoint(const b2Vec2& localPoint) const;
268 
272  b2Vec2 GetWorldVector(const b2Vec2& localVector) const;
273 
277  b2Vec2 GetLocalPoint(const b2Vec2& worldPoint) const;
278 
282  b2Vec2 GetLocalVector(const b2Vec2& worldVector) const;
283 
287  b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const;
288 
292  b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const;
293 
295  float GetLinearDamping() const;
296 
298  void SetLinearDamping(float linearDamping);
299 
301  float GetAngularDamping() const;
302 
304  void SetAngularDamping(float angularDamping);
305 
307  float GetGravityScale() const;
308 
310  void SetGravityScale(float scale);
311 
313  void SetType(b2BodyType type);
314 
316  b2BodyType GetType() const;
317 
319  void SetBullet(bool flag);
320 
322  bool IsBullet() const;
323 
326  void SetSleepingAllowed(bool flag);
327 
329  bool IsSleepingAllowed() const;
330 
334  void SetAwake(bool flag);
335 
338  bool IsAwake() const;
339 
352  void SetEnabled(bool flag);
353 
355  bool IsEnabled() const;
356 
359  void SetFixedRotation(bool flag);
360 
362  bool IsFixedRotation() const;
363 
365  b2Fixture* GetFixtureList();
366  const b2Fixture* GetFixtureList() const;
367 
369  b2JointEdge* GetJointList();
370  const b2JointEdge* GetJointList() const;
371 
375  b2ContactEdge* GetContactList();
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_enabledFlag = 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 (m_type == b2_staticBody)
645  {
646  return;
647  }
648 
649  if (flag)
650  {
651  m_flags |= e_awakeFlag;
652  m_sleepTime = 0.0f;
653  }
654  else
655  {
656  m_flags &= ~e_awakeFlag;
657  m_sleepTime = 0.0f;
658  m_linearVelocity.SetZero();
659  m_angularVelocity = 0.0f;
660  m_force.SetZero();
661  m_torque = 0.0f;
662  }
663 }
664 
665 inline bool b2Body::IsAwake() const
666 {
667  return (m_flags & e_awakeFlag) == e_awakeFlag;
668 }
669 
670 inline bool b2Body::IsEnabled() const
671 {
672  return (m_flags & e_enabledFlag) == e_enabledFlag;
673 }
674 
675 inline bool b2Body::IsFixedRotation() const
676 {
677  return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
678 }
679 
680 inline void b2Body::SetSleepingAllowed(bool flag)
681 {
682  if (flag)
683  {
684  m_flags |= e_autoSleepFlag;
685  }
686  else
687  {
688  m_flags &= ~e_autoSleepFlag;
689  SetAwake(true);
690  }
691 }
692 
693 inline bool b2Body::IsSleepingAllowed() const
694 {
695  return (m_flags & e_autoSleepFlag) == e_autoSleepFlag;
696 }
697 
699 {
700  return m_fixtureList;
701 }
702 
703 inline const b2Fixture* b2Body::GetFixtureList() const
704 {
705  return m_fixtureList;
706 }
707 
709 {
710  return m_jointList;
711 }
712 
713 inline const b2JointEdge* b2Body::GetJointList() const
714 {
715  return m_jointList;
716 }
717 
719 {
720  return m_contactList;
721 }
722 
723 inline const b2ContactEdge* b2Body::GetContactList() const
724 {
725  return m_contactList;
726 }
727 
729 {
730  return m_next;
731 }
732 
733 inline const b2Body* b2Body::GetNext() const
734 {
735  return m_next;
736 }
737 
738 inline void b2Body::SetUserData(void* data)
739 {
740  m_userData = data;
741 }
742 
743 inline void* b2Body::GetUserData() const
744 {
745  return m_userData;
746 }
747 
748 inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
749 {
750  if (m_type != b2_dynamicBody)
751  {
752  return;
753  }
754 
755  if (wake && (m_flags & e_awakeFlag) == 0)
756  {
757  SetAwake(true);
758  }
759 
760  // Don't accumulate a force if the body is sleeping.
761  if (m_flags & e_awakeFlag)
762  {
763  m_force += force;
764  m_torque += b2Cross(point - m_sweep.c, force);
765  }
766 }
767 
768 inline void b2Body::ApplyForceToCenter(const b2Vec2& force, bool wake)
769 {
770  if (m_type != b2_dynamicBody)
771  {
772  return;
773  }
774 
775  if (wake && (m_flags & e_awakeFlag) == 0)
776  {
777  SetAwake(true);
778  }
779 
780  // Don't accumulate a force if the body is sleeping
781  if (m_flags & e_awakeFlag)
782  {
783  m_force += force;
784  }
785 }
786 
787 inline void b2Body::ApplyTorque(float torque, bool wake)
788 {
789  if (m_type != b2_dynamicBody)
790  {
791  return;
792  }
793 
794  if (wake && (m_flags & e_awakeFlag) == 0)
795  {
796  SetAwake(true);
797  }
798 
799  // Don't accumulate a force if the body is sleeping
800  if (m_flags & e_awakeFlag)
801  {
802  m_torque += torque;
803  }
804 }
805 
806 inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
807 {
808  if (m_type != b2_dynamicBody)
809  {
810  return;
811  }
812 
813  if (wake && (m_flags & e_awakeFlag) == 0)
814  {
815  SetAwake(true);
816  }
817 
818  // Don't accumulate velocity if the body is sleeping
819  if (m_flags & e_awakeFlag)
820  {
821  m_linearVelocity += m_invMass * impulse;
822  m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
823  }
824 }
825 
826 inline void b2Body::ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake)
827 {
828  if (m_type != b2_dynamicBody)
829  {
830  return;
831  }
832 
833  if (wake && (m_flags & e_awakeFlag) == 0)
834  {
835  SetAwake(true);
836  }
837 
838  // Don't accumulate velocity if the body is sleeping
839  if (m_flags & e_awakeFlag)
840  {
841  m_linearVelocity += m_invMass * impulse;
842  }
843 }
844 
845 inline void b2Body::ApplyAngularImpulse(float impulse, bool wake)
846 {
847  if (m_type != b2_dynamicBody)
848  {
849  return;
850  }
851 
852  if (wake && (m_flags & e_awakeFlag) == 0)
853  {
854  SetAwake(true);
855  }
856 
857  // Don't accumulate velocity if the body is sleeping
858  if (m_flags & e_awakeFlag)
859  {
860  m_angularVelocity += m_invI * impulse;
861  }
862 }
863 
864 inline void b2Body::SynchronizeTransform()
865 {
866  m_xf.q.Set(m_sweep.a);
867  m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
868 }
869 
870 inline void b2Body::Advance(float alpha)
871 {
872  // Advance to the new safe time. This doesn't sync the broad-phase.
873  m_sweep.Advance(alpha);
874  m_sweep.c = m_sweep.c0;
875  m_sweep.a = m_sweep.a0;
876  m_xf.q.Set(m_sweep.a);
877  m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
878 }
879 
881 {
882  return m_world;
883 }
884 
885 inline const b2World* b2Body::GetWorld() const
886 {
887  return m_world;
888 }
889 
890 #endif
b2Vec2
A 2D column vector.
Definition: b2_math.h:42
b2Body::SetAngularDamping
void SetAngularDamping(float angularDamping)
Set the angular damping of the body.
Definition: b2_body.h:610
b2FrictionJoint
Definition: b2_friction_joint.h:61
b2Body::IsAwake
bool IsAwake() const
Definition: b2_body.h:665
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition: b2_body.h:133
b2BodyDef::linearDamping
float linearDamping
Definition: b2_body.h:97
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:36
b2Body::SetTransform
void SetTransform(const b2Vec2 &position, float angle)
b2DistanceJoint
Definition: b2_distance_joint.h:70
b2Body::GetLocalPoint
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition: b2_body.h:575
b2Body::GetTransform
const b2Transform & GetTransform() const
Definition: b2_body.h:483
b2Transform
Definition: b2_math.h:339
b2Body::GetType
b2BodyType GetType() const
Get the type of this body.
Definition: b2_body.h:478
b2Body::GetFixtureList
b2Fixture * GetFixtureList()
Get the list of all fixtures attached to this body.
Definition: b2_body.h:698
b2Body::GetWorldPoint
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition: b2_body.h:565
b2Sweep
Definition: b2_math.h:369
b2Body::GetLinearVelocityFromWorldPoint
b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2 &worldPoint) const
Definition: b2_body.h:585
b2PrismaticJoint
Definition: b2_prismatic_joint.h:92
b2BodyDef::gravityScale
float gravityScale
Scale the gravity applied to this body.
Definition: b2_body.h:128
b2BodyDef::fixedRotation
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition: b2_body.h:113
b2Body::GetWorld
b2World * GetWorld()
Get the parent world of this body.
Definition: b2_body.h:880
b2BodyDef::b2BodyDef
b2BodyDef()
This constructor sets the body definition default values.
Definition: b2_body.h:58
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:103
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:85
b2Body::SetAngularVelocity
void SetAngularVelocity(float omega)
Definition: b2_body.h:528
b2Body::GetJointList
b2JointEdge * GetJointList()
Get the list of all joints attached to this body.
Definition: b2_body.h:708
b2Sweep::c
b2Vec2 c
center world positions
Definition: b2_math.h:383
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:125
b2Body::ApplyAngularImpulse
void ApplyAngularImpulse(float impulse, bool wake)
Definition: b2_body.h:845
b2WheelJoint
Definition: b2_wheel_joint.h:96
b2Body::SetSleepingAllowed
void SetSleepingAllowed(bool flag)
Definition: b2_body.h:680
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:693
b2Body::GetUserData
void * GetUserData() const
Get the user data pointer that was provided in the body definition.
Definition: b2_body.h:743
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2FixtureDef *def)
b2FixtureDef
Definition: b2_fixture.h:62
b2WeldJoint
Definition: b2_weld_joint.h:70
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 file.
b2Body::ApplyLinearImpulseToCenter
void ApplyLinearImpulseToCenter(const b2Vec2 &impulse, bool wake)
Definition: b2_body.h:826
b2Body::SetUserData
void SetUserData(void *data)
Set the user data. Use this to store your application specific data.
Definition: b2_body.h:738
b2BodyDef::type
b2BodyType type
Definition: b2_body.h:78
b2Fixture
Definition: b2_fixture.h:113
b2BodyDef::linearVelocity
b2Vec2 linearVelocity
The linear velocity of the body's origin in world co-ordinates.
Definition: b2_body.h:88
b2Sweep::Advance
void Advance(float alpha)
Definition: b2_math.h:696
b2BodyDef::bullet
bool bullet
Definition: b2_body.h:119
b2BodyDef::angularVelocity
float angularVelocity
The angular velocity of the body.
Definition: b2_body.h:91
b2Body::GetAngularDamping
float GetAngularDamping() const
Get the angular damping of the body.
Definition: b2_body.h:605
b2RevoluteJoint
Definition: b2_revolute_joint.h:95
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
b2Body::GetContactList
b2ContactEdge * GetContactList()
Definition: b2_body.h:718
b2BodyDef::awake
bool awake
Is this body initially awake or sleeping?
Definition: b2_body.h:110
b2BodyDef::allowSleep
bool allowSleep
Definition: b2_body.h:107
b2BodyDef
Definition: b2_body.h:56
b2Body::GetLinearVelocityFromLocalPoint
b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2 &localPoint) const
Definition: b2_body.h:590
b2BodyDef::enabled
bool enabled
Does this body start out enabled?
Definition: b2_body.h:122
b2Body::SetLinearDamping
void SetLinearDamping(float linearDamping)
Set the linear damping of the body.
Definition: b2_body.h:600
b2Body::IsEnabled
bool IsEnabled() const
Get the active state of the body.
Definition: b2_body.h:670
b2Body::SetEnabled
void SetEnabled(bool flag)
b2Contact
Definition: b2_contact.h:83
b2JointEdge
Definition: b2_joint.h:64
b2MotorJoint
Definition: b2_motor_joint.h:65
b2Body::GetMass
float GetMass() const
Definition: b2_body.h:548
b2Body::DestroyFixture
void DestroyFixture(b2Fixture *fixture)
b2Body::GetNext
b2Body * GetNext()
Get the next body in the world's body list.
Definition: b2_body.h:728
b2World
Definition: b2_world.h:47
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:675
b2Body::ApplyLinearImpulse
void ApplyLinearImpulse(const b2Vec2 &impulse, const b2Vec2 &point, bool wake)
Definition: b2_body.h:806
b2GearJoint
Definition: b2_gear_joint.h:61
b2Shape
Definition: b2_shape.h:49
b2RopeJoint
Definition: b2_rope_joint.h:64
b2Rot::Set
void Set(float angle)
Set using an angle in radians.
Definition: b2_math.h:300
b2MassData
This holds the mass data computed for a shape.
Definition: b2_shape.h:34
b2MassData::center
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
Definition: b2_shape.h:39
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:50
b2MassData::mass
float mass
The mass of the shape, usually in kilograms.
Definition: b2_shape.h:36
b2Body::SetMassData
void SetMassData(const b2MassData *data)
b2Body::ApplyTorque
void ApplyTorque(float torque, bool wake)
Definition: b2_body.h:787
b2MouseJoint
Definition: b2_mouse_joint.h:66
b2Body::SetFixedRotation
void SetFixedRotation(bool flag)
b2Joint
Definition: b2_joint.h:112
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:382
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:72
b2MassData::I
float I
The rotational inertia of the shape about the local origin.
Definition: b2_shape.h:42
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:748
b2Sweep::a
float a
world angles
Definition: b2_math.h:384
b2PulleyJoint
Definition: b2_pulley_joint.h:85
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2Shape *shape, float density)
b2BodyDef::position
b2Vec2 position
Definition: b2_body.h:82
b2Body::ApplyForceToCenter
void ApplyForceToCenter(const b2Vec2 &force, bool wake)
Definition: b2_body.h:768