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

Method computeDebugRenderingPrimitives

src/utils/DebugRenderer.cpp:482–527  ·  view source on GitHub ↗

Generate the rendering primitives (triangles, lines, ...) of a physics world

Source from the content-addressed store, hash-verified

480
481// Generate the rendering primitives (triangles, lines, ...) of a physics world
482void DebugRenderer::computeDebugRenderingPrimitives(const PhysicsWorld& world) {
483
484 const bool drawColliderAABB = getIsDebugItemDisplayed(DebugItem::COLLIDER_AABB);
485 const bool drawColliderBroadphaseAABB = getIsDebugItemDisplayed(DebugItem::COLLIDER_BROADPHASE_AABB);
486 const bool drawCollisionShape = getIsDebugItemDisplayed(DebugItem::COLLISION_SHAPE);
487 const bool drawCollisionShapeNormals = getIsDebugItemDisplayed(DebugItem::COLLISION_SHAPE_NORMAL);
488
489 const uint32 nbRigidBodies = world.getNbRigidBodies();
490
491 // For each body of the world
492 for (uint32 b = 0; b < nbRigidBodies; b++) {
493
494 // Get a body
495 const Body* body = world.getRigidBody(b);
496
497 if (body->isActive() && body->isDebugEnabled()) {
498
499 // For each collider of the body
500 for (uint32 c = 0; c < body->getNbColliders(); c++) {
501
502 // Get a collider
503 const Collider* collider = body->getCollider(c);
504
505 // If we need to draw the collider AABB
506 if (drawColliderAABB) {
507
508 drawAABB(collider->getWorldAABB(), mMapDebugItemWithColor[DebugItem::COLLIDER_AABB]);
509 }
510
511 // If we need to draw the collider broad-phase AABB
512 if (drawColliderBroadphaseAABB) {
513
514 if (collider->getBroadPhaseId() != -1) {
515 drawAABB(world.mCollisionDetection.mBroadPhaseSystem.getFatAABB(collider->getBroadPhaseId()), mMapDebugItemWithColor[DebugItem::COLLIDER_BROADPHASE_AABB]);
516 }
517 }
518
519 // If we need to draw the collision shape
520 if (drawCollisionShape || drawCollisionShapeNormals) {
521
522 drawCollisionShapeOfCollider(collider, mMapDebugItemWithColor[DebugItem::COLLISION_SHAPE]);
523 }
524 }
525 }
526 }
527}
528
529// Called when some contacts occur
530void DebugRenderer::onContact(const CollisionCallback::CallbackData& callbackData) {

Callers 3

updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80

Calls 8

getNbRigidBodiesMethod · 0.80
isActiveMethod · 0.80
isDebugEnabledMethod · 0.80
getNbCollidersMethod · 0.80
getRigidBodyMethod · 0.45
getColliderMethod · 0.45
getWorldAABBMethod · 0.45
getBroadPhaseIdMethod · 0.45

Tested by

no test coverage detected