Draw the collision shape of a collider
| 429 | |
| 430 | // Draw the collision shape of a collider |
| 431 | void DebugRenderer::drawCollisionShapeOfCollider(const Collider* collider, uint32 color) { |
| 432 | |
| 433 | uint32 colorShape = mMapDebugItemWithColor[DebugItem::COLLISION_SHAPE]; |
| 434 | uint32 colorShapeNormals = mMapDebugItemWithColor[DebugItem::COLLISION_SHAPE_NORMAL]; |
| 435 | |
| 436 | switch (collider->getCollisionShape()->getName()) { |
| 437 | |
| 438 | case CollisionShapeName::BOX: |
| 439 | { |
| 440 | const BoxShape* boxShape = static_cast<const BoxShape*>(collider->getCollisionShape()); |
| 441 | drawBox(collider->getLocalToWorldTransform(), boxShape, colorShape, colorShapeNormals); |
| 442 | break; |
| 443 | } |
| 444 | case CollisionShapeName::SPHERE: |
| 445 | { |
| 446 | const SphereShape* sphereShape = static_cast<const SphereShape*>(collider->getCollisionShape()); |
| 447 | drawSphere(collider->getLocalToWorldTransform().getPosition(), sphereShape->getRadius(), colorShape); |
| 448 | break; |
| 449 | } |
| 450 | case CollisionShapeName::CAPSULE: |
| 451 | { |
| 452 | const CapsuleShape* capsuleShape = static_cast<const CapsuleShape*>(collider->getCollisionShape()); |
| 453 | drawCapsule(collider->getLocalToWorldTransform(), capsuleShape->getRadius(), capsuleShape->getHeight(), colorShape); |
| 454 | break; |
| 455 | } |
| 456 | case CollisionShapeName::CONVEX_MESH: |
| 457 | { |
| 458 | const ConvexMeshShape* convexMeshShape = static_cast<const ConvexMeshShape*>(collider->getCollisionShape()); |
| 459 | drawConvexMesh(collider->getLocalToWorldTransform(), convexMeshShape, colorShape, colorShapeNormals); |
| 460 | break; |
| 461 | } |
| 462 | case CollisionShapeName::TRIANGLE_MESH: |
| 463 | { |
| 464 | const ConcaveMeshShape* concaveMeshShape = static_cast<const ConcaveMeshShape*>(collider->getCollisionShape()); |
| 465 | drawConcaveMeshShape(collider->getLocalToWorldTransform(), concaveMeshShape, colorShape, colorShapeNormals); |
| 466 | break; |
| 467 | } |
| 468 | case CollisionShapeName::HEIGHTFIELD: |
| 469 | { |
| 470 | const HeightFieldShape* heighFieldShape = static_cast<const HeightFieldShape*>(collider->getCollisionShape()); |
| 471 | drawHeightFieldShape(collider->getLocalToWorldTransform(), heighFieldShape, colorShape, colorShapeNormals); |
| 472 | break; |
| 473 | } |
| 474 | default: |
| 475 | { |
| 476 | assert(false); |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | // Generate the rendering primitives (triangles, lines, ...) of a physics world |
| 482 | void DebugRenderer::computeDebugRenderingPrimitives(const PhysicsWorld& world) { |
nothing calls this directly
no test coverage detected