MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / Collide

Method Collide

engine/source/Box2D/Dynamics/b2ContactManager.cpp:105–170  ·  view source on GitHub ↗

This is the top level collision call for the time step. Here all the narrow phase collision is processed for the world contact list.

Source from the content-addressed store, hash-verified

103// all the narrow phase collision is processed for the world
104// contact list.
105void b2ContactManager::Collide()
106{
107 // Update awake contacts.
108 b2Contact* c = m_contactList;
109 while (c)
110 {
111 b2Fixture* fixtureA = c->GetFixtureA();
112 b2Fixture* fixtureB = c->GetFixtureB();
113 int32 indexA = c->GetChildIndexA();
114 int32 indexB = c->GetChildIndexB();
115 b2Body* bodyA = fixtureA->GetBody();
116 b2Body* bodyB = fixtureB->GetBody();
117
118 // Is this contact flagged for filtering?
119 if (c->m_flags & b2Contact::e_filterFlag)
120 {
121 // Should these bodies collide?
122 if (bodyB->ShouldCollide(bodyA) == false)
123 {
124 b2Contact* cNuke = c;
125 c = cNuke->GetNext();
126 Destroy(cNuke);
127 continue;
128 }
129
130 // Check user filtering.
131 if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false)
132 {
133 b2Contact* cNuke = c;
134 c = cNuke->GetNext();
135 Destroy(cNuke);
136 continue;
137 }
138
139 // Clear the filtering flag.
140 c->m_flags &= ~b2Contact::e_filterFlag;
141 }
142
143 bool activeA = bodyA->IsAwake() && bodyA->m_type != b2_staticBody;
144 bool activeB = bodyB->IsAwake() && bodyB->m_type != b2_staticBody;
145
146 // At least one body must be awake and it must be dynamic or kinematic.
147 if (activeA == false && activeB == false)
148 {
149 c = c->GetNext();
150 continue;
151 }
152
153 int32 proxyIdA = fixtureA->m_proxies[indexA].proxyId;
154 int32 proxyIdB = fixtureB->m_proxies[indexB].proxyId;
155 bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB);
156
157 // Here we destroy contacts that cease to overlap in the broad-phase.
158 if (overlap == false)
159 {
160 b2Contact* cNuke = c;
161 c = cNuke->GetNext();
162 Destroy(cNuke);

Callers 1

StepMethod · 0.45

Calls 10

GetFixtureAMethod · 0.80
GetFixtureBMethod · 0.80
GetChildIndexAMethod · 0.80
GetChildIndexBMethod · 0.80
GetBodyMethod · 0.80
IsAwakeMethod · 0.80
TestOverlapMethod · 0.80
ShouldCollideMethod · 0.45
GetNextMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected