Box2D: /build/box2d/src/box2d-2.4.1/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 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 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
382 void SetUserData(void* data);
383
385 b2World* GetWorld();
386 const b2World* GetWorld() const;
387
389 void Dump();
390
391private:
392
393 friend class b2World;
394 friend class b2Island;
395 friend class b2ContactManager;
396 friend class b2ContactSolver;
397 friend class b2Contact;
398
399 friend class b2DistanceJoint;
400 friend class b2FrictionJoint;
401 friend class b2GearJoint;
402 friend class b2MotorJoint;
403 friend class b2MouseJoint;
404 friend class b2PrismaticJoint;
405 friend class b2PulleyJoint;
406 friend class b2RevoluteJoint;
407 friend class b2RopeJoint;
408 friend class b2WeldJoint;
409 friend class b2WheelJoint;
410
411 // m_flags
412 enum
413 {
414 e_islandFlag = 0x0001,
415 e_awakeFlag = 0x0002,
416 e_autoSleepFlag = 0x0004,
417 e_bulletFlag = 0x0008,
418 e_fixedRotationFlag = 0x0010,
419 e_enabledFlag = 0x0020,
420 e_toiFlag = 0x0040
421 };
422
423 b2Body(const b2BodyDef* bd, b2World* world);
424 ~b2Body();
425
426 void SynchronizeFixtures();
427 void SynchronizeTransform();
428
429 // This is used to prevent connected bodies from colliding.
430 // It may lie, depending on the collideConnected flag.
431 bool ShouldCollide(const b2Body* other) const;
432
433 void Advance(float t);
434
435 b2BodyType m_type;
436
437 uint16 m_flags;
438
439 int32 m_islandIndex;
440
441 b2Transform m_xf; // the body origin transform
442 b2Sweep m_sweep; // the swept motion for CCD
443
444 b2Vec2 m_linearVelocity;
445 float m_angularVelocity;
446
447 b2Vec2 m_force;
448 float m_torque;
449
450 b2World* m_world;
451 b2Body* m_prev;
452 b2Body* m_next;
453
454 b2Fixture* m_fixtureList;
455 int32 m_fixtureCount;
456
457 b2JointEdge* m_jointList;
458 b2ContactEdge* m_contactList;
459
460 float m_mass, m_invMass;
461
462 // Rotational inertia about the center of mass.
463 float m_I, m_invI;
464
465 float m_linearDamping;
466 float m_angularDamping;
467 float m_gravityScale;
468
469 float m_sleepTime;
470
471 b2BodyUserData m_userData;
472};
473
474 inline b2BodyType b2Body::GetType() const
475{
476 return m_type;
477}
478
479 inline const b2Transform& b2Body::GetTransform() const
480{
481 return m_xf;
482}
483
484 inline const b2Vec2& b2Body::GetPosition() const
485{
486 return m_xf.p;
487}
488
489 inline float b2Body::GetAngle() const
490{
491 return m_sweep.a;
492}
493
494 inline const b2Vec2& b2Body::GetWorldCenter() const
495{
496 return m_sweep.c;
497}
498
499 inline const b2Vec2& b2Body::GetLocalCenter() const
500{
501 return m_sweep.localCenter;
502}
503
504 inline void b2Body::SetLinearVelocity(const b2Vec2& v)
505{
506 if (m_type == b2_staticBody)
507 {
508 return;
509 }
510
511 if (b2Dot(v,v) > 0.0f)
512 {
513 SetAwake(true);
514 }
515
516 m_linearVelocity = v;
517}
518
519 inline const b2Vec2& b2Body::GetLinearVelocity() const
520{
521 return m_linearVelocity;
522}
523
524 inline void b2Body::SetAngularVelocity(float w)
525{
526 if (m_type == b2_staticBody)
527 {
528 return;
529 }
530
531 if (w * w > 0.0f)
532 {
533 SetAwake(true);
534 }
535
536 m_angularVelocity = w;
537}
538
539 inline float b2Body::GetAngularVelocity() const
540{
541 return m_angularVelocity;
542}
543
544 inline float b2Body::GetMass() const
545{
546 return m_mass;
547}
548
549 inline float b2Body::GetInertia() const
550{
551 return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
552}
553
554 inline void b2Body::GetMassData(b2MassData* data) const
555{
556 data->mass = m_mass;
557 data->I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
558 data->center = m_sweep.localCenter;
559}
560
561 inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const
562{
563 return b2Mul(m_xf, localPoint);
564}
565
566 inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const
567{
568 return b2Mul(m_xf.q, localVector);
569}
570
571 inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const
572{
573 return b2MulT(m_xf, worldPoint);
574}
575
576 inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const
577{
578 return b2MulT(m_xf.q, worldVector);
579}
580
581 inline b2Vec2 b2Body::GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const
582{
583 return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c);
584}
585
586 inline b2Vec2 b2Body::GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const
587{
588 return GetLinearVelocityFromWorldPoint(GetWorldPoint(localPoint));
589}
590
591 inline float b2Body::GetLinearDamping() const
592{
593 return m_linearDamping;
594}
595
596 inline void b2Body::SetLinearDamping(float linearDamping)
597{
598 m_linearDamping = linearDamping;
599}
600
601 inline float b2Body::GetAngularDamping() const
602{
603 return m_angularDamping;
604}
605
606 inline void b2Body::SetAngularDamping(float angularDamping)
607{
608 m_angularDamping = angularDamping;
609}
610
611 inline float b2Body::GetGravityScale() const
612{
613 return m_gravityScale;
614}
615
616 inline void b2Body::SetGravityScale(float scale)
617{
618 m_gravityScale = scale;
619}
620
621 inline void b2Body::SetBullet(bool flag)
622{
623 if (flag)
624 {
625 m_flags |= e_bulletFlag;
626 }
627 else
628 {
629 m_flags &= ~e_bulletFlag;
630 }
631}
632
633 inline bool b2Body::IsBullet() const
634{
635 return (m_flags & e_bulletFlag) == e_bulletFlag;
636}
637
638 inline void b2Body::SetAwake(bool flag)
639{
640 if (m_type == b2_staticBody)
641 {
642 return;
643 }
644
645 if (flag)
646 {
647 m_flags |= e_awakeFlag;
648 m_sleepTime = 0.0f;
649 }
650 else
651 {
652 m_flags &= ~e_awakeFlag;
653 m_sleepTime = 0.0f;
654 m_linearVelocity.SetZero();
655 m_angularVelocity = 0.0f;
656 m_force.SetZero();
657 m_torque = 0.0f;
658 }
659}
660
661 inline bool b2Body::IsAwake() const
662{
663 return (m_flags & e_awakeFlag) == e_awakeFlag;
664}
665
666 inline bool b2Body::IsEnabled() const
667{
668 return (m_flags & e_enabledFlag) == e_enabledFlag;
669}
670
671 inline bool b2Body::IsFixedRotation() const
672{
673 return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
674}
675
676 inline void b2Body::SetSleepingAllowed(bool flag)
677{
678 if (flag)
679 {
680 m_flags |= e_autoSleepFlag;
681 }
682 else
683 {
684 m_flags &= ~e_autoSleepFlag;
685 SetAwake(true);
686 }
687}
688
689 inline bool b2Body::IsSleepingAllowed() const
690{
691 return (m_flags & e_autoSleepFlag) == e_autoSleepFlag;
692}
693
694 inline b2Fixture* b2Body::GetFixtureList()
695{
696 return m_fixtureList;
697}
698
699inline const b2Fixture* b2Body::GetFixtureList() const
700{
701 return m_fixtureList;
702}
703
704 inline b2JointEdge* b2Body::GetJointList()
705{
706 return m_jointList;
707}
708
709inline const b2JointEdge* b2Body::GetJointList() const
710{
711 return m_jointList;
712}
713
714 inline b2ContactEdge* b2Body::GetContactList()
715{
716 return m_contactList;
717}
718
719inline const b2ContactEdge* b2Body::GetContactList() const
720{
721 return m_contactList;
722}
723
724 inline b2Body* b2Body::GetNext()
725{
726 return m_next;
727}
728
729inline const b2Body* b2Body::GetNext() const
730{
731 return m_next;
732}
733
734 inline b2BodyUserData& b2Body::GetUserData()
735{
736 return m_userData;
737}
738
739 inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
740{
741 if (m_type != b2_dynamicBody)
742 {
743 return;
744 }
745
746 if (wake && (m_flags & e_awakeFlag) == 0)
747 {
748 SetAwake(true);
749 }
750
751 // Don't accumulate a force if the body is sleeping.
752 if (m_flags & e_awakeFlag)
753 {
754 m_force += force;
755 m_torque += b2Cross(point - m_sweep.c, force);
756 }
757}
758
759 inline void b2Body::ApplyForceToCenter(const b2Vec2& force, 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 }
776}
777
778 inline void b2Body::ApplyTorque(float torque, bool wake)
779{
780 if (m_type != b2_dynamicBody)
781 {
782 return;
783 }
784
785 if (wake && (m_flags & e_awakeFlag) == 0)
786 {
787 SetAwake(true);
788 }
789
790 // Don't accumulate a force if the body is sleeping
791 if (m_flags & e_awakeFlag)
792 {
793 m_torque += torque;
794 }
795}
796
797 inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
798{
799 if (m_type != b2_dynamicBody)
800 {
801 return;
802 }
803
804 if (wake && (m_flags & e_awakeFlag) == 0)
805 {
806 SetAwake(true);
807 }
808
809 // Don't accumulate velocity if the body is sleeping
810 if (m_flags & e_awakeFlag)
811 {
812 m_linearVelocity += m_invMass * impulse;
813 m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
814 }
815}
816
817 inline void b2Body::ApplyLinearImpulseToCenter(const b2Vec2& impulse, 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 }
834}
835
836 inline void b2Body::ApplyAngularImpulse(float impulse, bool wake)
837{
838 if (m_type != b2_dynamicBody)
839 {
840 return;
841 }
842
843 if (wake && (m_flags & e_awakeFlag) == 0)
844 {
845 SetAwake(true);
846 }
847
848 // Don't accumulate velocity if the body is sleeping
849 if (m_flags & e_awakeFlag)
850 {
851 m_angularVelocity += m_invI * impulse;
852 }
853}
854
855inline void b2Body::SynchronizeTransform()
856{
857 m_xf.q.Set(m_sweep.a);
858 m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
859}
860
861inline void b2Body::Advance(float alpha)
862{
863 // Advance to the new safe time. This doesn't sync the broad-phase.
864 m_sweep.Advance(alpha);
865 m_sweep.c = m_sweep.c0;
866 m_sweep.a = m_sweep.a0;
867 m_xf.q.Set(m_sweep.a);
868 m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
869}
870
871 inline b2World* b2Body::GetWorld()
872{
873 return m_world;
874}
875
876inline const b2World* b2Body::GetWorld() const
877{
878 return m_world;
879}
880
881#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:666
b2Body::SetEnabled
void SetEnabled(bool flag)
b2Body::IsFixedRotation
bool IsFixedRotation() const
Does this body have fixed rotation?
Definition b2_body.h:671
b2Body::GetLinearVelocityFromLocalPoint
b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2 &localPoint) const
Definition b2_body.h:586
b2Body::GetLocalPoint
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition b2_body.h:571
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:734
b2Body::GetContactList
b2ContactEdge * GetContactList()
Definition b2_body.h:714
b2Body::GetAngularDamping
float GetAngularDamping() const
Get the angular damping of the body.
Definition b2_body.h:601
b2Body::ApplyAngularImpulse
void ApplyAngularImpulse(float impulse, bool wake)
Definition b2_body.h:836
b2Body::SetAngularVelocity
void SetAngularVelocity(float omega)
Definition b2_body.h:524
b2Body::SetSleepingAllowed
void SetSleepingAllowed(bool flag)
Definition b2_body.h:676
b2Body::SetBullet
void SetBullet(bool flag)
Should this body be treated like a bullet for continuous collision detection?
Definition b2_body.h:621
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:494
b2Body::GetMassData
void GetMassData(b2MassData *data) const
Definition b2_body.h:554
b2Body::SetUserData
void SetUserData(void *data)
Set the user data. Use this to store your application specific data.
b2Body::GetJointList
b2JointEdge * GetJointList()
Get the list of all joints attached to this body.
Definition b2_body.h:704
b2Body::SetMassData
void SetMassData(const b2MassData *data)
b2Body::GetLinearVelocityFromWorldPoint
b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2 &worldPoint) const
Definition b2_body.h:581
b2Body::GetLocalCenter
const b2Vec2 & GetLocalCenter() const
Get the local position of the center of mass.
Definition b2_body.h:499
b2Body::GetFixtureList
b2Fixture * GetFixtureList()
Get the list of all fixtures attached to this body.
Definition b2_body.h:694
b2Body::IsAwake
bool IsAwake() const
Definition b2_body.h:661
b2Body::GetLinearDamping
float GetLinearDamping() const
Get the linear damping of the body.
Definition b2_body.h:591
b2Body::GetWorldPoint
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition b2_body.h:561
b2Body::GetAngularVelocity
float GetAngularVelocity() const
Definition b2_body.h:539
b2Body::GetPosition
const b2Vec2 & GetPosition() const
Definition b2_body.h:484
b2Body::ApplyLinearImpulse
void ApplyLinearImpulse(const b2Vec2 &impulse, const b2Vec2 &point, bool wake)
Definition b2_body.h:797
b2Body::SetAngularDamping
void SetAngularDamping(float angularDamping)
Set the angular damping of the body.
Definition b2_body.h:606
b2Body::SetLinearVelocity
void SetLinearVelocity(const b2Vec2 &v)
Definition b2_body.h:504
b2Body::DestroyFixture
void DestroyFixture(b2Fixture *fixture)
b2Body::GetMass
float GetMass() const
Definition b2_body.h:544
b2Body::GetGravityScale
float GetGravityScale() const
Get the gravity scale of the body.
Definition b2_body.h:611
b2Body::GetLinearVelocity
const b2Vec2 & GetLinearVelocity() const
Definition b2_body.h:519
b2Body::SetGravityScale
void SetGravityScale(float scale)
Set the gravity scale of the body.
Definition b2_body.h:616
b2Body::ApplyForce
void ApplyForce(const b2Vec2 &force, const b2Vec2 &point, bool wake)
Definition b2_body.h:739
b2Body::GetType
b2BodyType GetType() const
Get the type of this body.
Definition b2_body.h:474
b2Body::SetLinearDamping
void SetLinearDamping(float linearDamping)
Set the linear damping of the body.
Definition b2_body.h:596
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2FixtureDef *def)
b2Body::GetAngle
float GetAngle() const
Definition b2_body.h:489
b2Body::ApplyForceToCenter
void ApplyForceToCenter(const b2Vec2 &force, bool wake)
Definition b2_body.h:759
b2Body::GetWorld
b2World * GetWorld()
Get the parent world of this body.
Definition b2_body.h:871
b2Body::SetTransform
void SetTransform(const b2Vec2 &position, float angle)
b2Body::IsSleepingAllowed
bool IsSleepingAllowed() const
Is this body allowed to sleep.
Definition b2_body.h:689
b2Body::SetAwake
void SetAwake(bool flag)
Definition b2_body.h:638
b2Body::Dump
void Dump()
Dump this body to a file.
b2Body::ApplyTorque
void ApplyTorque(float torque, bool wake)
Definition b2_body.h:778
b2Body::GetNext
b2Body * GetNext()
Get the next body in the world's body list.
Definition b2_body.h:724
b2Body::IsBullet
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
Definition b2_body.h:633
b2Body::GetWorldVector
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
Definition b2_body.h:566
b2Body::GetInertia
float GetInertia() const
Definition b2_body.h:549
b2Body::GetLocalVector
b2Vec2 GetLocalVector(const b2Vec2 &worldVector) const
Definition b2_body.h:576
b2Body::ApplyLinearImpulseToCenter
void ApplyLinearImpulseToCenter(const b2Vec2 &impulse, bool wake)
Definition b2_body.h:817
b2Body::GetTransform
const b2Transform & GetTransform() const
Definition b2_body.h:479
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:111
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:64
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:383
b2Sweep::Advance
void Advance(float alpha)
Definition b2_math.h:697
b2Sweep::localCenter
b2Vec2 localCenter
local center of mass position
Definition b2_math.h:382
b2Sweep::a
float a
world angles
Definition b2_math.h:384
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