Box2D: /build/box2d/src/box2d-2.4.2/include/box2d/b2_body.h Source File

| Box2D 2.4.1 A 2D physics engine for games

Loading...
Searching...
No Matches
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
30class b2Fixture;
31class b2Joint;
32class b2Contact;
33class b2Controller;
34class b2World;
35struct b2FixtureDef;
36struct b2JointEdge;
37struct b2ContactEdge;
38
43enum b2BodyType
44{
45 b2_staticBody = 0,
46 b2_kinematicBody,
47 b2_dynamicBody
48};
49
52 struct B2_API b2BodyDef
53{
55 b2BodyDef()
56 {
57 position.Set(0.0f, 0.0f);
58 angle = 0.0f;
59 linearVelocity.Set(0.0f, 0.0f);
60 angularVelocity = 0.0f;
61 linearDamping = 0.0f;
62 angularDamping = 0.0f;
63 allowSleep = true;
64 awake = true;
65 fixedRotation = false;
66 bullet = false;
67 type = b2_staticBody;
68 enabled = true;
69 gravityScale = 1.0f;
70 }
71
74 b2BodyType type;
75
78 b2Vec2 position;
79
81 float angle;
82
84 b2Vec2 linearVelocity;
85
87 float angularVelocity;
88
93 float linearDamping;
94
99 float angularDamping;
100
103 bool allowSleep;
104
106 bool awake;
107
109 bool fixedRotation;
110
115 bool bullet;
116
118 bool enabled;
119
121 b2BodyUserData userData;
122
124 float gravityScale;
125};
126
128 class B2_API b2Body
129{
130public:
138 b2Fixture* CreateFixture(const b2FixtureDef* def);
139
147 b2Fixture* CreateFixture(const b2Shape* shape, float density);
148
156 void DestroyFixture(b2Fixture* fixture);
157
163 void SetTransform(const b2Vec2& position, float angle);
164
167 const b2Transform& GetTransform() const;
168
171 const b2Vec2& GetPosition() const;
172
175 float GetAngle() const;
176
178 const b2Vec2& GetWorldCenter() const;
179
181 const b2Vec2& GetLocalCenter() const;
182
185 void SetLinearVelocity(const b2Vec2& v);
186
189 const b2Vec2& GetLinearVelocity() const;
190
193 void SetAngularVelocity(float omega);
194
197 float GetAngularVelocity() const;
198
205 void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake);
206
210 void ApplyForceToCenter(const b2Vec2& force, bool wake);
211
216 void ApplyTorque(float torque, bool wake);
217
224 void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
225
229 void ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake);
230
234 void ApplyAngularImpulse(float impulse, bool wake);
235
238 float GetMass() const;
239
242 float GetInertia() const;
243
246 b2MassData GetMassData() 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 float GetLinearDamping() const;
292
294 void SetLinearDamping(float linearDamping);
295
297 float GetAngularDamping() const;
298
300 void SetAngularDamping(float angularDamping);
301
303 float GetGravityScale() const;
304
306 void SetGravityScale(float 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
348 void SetEnabled(bool flag);
349
351 bool IsEnabled() const;
352
355 void SetFixedRotation(bool flag);
356
358 bool IsFixedRotation() const;
359
361 b2Fixture* GetFixtureList();
362 const b2Fixture* GetFixtureList() const;
363
365 b2JointEdge* GetJointList();
366 const b2JointEdge* GetJointList() const;
367
371 b2ContactEdge* GetContactList();
372 const b2ContactEdge* GetContactList() const;
373
375 b2Body* GetNext();
376 const b2Body* GetNext() const;
377
379 b2BodyUserData& GetUserData();
380 const b2BodyUserData& GetUserData() const;
381
383 b2World* GetWorld();
384 const b2World* GetWorld() const;
385
387 void Dump();
388
389private:
390
391 friend class b2World;
392 friend class b2Island;
393 friend class b2ContactManager;
394 friend class b2ContactSolver;
395 friend class b2Contact;
396
397 friend class b2DistanceJoint;
398 friend class b2FrictionJoint;
399 friend class b2GearJoint;
400 friend class b2MotorJoint;
401 friend class b2MouseJoint;
402 friend class b2PrismaticJoint;
403 friend class b2PulleyJoint;
404 friend class b2RevoluteJoint;
405 friend class b2WeldJoint;
406 friend class b2WheelJoint;
407
408 // m_flags
409 enum
410 {
411 e_islandFlag = 0x0001,
412 e_awakeFlag = 0x0002,
413 e_autoSleepFlag = 0x0004,
414 e_bulletFlag = 0x0008,
415 e_fixedRotationFlag = 0x0010,
416 e_enabledFlag = 0x0020,
417 e_toiFlag = 0x0040
418 };
419
420 b2Body(const b2BodyDef* bd, b2World* world);
421 ~b2Body();
422
423 void SynchronizeFixtures();
424 void SynchronizeTransform();
425
426 // This is used to prevent connected bodies from colliding.
427 // It may lie, depending on the collideConnected flag.
428 bool ShouldCollide(const b2Body* other) const;
429
430 void Advance(float t);
431
432 b2BodyType m_type;
433
434 uint16 m_flags;
435
436 int32 m_islandIndex;
437
438 b2Transform m_xf; // the body origin transform
439 b2Sweep m_sweep; // the swept motion for CCD
440
441 b2Vec2 m_linearVelocity;
442 float m_angularVelocity;
443
444 b2Vec2 m_force;
445 float m_torque;
446
447 b2World* m_world;
448 b2Body* m_prev;
449 b2Body* m_next;
450
451 b2Fixture* m_fixtureList;
452 int32 m_fixtureCount;
453
454 b2JointEdge* m_jointList;
455 b2ContactEdge* m_contactList;
456
457 float m_mass, m_invMass;
458
459 // Rotational inertia about the center of mass.
460 float m_I, m_invI;
461
462 float m_linearDamping;
463 float m_angularDamping;
464 float m_gravityScale;
465
466 float m_sleepTime;
467
468 b2BodyUserData m_userData;
469};
470
471 inline b2BodyType b2Body::GetType() const
472{
473 return m_type;
474}
475
476 inline const b2Transform& b2Body::GetTransform() const
477{
478 return m_xf;
479}
480
481 inline const b2Vec2& b2Body::GetPosition() const
482{
483 return m_xf.p;
484}
485
486 inline float b2Body::GetAngle() const
487{
488 return m_sweep.a;
489}
490
491 inline const b2Vec2& b2Body::GetWorldCenter() const
492{
493 return m_sweep.c;
494}
495
496 inline const b2Vec2& b2Body::GetLocalCenter() const
497{
498 return m_sweep.localCenter;
499}
500
501 inline void b2Body::SetLinearVelocity(const b2Vec2& v)
502{
503 if (m_type == b2_staticBody)
504 {
505 return;
506 }
507
508 if (b2Dot(v,v) > 0.0f)
509 {
510 SetAwake(true);
511 }
512
513 m_linearVelocity = v;
514}
515
516 inline const b2Vec2& b2Body::GetLinearVelocity() const
517{
518 return m_linearVelocity;
519}
520
521 inline void b2Body::SetAngularVelocity(float w)
522{
523 if (m_type == b2_staticBody)
524 {
525 return;
526 }
527
528 if (w * w > 0.0f)
529 {
530 SetAwake(true);
531 }
532
533 m_angularVelocity = w;
534}
535
536 inline float b2Body::GetAngularVelocity() const
537{
538 return m_angularVelocity;
539}
540
541 inline float b2Body::GetMass() const
542{
543 return m_mass;
544}
545
546 inline float b2Body::GetInertia() const
547{
548 return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
549}
550
551 inline b2MassData b2Body::GetMassData() const
552{
553 b2MassData data;
554 data.mass = m_mass;
555 data.I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
556 data.center = m_sweep.localCenter;
557 return data;
558}
559
560 inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const
561{
562 return b2Mul(m_xf, localPoint);
563}
564
565 inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const
566{
567 return b2Mul(m_xf.q, localVector);
568}
569
570 inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const
571{
572 return b2MulT(m_xf, worldPoint);
573}
574
575 inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const
576{
577 return b2MulT(m_xf.q, worldVector);
578}
579
580 inline b2Vec2 b2Body::GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const
581{
582 return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c);
583}
584
585 inline b2Vec2 b2Body::GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const
586{
587 return GetLinearVelocityFromWorldPoint(GetWorldPoint(localPoint));
588}
589
590 inline float b2Body::GetLinearDamping() const
591{
592 return m_linearDamping;
593}
594
595 inline void b2Body::SetLinearDamping(float linearDamping)
596{
597 m_linearDamping = linearDamping;
598}
599
600 inline float b2Body::GetAngularDamping() const
601{
602 return m_angularDamping;
603}
604
605 inline void b2Body::SetAngularDamping(float angularDamping)
606{
607 m_angularDamping = angularDamping;
608}
609
610 inline float b2Body::GetGravityScale() const
611{
612 return m_gravityScale;
613}
614
615 inline void b2Body::SetGravityScale(float scale)
616{
617 m_gravityScale = scale;
618}
619
620 inline void b2Body::SetBullet(bool flag)
621{
622 if (flag)
623 {
624 m_flags |= e_bulletFlag;
625 }
626 else
627 {
628 m_flags &= ~e_bulletFlag;
629 }
630}
631
632 inline bool b2Body::IsBullet() const
633{
634 return (m_flags & e_bulletFlag) == e_bulletFlag;
635}
636
637 inline void b2Body::SetAwake(bool flag)
638{
639 if (m_type == b2_staticBody)
640 {
641 return;
642 }
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::IsEnabled() const
666{
667 return (m_flags & e_enabledFlag) == e_enabledFlag;
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
693 inline b2Fixture* b2Body::GetFixtureList()
694{
695 return m_fixtureList;
696}
697
698inline const b2Fixture* b2Body::GetFixtureList() const
699{
700 return m_fixtureList;
701}
702
703 inline b2JointEdge* b2Body::GetJointList()
704{
705 return m_jointList;
706}
707
708inline const b2JointEdge* b2Body::GetJointList() const
709{
710 return m_jointList;
711}
712
713 inline b2ContactEdge* b2Body::GetContactList()
714{
715 return m_contactList;
716}
717
718inline const b2ContactEdge* b2Body::GetContactList() const
719{
720 return m_contactList;
721}
722
723 inline b2Body* b2Body::GetNext()
724{
725 return m_next;
726}
727
728inline const b2Body* b2Body::GetNext() const
729{
730 return m_next;
731}
732
733 inline b2BodyUserData& b2Body::GetUserData()
734{
735 return m_userData;
736}
737
738inline const b2BodyUserData& 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
859inline 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
865inline 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
875 inline b2World* b2Body::GetWorld()
876{
877 return m_world;
878}
879
880inline const b2World* b2Body::GetWorld() const
881{
882 return m_world;
883}
884
885#endif
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition b2_body.h:129
b2Body::IsEnabled
bool IsEnabled() const
Get the active state of the body.
Definition b2_body.h:665
b2Body::SetEnabled
void SetEnabled(bool flag)
b2Body::IsFixedRotation
bool IsFixedRotation() const
Does this body have fixed rotation?
Definition b2_body.h:670
b2Body::GetLinearVelocityFromLocalPoint
b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2 &localPoint) const
Definition b2_body.h:585
b2Body::GetLocalPoint
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition b2_body.h:570
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2Shape *shape, float density)
b2Body::ResetMassData
void ResetMassData()
b2Body::GetUserData
b2BodyUserData & GetUserData()
Get the user data pointer that was provided in the body definition.
Definition b2_body.h:733
b2Body::GetContactList
b2ContactEdge * GetContactList()
Definition b2_body.h:713
b2Body::GetAngularDamping
float GetAngularDamping() const
Get the angular damping of the body.
Definition b2_body.h:600
b2Body::ApplyAngularImpulse
void ApplyAngularImpulse(float impulse, bool wake)
Definition b2_body.h:840
b2Body::SetAngularVelocity
void SetAngularVelocity(float omega)
Definition b2_body.h:521
b2Body::SetSleepingAllowed
void SetSleepingAllowed(bool flag)
Definition b2_body.h:675
b2Body::SetBullet
void SetBullet(bool flag)
Should this body be treated like a bullet for continuous collision detection?
Definition b2_body.h:620
b2Body::SetType
void SetType(b2BodyType type)
Set the type of this body. This may alter the mass and velocity.
b2Body::GetWorldCenter
const b2Vec2 & GetWorldCenter() const
Get the world position of the center of mass.
Definition b2_body.h:491
b2Body::GetJointList
b2JointEdge * GetJointList()
Get the list of all joints attached to this body.
Definition b2_body.h:703
b2Body::SetMassData
void SetMassData(const b2MassData *data)
b2Body::GetLinearVelocityFromWorldPoint
b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2 &worldPoint) const
Definition b2_body.h:580
b2Body::GetLocalCenter
const b2Vec2 & GetLocalCenter() const
Get the local position of the center of mass.
Definition b2_body.h:496
b2Body::GetFixtureList
b2Fixture * GetFixtureList()
Get the list of all fixtures attached to this body.
Definition b2_body.h:693
b2Body::IsAwake
bool IsAwake() const
Definition b2_body.h:660
b2Body::GetLinearDamping
float GetLinearDamping() const
Get the linear damping of the body.
Definition b2_body.h:590
b2Body::GetWorldPoint
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition b2_body.h:560
b2Body::GetAngularVelocity
float GetAngularVelocity() const
Definition b2_body.h:536
b2Body::GetPosition
const b2Vec2 & GetPosition() const
Definition b2_body.h:481
b2Body::ApplyLinearImpulse
void ApplyLinearImpulse(const b2Vec2 &impulse, const b2Vec2 &point, bool wake)
Definition b2_body.h:801
b2Body::SetAngularDamping
void SetAngularDamping(float angularDamping)
Set the angular damping of the body.
Definition b2_body.h:605
b2Body::SetLinearVelocity
void SetLinearVelocity(const b2Vec2 &v)
Definition b2_body.h:501
b2Body::DestroyFixture
void DestroyFixture(b2Fixture *fixture)
b2Body::GetMass
float GetMass() const
Definition b2_body.h:541
b2Body::GetMassData
b2MassData GetMassData() const
Definition b2_body.h:551
b2Body::GetGravityScale
float GetGravityScale() const
Get the gravity scale of the body.
Definition b2_body.h:610
b2Body::GetLinearVelocity
const b2Vec2 & GetLinearVelocity() const
Definition b2_body.h:516
b2Body::SetGravityScale
void SetGravityScale(float scale)
Set the gravity scale of the body.
Definition b2_body.h:615
b2Body::ApplyForce
void ApplyForce(const b2Vec2 &force, const b2Vec2 &point, bool wake)
Definition b2_body.h:743
b2Body::GetType
b2BodyType GetType() const
Get the type of this body.
Definition b2_body.h:471
b2Body::SetLinearDamping
void SetLinearDamping(float linearDamping)
Set the linear damping of the body.
Definition b2_body.h:595
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2FixtureDef *def)
b2Body::GetAngle
float GetAngle() const
Definition b2_body.h:486
b2Body::ApplyForceToCenter
void ApplyForceToCenter(const b2Vec2 &force, bool wake)
Definition b2_body.h:763
b2Body::GetWorld
b2World * GetWorld()
Get the parent world of this body.
Definition b2_body.h:875
b2Body::SetTransform
void SetTransform(const b2Vec2 &position, float angle)
b2Body::IsSleepingAllowed
bool IsSleepingAllowed() const
Is this body allowed to sleep.
Definition b2_body.h:688
b2Body::SetAwake
void SetAwake(bool flag)
Definition b2_body.h:637
b2Body::Dump
void Dump()
Dump this body to a file.
b2Body::ApplyTorque
void ApplyTorque(float torque, bool wake)
Definition b2_body.h:782
b2Body::GetNext
b2Body * GetNext()
Get the next body in the world's body list.
Definition b2_body.h:723
b2Body::IsBullet
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
Definition b2_body.h:632
b2Body::GetWorldVector
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
Definition b2_body.h:565
b2Body::GetInertia
float GetInertia() const
Definition b2_body.h:546
b2Body::GetLocalVector
b2Vec2 GetLocalVector(const b2Vec2 &worldVector) const
Definition b2_body.h:575
b2Body::ApplyLinearImpulseToCenter
void ApplyLinearImpulseToCenter(const b2Vec2 &impulse, bool wake)
Definition b2_body.h:821
b2Body::GetTransform
const b2Transform & GetTransform() const
Definition b2_body.h:476
b2Body::SetFixedRotation
void SetFixedRotation(bool flag)
b2Contact
Definition b2_contact.h:89
b2ContactManager
Definition b2_contact_manager.h:36
b2DistanceJoint
Definition b2_distance_joint.h:77
b2Fixture
Definition b2_fixture.h:117
b2FrictionJoint
Definition b2_friction_joint.h:61
b2GearJoint
Definition b2_gear_joint.h:62
b2Joint
Definition b2_joint.h:110
b2MotorJoint
Definition b2_motor_joint.h:65
b2MouseJoint
Definition b2_mouse_joint.h:66
b2PrismaticJoint
Definition b2_prismatic_joint.h:92
b2PulleyJoint
Definition b2_pulley_joint.h:85
b2RevoluteJoint
Definition b2_revolute_joint.h:95
b2Shape
Definition b2_shape.h:49
b2WeldJoint
Definition b2_weld_joint.h:70
b2WheelJoint
Definition b2_wheel_joint.h:96
b2World
Definition b2_world.h:47
b2BodyDef
Definition b2_body.h:53
b2BodyDef::allowSleep
bool allowSleep
Definition b2_body.h:103
b2BodyDef::awake
bool awake
Is this body initially awake or sleeping?
Definition b2_body.h:106
b2BodyDef::linearVelocity
b2Vec2 linearVelocity
The linear velocity of the body's origin in world co-ordinates.
Definition b2_body.h:84
b2BodyDef::fixedRotation
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition b2_body.h:109
b2BodyDef::enabled
bool enabled
Does this body start out enabled?
Definition b2_body.h:118
b2BodyDef::position
b2Vec2 position
Definition b2_body.h:78
b2BodyDef::bullet
bool bullet
Definition b2_body.h:115
b2BodyDef::b2BodyDef
b2BodyDef()
This constructor sets the body definition default values.
Definition b2_body.h:55
b2BodyDef::type
b2BodyType type
Definition b2_body.h:74
b2BodyDef::linearDamping
float linearDamping
Definition b2_body.h:93
b2BodyDef::angularVelocity
float angularVelocity
The angular velocity of the body.
Definition b2_body.h:87
b2BodyDef::angle
float angle
The world angle of the body in radians.
Definition b2_body.h:81
b2BodyDef::gravityScale
float gravityScale
Scale the gravity applied to this body.
Definition b2_body.h:124
b2BodyDef::userData
b2BodyUserData userData
Use this to store application specific body data.
Definition b2_body.h:121
b2BodyDef::angularDamping
float angularDamping
Definition b2_body.h:99
b2BodyUserData
You can define this to inject whatever data you want in b2Body.
Definition b2_settings.h:59
b2ContactEdge
Definition b2_contact.h:78
b2FixtureDef
Definition b2_fixture.h:62
b2JointEdge
Definition b2_joint.h:63
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
b2MassData::mass
float mass
The mass of the shape, usually in kilograms.
Definition b2_shape.h:36
b2MassData::I
float I
The rotational inertia of the shape about the local origin.
Definition b2_shape.h:42
b2Rot::Set
void Set(float angle)
Set using an angle in radians.
Definition b2_math.h:300
b2Sweep
Definition b2_math.h:369
b2Sweep::c
b2Vec2 c
center world positions
Definition b2_math.h:385
b2Sweep::Advance
void Advance(float alpha)
Definition b2_math.h:699
b2Sweep::localCenter
b2Vec2 localCenter
local center of mass position
Definition b2_math.h:384
b2Sweep::a
float a
world angles
Definition b2_math.h:386
b2Transform
Definition b2_math.h:339
b2Vec2
A 2D column vector.
Definition b2_math.h:42
b2Vec2::SetZero
void SetZero()
Set this vector to all zeros.
Definition b2_math.h:50