MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / onContact

Method onContact

src/utils/DebugRenderer.cpp:530–564  ·  view source on GitHub ↗

Called when some contacts occur

Source from the content-addressed store, hash-verified

528
529// Called when some contacts occur
530void 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}

Callers 2

reportContactsMethod · 0.45

Calls 9

DebugLineClass · 0.85
getContactPairMethod · 0.80
getContactPointMethod · 0.80
getNbContactPairsMethod · 0.45
getEventTypeMethod · 0.45
getNbContactPointsMethod · 0.45
getCollider1Method · 0.45
addMethod · 0.45

Tested by

no test coverage detected