LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
b2Body.h
1 /*
2 * Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3 * Copyright (c) 2013 Google, Inc.
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 * 2. Altered source versions must be plainly marked as such, and must not be
16 * misrepresented as being the original software.
17 * 3. This notice may not be removed or altered from any source distribution.
18 */
19 
20 #ifndef B2_BODY_H
21 #define B2_BODY_H
22 
23 #include <Box2D/Common/b2Math.h>
24 #include <Box2D/Collision/Shapes/b2Shape.h>
25 #include <memory>
26 
27 class b2Fixture;
28 class b2Joint;
29 class b2Contact;
30 class b2Controller;
31 class b2World;
32 struct b2FixtureDef;
33 struct b2JointEdge;
34 struct b2ContactEdge;
35 
40 enum b2BodyType
41 {
42  b2_staticBody = 0,
43  b2_kinematicBody,
44  b2_dynamicBody
45 
46  // TODO_ERIN
47  //b2_bulletBody,
48 };
49 
52 struct b2BodyDef
53 {
56  {
57  userData = NULL;
58  position.Set(0.0f, 0.0f);
59  angle = 0.0f;
60  linearVelocity.Set(0.0f, 0.0f);
61  angularVelocity = 0.0f;
62  linearDamping = 0.0f;
63  angularDamping = 0.0f;
64  allowSleep = true;
65  awake = true;
66  fixedRotation = false;
67  bullet = false;
68  type = b2_staticBody;
69  active = true;
70  gravityScale = 1.0f;
71  }
72 
73 #if LIQUIDFUN_EXTERNAL_LANGUAGE_API
74  void SetPosition(float32 positionX, float32 positionY);
76 #endif // LIQUIDFUN_EXTERNAL_LANGUAGE_API
77 
80  b2BodyType type;
81 
85 
87  float32 angle;
88 
91 
93  float32 angularVelocity;
94 
98  float32 linearDamping;
99 
103  float32 angularDamping;
104 
108 
110  bool awake;
111 
114 
119  bool bullet;
120 
122  bool active;
123 
125  void* userData;
126 
128  float32 gravityScale;
129 };
130 
132 class b2Body
133 {
134 public:
142  b2Fixture* CreateFixture(const b2FixtureDef* def);
143 
151  b2Fixture* CreateFixture(const b2Shape* shape, float32 density);
152 
160  void DestroyFixture(b2Fixture* fixture);
161 
167  void SetTransform(const b2Vec2& position, float32 angle);
168 
171  const b2Transform& GetTransform() const;
172 
175  const b2Vec2& GetPosition() const;
176 
179  float32 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(float32 omega);
198 
201  float32 GetAngularVelocity() const;
202 
209  void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake);
210 
214  void ApplyForceToCenter(const b2Vec2& force, bool wake);
215 
221  void ApplyTorque(float32 torque, bool wake);
222 
229  void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
230 
234  void ApplyAngularImpulse(float32 impulse, bool wake);
235 
238  float32 GetMass() const;
239 
242  float32 GetInertia() const;
243 
246  void GetMassData(b2MassData* data) const;
247 
253  void SetMassData(const b2MassData* data);
254 
258  void ResetMassData();
259 
263  b2Vec2 GetWorldPoint(const b2Vec2& localPoint) const;
264 
268  b2Vec2 GetWorldVector(const b2Vec2& localVector) const;
269 
273  b2Vec2 GetLocalPoint(const b2Vec2& worldPoint) const;
274 
278  b2Vec2 GetLocalVector(const b2Vec2& worldVector) const;
279 
283  b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const;
284 
288  b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const;
289 
291  float32 GetLinearDamping() const;
292 
294  void SetLinearDamping(float32 linearDamping);
295 
297  float32 GetAngularDamping() const;
298 
300  void SetAngularDamping(float32 angularDamping);
301 
303  float32 GetGravityScale() const;
304 
306  void SetGravityScale(float32 scale);
307 
309  void SetType(b2BodyType type);
310 
312  b2BodyType GetType() const;
313 
315  void SetBullet(bool flag);
316 
318  bool IsBullet() const;
319 
322  void SetSleepingAllowed(bool flag);
323 
325  bool IsSleepingAllowed() const;
326 
330  void SetAwake(bool flag);
331 
334  bool IsAwake() const;
335 
349  void SetActive(bool flag);
350 
352  bool IsActive() const;
353 
356  void SetFixedRotation(bool flag);
357 
359  bool IsFixedRotation() const;
360 
363  const b2Fixture* GetFixtureList() const;
364 
367  const b2JointEdge* GetJointList() const;
368 
373  const b2ContactEdge* GetContactList() const;
374 
376  b2Body* GetNext();
377  const b2Body* GetNext() const;
378 
380  void* GetUserData() const;
381 
383  void SetUserData(void* data);
384 
386  b2World* GetWorld();
387  const b2World* GetWorld() const;
388 
390  void Dump();
391 
392 #if LIQUIDFUN_EXTERNAL_LANGUAGE_API
393 public:
395  float32 GetPositionX() const { return GetPosition().x; }
396 
398  float32 GetPositionY() const { return GetPosition().y; }
399 
401  void SetTransform(float32 positionX, float32 positionY, float32 angle);
402 #endif // LIQUIDFUN_EXTERNAL_LANGUAGE_API
403 
404 private:
405 
406  friend class b2World;
407  friend class b2Island;
408  friend class b2ContactManager;
409  friend class b2ContactSolver;
410  friend class b2Contact;
411 
412  friend class b2DistanceJoint;
413  friend class b2FrictionJoint;
414  friend class b2GearJoint;
415  friend class b2MotorJoint;
416  friend class b2MouseJoint;
417  friend class b2PrismaticJoint;
418  friend class b2PulleyJoint;
419  friend class b2RevoluteJoint;
420  friend class b2RopeJoint;
421  friend class b2WeldJoint;
422  friend class b2WheelJoint;
423 
424  friend class b2ParticleSystem;
425  friend class b2ParticleGroup;
426 
427  // m_flags
428  enum
429  {
430  e_islandFlag = 0x0001,
431  e_awakeFlag = 0x0002,
432  e_autoSleepFlag = 0x0004,
433  e_bulletFlag = 0x0008,
434  e_fixedRotationFlag = 0x0010,
435  e_activeFlag = 0x0020,
436  e_toiFlag = 0x0040
437  };
438 
439  b2Body(const b2BodyDef* bd, b2World* world);
440  ~b2Body();
441 
442  void SynchronizeFixtures();
443  void SynchronizeTransform();
444 
445  // This is used to prevent connected bodies from colliding.
446  // It may lie, depending on the collideConnected flag.
447  bool ShouldCollide(const b2Body* other) const;
448 
449  void Advance(float32 t);
450 
451  b2BodyType m_type;
452 
453  uint16 m_flags;
454 
455  int32 m_islandIndex;
456 
457  b2Transform m_xf; // the body origin transform
458  b2Transform m_xf0; // the previous transform for particle simulation
459  b2Sweep m_sweep; // the swept motion for CCD
460 
461  b2Vec2 m_linearVelocity;
462  float32 m_angularVelocity;
463 
464  b2Vec2 m_force;
465  float32 m_torque;
466 
467  b2World* m_world;
468  b2Body* m_prev;
469  b2Body* m_next;
470 
471  b2Fixture* m_fixtureList;
472  int32 m_fixtureCount;
473 
474  b2JointEdge* m_jointList;
475  b2ContactEdge* m_contactList;
476 
477  float32 m_mass, m_invMass;
478 
479  // Rotational inertia about the center of mass.
480  float32 m_I, m_invI;
481 
482  float32 m_linearDamping;
483  float32 m_angularDamping;
484  float32 m_gravityScale;
485 
486  float32 m_sleepTime;
487 
488  void* m_userData;
489 };
490 
491 inline b2BodyType b2Body::GetType() const
492 {
493  return m_type;
494 }
495 
496 inline const b2Transform& b2Body::GetTransform() const
497 {
498  return m_xf;
499 }
500 
501 inline const b2Vec2& b2Body::GetPosition() const
502 {
503  return m_xf.p;
504 }
505 
506 inline float32 b2Body::GetAngle() const
507 {
508  return m_sweep.a;
509 }
510 
511 inline const b2Vec2& b2Body::GetWorldCenter() const
512 {
513  return m_sweep.c;
514 }
515 
516 inline const b2Vec2& b2Body::GetLocalCenter() const
517 {
518  return m_sweep.localCenter;
519 }
520 
521 inline void b2Body::SetLinearVelocity(const b2Vec2& v)
522 {
523  if (m_type == b2_staticBody)
524  {
525  return;
526  }
527 
528  if (b2Dot(v,v) > 0.0f)
529  {
530  SetAwake(true);
531  }
532 
533  m_linearVelocity = v;
534 }
535 
536 inline const b2Vec2& b2Body::GetLinearVelocity() const
537 {
538  return m_linearVelocity;
539 }
540 
541 inline void b2Body::SetAngularVelocity(float32 w)
542 {
543  if (m_type == b2_staticBody)
544  {
545  return;
546  }
547 
548  if (w * w > 0.0f)
549  {
550  SetAwake(true);
551  }
552 
553  m_angularVelocity = w;
554 }
555 
556 inline float32 b2Body::GetAngularVelocity() const
557 {
558  return m_angularVelocity;
559 }
560 
561 inline float32 b2Body::GetMass() const
562 {
563  return m_mass;
564 }
565 
566 inline float32 b2Body::GetInertia() const
567 {
568  return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
569 }
570 
571 inline void b2Body::GetMassData(b2MassData* data) const
572 {
573  data->mass = m_mass;
574  data->I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
575  data->center = m_sweep.localCenter;
576 }
577 
578 inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const
579 {
580  return b2Mul(m_xf, localPoint);
581 }
582 
583 inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const
584 {
585  return b2Mul(m_xf.q, localVector);
586 }
587 
588 inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const
589 {
590  return b2MulT(m_xf, worldPoint);
591 }
592 
593 inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const
594 {
595  return b2MulT(m_xf.q, worldVector);
596 }
597 
599 {
600  return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c);
601 }
602 
604 {
606 }
607 
608 inline float32 b2Body::GetLinearDamping() const
609 {
610  return m_linearDamping;
611 }
612 
613 inline void b2Body::SetLinearDamping(float32 linearDamping)
614 {
615  m_linearDamping = linearDamping;
616 }
617 
618 inline float32 b2Body::GetAngularDamping() const
619 {
620  return m_angularDamping;
621 }
622 
623 inline void b2Body::SetAngularDamping(float32 angularDamping)
624 {
625  m_angularDamping = angularDamping;
626 }
627 
628 inline float32 b2Body::GetGravityScale() const
629 {
630  return m_gravityScale;
631 }
632 
633 inline void b2Body::SetGravityScale(float32 scale)
634 {
635  m_gravityScale = scale;
636 }
637 
638 inline void b2Body::SetBullet(bool flag)
639 {
640  if (flag)
641  {
642  m_flags |= e_bulletFlag;
643  }
644  else
645  {
646  m_flags &= ~e_bulletFlag;
647  }
648 }
649 
650 inline bool b2Body::IsBullet() const
651 {
652  return (m_flags & e_bulletFlag) == e_bulletFlag;
653 }
654 
655 inline void b2Body::SetAwake(bool flag)
656 {
657  if (flag)
658  {
659  if ((m_flags & e_awakeFlag) == 0)
660  {
661  m_flags |= e_awakeFlag;
662  m_sleepTime = 0.0f;
663  }
664  }
665  else
666  {
667  m_flags &= ~e_awakeFlag;
668  m_sleepTime = 0.0f;
669  m_linearVelocity.SetZero();
670  m_angularVelocity = 0.0f;
671  m_force.SetZero();
672  m_torque = 0.0f;
673  }
674 }
675 
676 inline bool b2Body::IsAwake() const
677 {
678  return (m_flags & e_awakeFlag) == e_awakeFlag;
679 }
680 
681 inline bool b2Body::IsActive() const
682 {
683  return (m_flags & e_activeFlag) == e_activeFlag;
684 }
685 
686 inline bool b2Body::IsFixedRotation() const
687 {
688  return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
689 }
690 
691 inline void b2Body::SetSleepingAllowed(bool flag)
692 {
693  if (flag)
694  {
695  m_flags |= e_autoSleepFlag;
696  }
697  else
698  {
699  m_flags &= ~e_autoSleepFlag;
700  SetAwake(true);
701  }
702 }
703 
704 inline bool b2Body::IsSleepingAllowed() const
705 {
706  return (m_flags & e_autoSleepFlag) == e_autoSleepFlag;
707 }
708 
710 {
711  return m_fixtureList;
712 }
713 
714 inline const b2Fixture* b2Body::GetFixtureList() const
715 {
716  return m_fixtureList;
717 }
718 
720 {
721  return m_jointList;
722 }
723 
724 inline const b2JointEdge* b2Body::GetJointList() const
725 {
726  return m_jointList;
727 }
728 
730 {
731  return m_contactList;
732 }
733 
734 inline const b2ContactEdge* b2Body::GetContactList() const
735 {
736  return m_contactList;
737 }
738 
740 {
741  return m_next;
742 }
743 
744 inline const b2Body* b2Body::GetNext() const
745 {
746  return m_next;
747 }
748 
749 inline void b2Body::SetUserData(void* data)
750 {
751  m_userData = data;
752 }
753 
754 inline void* b2Body::GetUserData() const
755 {
756  return m_userData;
757 }
758 
759 inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
760 {
761  if (m_type != b2_dynamicBody)
762  {
763  return;
764  }
765 
766  if (wake && (m_flags & e_awakeFlag) == 0)
767  {
768  SetAwake(true);
769  }
770 
771  // Don't accumulate a force if the body is sleeping.
772  if (m_flags & e_awakeFlag)
773  {
774  m_force += force;
775  m_torque += b2Cross(point - m_sweep.c, force);
776  }
777 }
778 
779 inline void b2Body::ApplyForceToCenter(const b2Vec2& force, bool wake)
780 {
781  if (m_type != b2_dynamicBody)
782  {
783  return;
784  }
785 
786  if (wake && (m_flags & e_awakeFlag) == 0)
787  {
788  SetAwake(true);
789  }
790 
791  // Don't accumulate a force if the body is sleeping
792  if (m_flags & e_awakeFlag)
793  {
794  m_force += force;
795  }
796 }
797 
798 inline void b2Body::ApplyTorque(float32 torque, bool wake)
799 {
800  if (m_type != b2_dynamicBody)
801  {
802  return;
803  }
804 
805  if (wake && (m_flags & e_awakeFlag) == 0)
806  {
807  SetAwake(true);
808  }
809 
810  // Don't accumulate a force if the body is sleeping
811  if (m_flags & e_awakeFlag)
812  {
813  m_torque += torque;
814  }
815 }
816 
817 inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
818 {
819  if (m_type != b2_dynamicBody)
820  {
821  return;
822  }
823 
824  if (wake && (m_flags & e_awakeFlag) == 0)
825  {
826  SetAwake(true);
827  }
828 
829  // Don't accumulate velocity if the body is sleeping
830  if (m_flags & e_awakeFlag)
831  {
832  m_linearVelocity += m_invMass * impulse;
833  m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
834  }
835 }
836 
837 inline void b2Body::ApplyAngularImpulse(float32 impulse, bool wake)
838 {
839  if (m_type != b2_dynamicBody)
840  {
841  return;
842  }
843 
844  if (wake && (m_flags & e_awakeFlag) == 0)
845  {
846  SetAwake(true);
847  }
848 
849  // Don't accumulate velocity if the body is sleeping
850  if (m_flags & e_awakeFlag)
851  {
852  m_angularVelocity += m_invI * impulse;
853  }
854 }
855 
856 inline void b2Body::SynchronizeTransform()
857 {
858  m_xf.q.Set(m_sweep.a);
859  m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
860 }
861 
862 inline void b2Body::Advance(float32 alpha)
863 {
864  // Advance to the new safe time. This doesn't sync the broad-phase.
865  m_sweep.Advance(alpha);
866  m_sweep.c = m_sweep.c0;
867  m_sweep.a = m_sweep.a0;
868  m_xf.q.Set(m_sweep.a);
869  m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
870 }
871 
873 {
874  return m_world;
875 }
876 
877 inline const b2World* b2Body::GetWorld() const
878 {
879  return m_world;
880 }
881 
882 #if LIQUIDFUN_EXTERNAL_LANGUAGE_API
883 inline void b2BodyDef::SetPosition(float32 positionX, float32 positionY)
884 {
885  position.Set(positionX, positionY);
886 }
887 
888 inline void b2Body::SetTransform(float32 positionX, float32 positionY, float32 angle)
889 {
890  SetTransform(b2Vec2(positionX, positionY), angle);
891 }
892 #endif // LIQUIDFUN_EXTERNAL_LANGUAGE_API
893 
894 #endif
b2BodyType type
Definition: b2Body.h:80
Definition: b2Math.h:411
void ResetMassData()
Definition: b2Body.cpp:287
b2JointEdge * GetJointList()
Get the list of all joints attached to this body.
Definition: b2Body.h:719
float32 GetInertia() const
Definition: b2Body.h:566
float32 GetAngularDamping() const
Get the angular damping of the body.
Definition: b2Body.h:618
float32 GetAngle() const
Definition: b2Body.h:506
void SetActive(bool flag)
Definition: b2Body.cpp:461
Definition: b2RopeJoint.h:58
bool active
Does this body start out active?
Definition: b2Body.h:122
b2ContactEdge * GetContactList()
Definition: b2Body.h:729
float32 GetAngularVelocity() const
Definition: b2Body.h:556
float32 angularDamping
Definition: b2Body.h:103
float32 GetGravityScale() const
Get the gravity scale of the body.
Definition: b2Body.h:628
void SetGravityScale(float32 scale)
Set the gravity scale of the body.
Definition: b2Body.h:633
void GetMassData(b2MassData *data) const
Definition: b2Body.h:571
void SetAwake(bool flag)
Definition: b2Body.h:655
Definition: b2MotorJoint.h:59
b2BodyType GetType() const
Get the type of this body.
Definition: b2Body.h:491
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
Definition: b2Body.h:583
float32 GetLinearDamping() const
Get the linear damping of the body.
Definition: b2Body.h:608
float32 I
The rotational inertia of the shape about the local origin.
Definition: b2Shape.h:37
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition: b2Body.h:113
void SetTransform(const b2Vec2 &position, float32 angle)
Definition: b2Body.cpp:423
void SetBullet(bool flag)
Should this body be treated like a bullet for continuous collision detection?
Definition: b2Body.h:638
Definition: b2Body.h:52
void SetAngularDamping(float32 angularDamping)
Set the angular damping of the body.
Definition: b2Body.h:623
b2Body * GetNext()
Get the next body in the world's body list.
Definition: b2Body.h:739
void * userData
Use this to store application specific body data.
Definition: b2Body.h:125
b2Vec2 position
Definition: b2Body.h:84
const b2Vec2 & GetLinearVelocity() const
Definition: b2Body.h:536
bool bullet
Definition: b2Body.h:119
b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2 &localPoint) const
Definition: b2Body.h:603
Definition: b2World.h:44
Definition: b2ParticleSystem.h:281
void ApplyAngularImpulse(float32 impulse, bool wake)
Definition: b2Body.h:837
float32 linearDamping
Definition: b2Body.h:98
Definition: b2Math.h:455
void SetLinearVelocity(const b2Vec2 &v)
Definition: b2Body.h:521
Definition: b2Joint.h:103
This holds the mass data computed for a shape.
Definition: b2Shape.h:28
void SetUserData(void *data)
Set the user data. Use this to store your application specific data.
Definition: b2Body.h:749
Definition: b2Shape.h:43
bool IsFixedRotation() const
Does this body have fixed rotation?
Definition: b2Body.h:686
void SetMassData(const b2MassData *data)
Definition: b2Body.cpp:359
b2Vec2 GetLocalVector(const b2Vec2 &worldVector) const
Definition: b2Body.h:593
float32 a
world angles
Definition: b2Math.h:470
Definition: b2PrismaticJoint.h:86
Definition: b2WeldJoint.h:62
void DestroyFixture(b2Fixture *fixture)
Definition: b2Body.cpp:216
Definition: b2MouseJoint.h:60
b2Fixture * CreateFixture(const b2FixtureDef *def)
Definition: b2Body.cpp:168
float32 GetMass() const
Definition: b2Body.h:561
float32 gravityScale
Scale the gravity applied to this body.
Definition: b2Body.h:128
bool IsActive() const
Get the active state of the body.
Definition: b2Body.h:681
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:68
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:65
void SetType(b2BodyType type)
Set the type of this body. This may alter the mass and velocity.
Definition: b2Body.cpp:115
Definition: b2Contact.h:66
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
Definition: b2Body.h:650
Definition: b2Fixture.h:57
void ApplyForceToCenter(const b2Vec2 &force, bool wake)
Definition: b2Body.h:779
Definition: b2GearJoint.h:56
b2Fixture * GetFixtureList()
Get the list of all fixtures attached to this body.
Definition: b2Body.h:709
Definition: b2FrictionJoint.h:55
A group of particles. b2ParticleGroup::CreateParticleGroup creates these.
Definition: b2ParticleGroup.h:172
void SetFixedRotation(bool flag)
Definition: b2Body.cpp:506
bool awake
Is this body initially awake or sleeping?
Definition: b2Body.h:110
float32 mass
The mass of the shape, usually in kilograms.
Definition: b2Shape.h:31
bool IsSleepingAllowed() const
Is this body allowed to sleep.
Definition: b2Body.h:704
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
Definition: b2Shape.h:34
b2Vec2 c
center world positions
Definition: b2Math.h:469
void * GetUserData() const
Get the user data pointer that was provided in the body definition.
Definition: b2Body.h:754
b2World * GetWorld()
Get the parent world of this body.
Definition: b2Body.h:872
b2Vec2 localCenter
local center of mass position
Definition: b2Math.h:468
Definition: b2DistanceJoint.h:67
b2BodyDef()
This constructor sets the body definition default values.
Definition: b2Body.h:55
void ApplyLinearImpulse(const b2Vec2 &impulse, const b2Vec2 &point, bool wake)
Definition: b2Body.h:817
void SetLinearDamping(float32 linearDamping)
Set the linear damping of the body.
Definition: b2Body.h:613
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition: b2Body.h:578
float32 angle
The world angle of the body in radians.
Definition: b2Body.h:87
b2Vec2 linearVelocity
The linear velocity of the body's origin in world co-ordinates.
Definition: b2Body.h:90
Definition: b2RevoluteJoint.h:90
void SetSleepingAllowed(bool flag)
Definition: b2Body.h:691
Definition: b2Joint.h:65
float32 angularVelocity
The angular velocity of the body.
Definition: b2Body.h:93
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:132
This is an internal class.
Definition: b2Island.h:34
bool IsAwake() const
Definition: b2Body.h:676
const b2Transform & GetTransform() const
Definition: b2Body.h:496
const b2Vec2 & GetLocalCenter() const
Get the local position of the center of mass.
Definition: b2Body.h:516
void ApplyForce(const b2Vec2 &force, const b2Vec2 &point, bool wake)
Definition: b2Body.h:759
const b2Vec2 & GetPosition() const
Definition: b2Body.h:501
void ApplyTorque(float32 torque, bool wake)
Definition: b2Body.h:798
b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2 &worldPoint) const
Definition: b2Body.h:598
A 2D column vector.
Definition: b2Math.h:56
Definition: b2Contact.h:77
void Advance(float32 alpha)
Definition: b2Math.h:782
void Set(float32 angle)
Set using an angle in radians.
Definition: b2Math.h:373
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition: b2Body.h:588
void SetAngularVelocity(float32 omega)
Definition: b2Body.h:541
Definition: b2ContactManager.h:31
Definition: b2ContactSolver.h:69
Definition: b2PulleyJoint.h:79
Definition: b2WheelJoint.h:79
const b2Vec2 & GetWorldCenter() const
Get the world position of the center of mass.
Definition: b2Body.h:511
void Dump()
Dump this body to a log file.
Definition: b2Body.cpp:528
bool allowSleep
Definition: b2Body.h:107
Definition: b2Fixture.h:108