Go to the documentation of this file.
264 if (edge->
other == bodyA)
358 if (collideConnected ==
false)
363 if (edge->
other == bodyA)
410 b->m_flags &= ~
b2Body::e_islandFlag;
418 j->m_islandFlag =
false;
431 if (seed->IsAwake() ==
false || seed->IsEnabled() ==
false)
444 int32 stackCount = 0;
445 stack[stackCount++] = seed;
449 while (stackCount > 0)
452 b2Body* b = stack[--stackCount];
487 if (sensorA || sensorB)
495 b2Body* other = ce->other;
504 stack[stackCount++] = other;
511 if (je->joint->m_islandFlag ==
true)
516 b2Body* other = je->other;
524 island.
Add(je->joint);
525 je->joint->m_islandFlag =
true;
533 stack[stackCount++] = other;
575 b->SynchronizeFixtures();
593 b->m_flags &= ~
b2Body::e_islandFlag;
611 float minAlpha = 1.0f;
616 if (c->IsEnabled() ==
false)
655 if (activeA ==
false && activeB ==
false)
664 if (collideA ==
false && collideB ==
false)
686 int32 indexA = c->GetChildIndexA();
687 int32 indexB = c->GetChildIndexB();
701 float beta = output.
t;
704 alpha =
b2Min(alpha0 + (1.0
f - alpha0) * beta, 1.0
f);
715 if (alpha < minAlpha)
723 if (minContact ==
nullptr || 1.0
f - 10.0
f *
b2_epsilon < minAlpha)
766 island.
Add(minContact);
773 b2Body* bodies[2] = {bA, bB};
774 for (
int32 i = 0; i < 2; ++i)
800 b2Body* other = ce->other;
810 if (sensorA || sensorB)
865 subStep.
dt = (1.0f - minAlpha) *
step.dt;
920 step.velocityIterations = velocityIterations;
921 step.positionIterations = positionIterations;
924 step.inv_dt = 1.0f / dt;
977 body->m_force.SetZero();
978 body->m_torque = 0.0f;
1011 bool hit = fixture->
RayCast(&output, input, index);
1016 b2Vec2 point = (1.0f - fraction) * input.
p1 + fraction * input.
p2;
1077 for (
int32 i = 1; i < count; ++i)
1093 for (
int32 i = 0; i < vertexCount; ++i)
1121 for (
b2Fixture*
f = b->GetFixtureList();
f;
f =
f->GetNext())
1128 else if (b->IsEnabled() ==
false)
1140 else if (b->IsAwake() ==
false)
1167 int32 indexA = c->GetChildIndexA();
1168 int32 indexB = c->GetChildIndexB();
1183 if (b->IsEnabled() ==
false)
1188 for (
b2Fixture*
f = b->GetFixtureList();
f;
f =
f->GetNext())
1190 for (
int32 i = 0; i <
f->m_proxyCount; ++i)
1211 xf.
p = b->GetWorldCenter();
1247 b->m_xf.p -= newOrigin;
1248 b->m_sweep.c0 -= newOrigin;
1249 b->m_sweep.c -= newOrigin;
1254 j->ShiftOrigin(newOrigin);
1270 b2Dump(
"m_world->SetGravity(g);\n");
1272 b2Dump(
"b2Body** bodies = (b2Body**)b2Alloc(%d * sizeof(b2Body*));\n",
m_bodyCount);
1273 b2Dump(
"b2Joint** joints = (b2Joint**)b2Alloc(%d * sizeof(b2Joint*));\n",
m_jointCount);
1278 b->m_islandIndex = i;
1316 b2Dump(
"b2Free(joints);\n");
1317 b2Dump(
"b2Free(bodies);\n");
1318 b2Dump(
"joints = nullptr;\n");
1319 b2Dump(
"bodies = nullptr;\n");
void SetDebugDraw(b2Draw *debugDraw)
b2StackAllocator m_stackAllocator
b2Joint * GetNext()
Get the next joint the world joint list.
void DestroyProxies(b2BroadPhase *broadPhase)
void ShiftOrigin(const b2Vec2 &newOrigin)
void SynchronizeTransform()
int32 m_count
The vertex count.
void Free(void *p, int32 size)
Free memory. This will use b2Free if the size is larger than b2_maxBlockSize.
virtual bool ReportFixture(b2Fixture *fixture)=0
void QueryAABB(b2QueryCallback *callback, const b2AABB &aabb) const
b2BodyType GetType() const
Get the type of this body.
b2Vec2 m_vertices[b2_maxPolygonVertices]
void Solve(const b2TimeStep &step)
void * GetUserData(int32 proxyId) const
Get user data from a proxy. Returns nullptr if the id is invalid.
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
virtual float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction)=0
void Advance(float alpha)
void SynchronizeFixtures()
void * Allocate(int32 size)
Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize.
int32 GetProxyCount() const
Get the number of proxies.
b2Body * other
provides quick access to the other body attached.
virtual void DrawTransform(const b2Transform &xf)=0
void DebugDraw()
Call this to draw shapes and other debug draw data. This is intentionally non-const.
static void Destroy(b2Joint *joint, b2BlockAllocator *allocator)
const b2AABB & GetAABB(int32 childIndex) const
virtual void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color)=0
Draw a line segment.
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
b2Vec2 GetCenter() const
Get the center of the AABB.
virtual void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)=0
Draw a closed polygon provided in CCW order.
bool QueryCallback(int32 proxyId)
uint32 GetFlags() const
Get the drawing flags.
A rigid body. These are created via b2World::CreateBody.
void DestroyJoint(b2Joint *joint)
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
void b2Dump(const char *string,...)
b2JointEdge * m_jointList
~b2World()
Destruct the world. All physics entities are destroyed and all heap memory is released.
b2ContactEdge * m_contactList
void Set(float x_, float y_)
Set this vector to some specified coordinates.
bool IsEnabled() const
Get the active state of the body.
b2Vec2 upperBound
the upper vertex
virtual void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)=0
Draw a solid closed polygon provided in CCW order.
void Step(float timeStep, int32 velocityIterations, int32 positionIterations)
This proxy is used internally to connect fixtures to the broad-phase.
const b2BroadPhase * broadPhase
void SolveTOI(const b2TimeStep &step)
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, int32 childIndex) const
virtual void DrawSolidCircle(const b2Vec2 ¢er, float radius, const b2Vec2 &axis, const b2Color &color)=0
Draw a solid circle.
virtual void DrawPoint(const b2Vec2 &p, float size, const b2Color &color)=0
Draw a point.
b2ContactManager m_contactManager
@ e_centerOfMassBit
draw center of mass frame
int32 GetProxyCount() const
Get the number of broad-phase proxies.
b2Joint * CreateJoint(const b2JointDef *def)
int32 GetTreeBalance() const
Get the balance of the embedded tree.
Output parameters for b2TimeOfImpact.
virtual void SayGoodbye(b2Joint *joint)=0
Joint definitions are used to construct joints.
This is an internal class.
void ShiftOrigin(const b2Vec2 &newOrigin)
void RayCast(b2RayCastCallback *callback, const b2Vec2 &point1, const b2Vec2 &point2) const
bool collideConnected
Set this flag to true if the attached bodies should collide.
Color for debug drawing. Each value has the range [0,1].
b2Fixture * m_fixtureList
@ e_jointBit
draw joint connections
bool IsLocked() const
Is the world locked (in the middle of a time step).
void SolveTOI(const b2TimeStep &subStep, int32 toiIndexA, int32 toiIndexB)
b2Body * GetNext()
Get the next body in the world's body list.
int32 GetTreeBalance() const
Get the balance of the dynamic tree.
b2QueryCallback * callback
float GetTreeQuality() const
Get the quality metric of the embedded tree.
#define b2_maxTOIContacts
Maximum number of contacts to be handled to solve a TOI impact.
void Destroy(b2BlockAllocator *allocator)
int32 GetTreeHeight() const
Get the height of the embedded tree.
b2JointEdge * prev
the previous joint edge in the body's joint list
b2BlockAllocator m_blockAllocator
B2_API void b2TimeOfImpact(b2TOIOutput *output, const b2TOIInput *input)
float GetMilliseconds() const
Get the time since construction or the last reset.
An axis aligned bounding box.
b2Body * CreateBody(const b2BodyDef *def)
b2Vec2 m_vertex1
These are the edge vertices.
Profiling data. Times are in milliseconds.
void Query(T *callback, const b2AABB &aabb) const
b2ContactEdge * GetContactList()
void DestroyBody(b2Body *body)
b2JointEdge * next
the next joint edge in the body's joint list
void RayCast(T *callback, const b2RayCastInput &input) const
void * Allocate(int32 size)
b2DestructionListener * m_destructionListener
This is an internal structure.
@ e_aabbBit
draw axis aligned bounding boxes
void SetContactListener(b2ContactListener *listener)
void Set(const b2Shape *shape, int32 index)
#define b2_maxSubSteps
Maximum number of sub-steps per contact in continuous physics simulation.
int32 GetTreeHeight() const
Get the height of the dynamic tree.
b2World(const b2Vec2 &gravity)
b2Vec2 * m_vertices
The vertices. Owned by this class.
b2Shape::Type GetType() const
void b2OpenDump(const char *fileName)
Dump to a file. Only one dump file allowed at a time.
const b2BroadPhase * broadPhase
void SetDestructionListener(b2DestructionListener *listener)
@ e_pairBit
draw broad-phase pairs
static b2Joint * Create(const b2JointDef *def, b2BlockAllocator *allocator)
b2RayCastCallback * callback
b2Body * bodyA
The first attached body.
bool m_oneSided
Uses m_vertex0 and m_vertex3 to create smooth collision.
b2Vec2 lowerBound
the lower vertex
#define b2_maxPolygonVertices
void SetAllowSleeping(bool flag)
Enable/disable sleep.
void Solve(b2Profile *profile, const b2TimeStep &step, const b2Vec2 &gravity, bool allowSleep)
void SetContactFilter(b2ContactFilter *filter)
float RayCastCallback(const b2RayCastInput &input, int32 proxyId)
void DrawShape(b2Fixture *shape, const b2Transform &xf, const b2Color &color)
float GetTreeQuality() const
b2Body * bodyB
The second attached body.
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07