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;
977 body->m_force.SetZero();
978 body->m_torque = 0.0f;
987 return callback->ReportFixture(proxy->
fixture);
1006 void* userData = broadPhase->GetUserData(proxyId);
1011 bool hit = fixture->
RayCast(&output, input, index);
1016 b2Vec2 point = (1.0f - fraction) * input.
p1 + fraction * input.
p2;
1017 return callback->ReportFixture(fixture, point, output.
normal, fraction);
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");
This is an internal class.
virtual void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color)=0
Draw a line segment.
void b2OpenDump(const char *fileName)
Dump to a file. Only one dump file allowed at a time.
void RayCast(b2RayCastCallback *callback, const b2Vec2 &point1, const b2Vec2 &point2) const
virtual void DrawTransform(const b2Transform &xf)=0
b2Vec2 * m_vertices
The vertices. Owned by this class.
void SynchronizeFixtures()
void Set(const b2Shape *shape, int32 index)
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
static void Destroy(b2Joint *joint, b2BlockAllocator *allocator)
draw center of mass frame
b2ContactManager m_contactManager
float GetTreeQuality() const
Get the quality metric of the embedded tree.
uint32 GetFlags() const
Get the drawing flags.
b2Vec2 lowerBound
the lower vertex
int32 GetTreeBalance() const
Get the balance of the dynamic tree.
void SetAllowSleeping(bool flag)
Enable/disable sleep.
Joint definitions are used to construct joints.
void DrawShape(b2Fixture *shape, const b2Transform &xf, const b2Color &color)
bool IsBullet() const
Is this body treated like a bullet for continuous collision detection?
virtual void DrawSolidCircle(const b2Vec2 ¢er, float radius, const b2Vec2 &axis, const b2Color &color)=0
Draw a solid circle.
B2_API void b2TimeOfImpact(b2TOIOutput *output, const b2TOIInput *input)
b2ContactEdge * GetContactList()
b2JointEdge * prev
the previous joint edge in the body's joint list
b2ContactEdge * m_contactList
virtual void DrawPoint(const b2Vec2 &p, float size, const b2Color &color)=0
Draw a point.
const b2BroadPhase * broadPhase
void RayCast(T *callback, const b2RayCastInput &input) const
b2World(const b2Vec2 &gravity)
void Free(void *p, int32 size)
Free memory. This will use b2Free if the size is larger than b2_maxBlockSize.
const b2AABB & GetAABB(int32 childIndex) const
b2Joint * GetNext()
Get the next joint the world joint list.
This is an internal structure.
This proxy is used internally to connect fixtures to the broad-phase.
void SetDebugDraw(b2Draw *debugDraw)
void QueryAABB(b2QueryCallback *callback, const b2AABB &aabb) const
void DestroyJoint(b2Joint *joint)
const b2BroadPhase * broadPhase
b2Body * other
provides quick access to the other body attached.
void ShiftOrigin(const b2Vec2 &newOrigin)
void SolveTOI(const b2TimeStep &subStep, int32 toiIndexA, int32 toiIndexB)
b2Vec2 GetCenter() const
Get the center of the AABB.
virtual void SayGoodbye(b2Joint *joint)=0
Color for debug drawing. Each value has the range [0,1].
virtual void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)=0
Draw a closed polygon provided in CCW order.
int32 GetProxyCount() const
Get the number of proxies.
void Solve(const b2TimeStep &step)
b2JointEdge * m_jointList
void SolveTOI(const b2TimeStep &step)
A rigid body. These are created via b2World::CreateBody.
float GetTreeQuality() const
bool IsLocked() const
Is the world locked (in the middle of a time step).
void * Allocate(int32 size)
Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize.
int32 GetTreeHeight() const
Get the height of the embedded tree.
Profiling data. Times are in milliseconds.
draw axis aligned bounding boxes
virtual void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)=0
Draw a solid closed polygon provided in CCW order.
b2Joint * CreateJoint(const b2JointDef *def)
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, int32 childIndex) const
b2QueryCallback * callback
void * Allocate(int32 size)
bool collideConnected
Set this flag to true if the attached bodies should collide.
void Set(float x_, float y_)
Set this vector to some specified coordinates.
~b2World()
Destruct the world. All physics entities are destroyed and all heap memory is released.
int32 GetProxyCount() const
Get the number of broad-phase proxies.
b2Body * GetNext()
Get the next body in the world's body list.
b2Vec2 m_vertices[b2_maxPolygonVertices]
void Destroy(b2BlockAllocator *allocator)
int32 GetTreeBalance() const
Get the balance of the embedded tree.
b2BodyType GetType() const
Get the type of this body.
b2RayCastCallback * callback
void ShiftOrigin(const b2Vec2 &newOrigin)
float RayCastCallback(const b2RayCastInput &input, int32 proxyId)
void SynchronizeTransform()
void SetContactListener(b2ContactListener *listener)
b2StackAllocator m_stackAllocator
#define b2_maxSubSteps
Maximum number of sub-steps per contact in continuous physics simulation.
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
An axis aligned bounding box.
Output parameters for b2TimeOfImpact.
b2DestructionListener * m_destructionListener
void SetDestructionListener(b2DestructionListener *listener)
void Solve(b2Profile *profile, const b2TimeStep &step, const b2Vec2 &gravity, bool allowSleep)
void b2Dump(const char *string,...)
b2Vec2 m_vertex1
These are the edge vertices.
void DestroyBody(b2Body *body)
void DestroyProxies(b2BroadPhase *broadPhase)
#define b2_maxPolygonVertices
bool m_oneSided
Uses m_vertex0 and m_vertex3 to create smooth collision.
b2BlockAllocator m_blockAllocator
int32 m_count
The vertex count.
bool IsEnabled() const
Get the active state of the body.
void Step(float timeStep, int32 velocityIterations, int32 positionIterations)
bool QueryCallback(int32 proxyId)
b2Body * bodyA
The first attached body.
void DebugDraw()
Call this to draw shapes and other debug draw data. This is intentionally non-const.
static b2Joint * Create(const b2JointDef *def, b2BlockAllocator *allocator)
#define b2_maxTOIContacts
Maximum number of contacts to be handled to solve a TOI impact.
int32 GetTreeHeight() const
Get the height of the dynamic tree.
void SetContactFilter(b2ContactFilter *filter)
void Query(T *callback, const b2AABB &aabb) const
b2Body * CreateBody(const b2BodyDef *def)
b2Body * bodyB
The second attached body.
b2JointEdge * next
the next joint edge in the body's joint list
b2Shape::Type GetType() const
void Advance(float alpha)
b2Vec2 upperBound
the upper vertex
float GetMilliseconds() const
Get the time since construction or the last reset.
b2Fixture * m_fixtureList