Find TOI contacts and solve them.
| 575 | |
| 576 | // Find TOI contacts and solve them. |
| 577 | void b2World::SolveTOI(const b2TimeStep& step) |
| 578 | { |
| 579 | b2Island island(2 * b2_maxTOIContacts, b2_maxTOIContacts, 0, &m_stackAllocator, m_contactManager.m_contactListener); |
| 580 | |
| 581 | if (m_stepComplete) |
| 582 | { |
| 583 | for (b2Body* b = m_bodyList; b; b = b->m_next) |
| 584 | { |
| 585 | b->m_flags &= ~b2Body::e_islandFlag; |
| 586 | b->m_sweep.alpha0 = 0.0f; |
| 587 | } |
| 588 | |
| 589 | for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next) |
| 590 | { |
| 591 | // Invalidate TOI |
| 592 | c->m_flags &= ~(b2Contact::e_toiFlag | b2Contact::e_islandFlag); |
| 593 | c->m_toiCount = 0; |
| 594 | c->m_toi = 1.0f; |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | // Find TOI events and solve them. |
| 599 | for (;;) |
| 600 | { |
| 601 | // Find the first TOI. |
| 602 | b2Contact* minContact = NULL; |
| 603 | float32 minAlpha = 1.0f; |
| 604 | |
| 605 | for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next) |
| 606 | { |
| 607 | // Is this contact disabled? |
| 608 | if (c->IsEnabled() == false) |
| 609 | { |
| 610 | continue; |
| 611 | } |
| 612 | |
| 613 | // Prevent excessive sub-stepping. |
| 614 | if (c->m_toiCount > b2_maxSubSteps) |
| 615 | { |
| 616 | continue; |
| 617 | } |
| 618 | |
| 619 | float32 alpha = 1.0f; |
| 620 | if (c->m_flags & b2Contact::e_toiFlag) |
| 621 | { |
| 622 | // This contact has a valid cached TOI. |
| 623 | alpha = c->m_toi; |
| 624 | } |
| 625 | else |
| 626 | { |
| 627 | b2Fixture* fA = c->GetFixtureA(); |
| 628 | b2Fixture* fB = c->GetFixtureB(); |
| 629 | |
| 630 | // Is there a sensor? |
| 631 | if (fA->IsSensor() || fB->IsSensor()) |
| 632 | { |
| 633 | continue; |
| 634 | } |
nothing calls this directly
no test coverage detected