Called when some contacts occur
| 528 | |
| 529 | // Called when some contacts occur |
| 530 | void DebugRenderer::onContact(const CollisionCallback::CallbackData& callbackData) { |
| 531 | |
| 532 | // If we need to draw contact points |
| 533 | if (getIsDebugItemDisplayed(DebugItem::CONTACT_POINT) || getIsDebugItemDisplayed(DebugItem::CONTACT_NORMAL)) { |
| 534 | |
| 535 | // For each contact pair |
| 536 | for (uint32 p = 0; p < callbackData.getNbContactPairs(); p++) { |
| 537 | |
| 538 | CollisionCallback::ContactPair contactPair = callbackData.getContactPair(p); |
| 539 | |
| 540 | if (contactPair.getEventType() != CollisionCallback::ContactPair::EventType::ContactExit) { |
| 541 | |
| 542 | // For each contact point of the contact pair |
| 543 | for (uint32 c = 0; c < contactPair.getNbContactPoints(); c++) { |
| 544 | |
| 545 | CollisionCallback::ContactPoint contactPoint = contactPair.getContactPoint(c); |
| 546 | |
| 547 | Vector3 point = contactPair.getCollider1()->getLocalToWorldTransform() * contactPoint.getLocalPointOnCollider1(); |
| 548 | |
| 549 | if (getIsDebugItemDisplayed(DebugItem::CONTACT_POINT)) { |
| 550 | |
| 551 | // Contact point |
| 552 | drawSphere(point, mContactPointSphereRadius, mMapDebugItemWithColor[DebugItem::CONTACT_POINT]); |
| 553 | } |
| 554 | |
| 555 | if (getIsDebugItemDisplayed(DebugItem::CONTACT_NORMAL)) { |
| 556 | |
| 557 | // Contact normal |
| 558 | mLines.add(DebugLine(point, point + contactPoint.getWorldNormal() * mContactNormalLength, mMapDebugItemWithColor[DebugItem::CONTACT_NORMAL])); |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | } |
no test coverage detected