| 175 | } |
| 176 | |
| 177 | void b2ContactManager::AddPair(void* proxyUserDataA, void* proxyUserDataB) |
| 178 | { |
| 179 | b2FixtureProxy* proxyA = (b2FixtureProxy*)proxyUserDataA; |
| 180 | b2FixtureProxy* proxyB = (b2FixtureProxy*)proxyUserDataB; |
| 181 | |
| 182 | b2Fixture* fixtureA = proxyA->fixture; |
| 183 | b2Fixture* fixtureB = proxyB->fixture; |
| 184 | |
| 185 | int32 indexA = proxyA->childIndex; |
| 186 | int32 indexB = proxyB->childIndex; |
| 187 | |
| 188 | b2Body* bodyA = fixtureA->GetBody(); |
| 189 | b2Body* bodyB = fixtureB->GetBody(); |
| 190 | |
| 191 | // Are the fixtures on the same body? |
| 192 | if (bodyA == bodyB) |
| 193 | { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | // TODO_ERIN use a hash table to remove a potential bottleneck when both |
| 198 | // bodies have a lot of contacts. |
| 199 | // Does a contact already exist? |
| 200 | b2ContactEdge* edge = bodyB->GetContactList(); |
| 201 | while (edge) |
| 202 | { |
| 203 | if (edge->other == bodyA) |
| 204 | { |
| 205 | b2Fixture* fA = edge->contact->GetFixtureA(); |
| 206 | b2Fixture* fB = edge->contact->GetFixtureB(); |
| 207 | int32 iA = edge->contact->GetChildIndexA(); |
| 208 | int32 iB = edge->contact->GetChildIndexB(); |
| 209 | |
| 210 | if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) |
| 211 | { |
| 212 | // A contact already exists. |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) |
| 217 | { |
| 218 | // A contact already exists. |
| 219 | return; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | edge = edge->next; |
| 224 | } |
| 225 | |
| 226 | // Does a joint override collision? Is at least one body dynamic? |
| 227 | if (bodyB->ShouldCollide(bodyA) == false) |
| 228 | { |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | // Check user filtering. |
| 233 | if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false) |
| 234 | { |
no test coverage detected