Generate the rendering primitives (triangles, lines, ...) of a physics world
| 480 | |
| 481 | // Generate the rendering primitives (triangles, lines, ...) of a physics world |
| 482 | void 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 |
| 530 | void DebugRenderer::onContact(const CollisionCallback::CallbackData& callbackData) { |
no test coverage detected