Draw a convex mesh
| 297 | |
| 298 | // Draw a convex mesh |
| 299 | void DebugRenderer::drawConvexMesh(const Transform& transform, const ConvexMeshShape* convexMesh, |
| 300 | uint32 colorShape, uint32 colorShapeNormals) { |
| 301 | |
| 302 | const bool drawShape = getIsDebugItemDisplayed(DebugItem::COLLISION_SHAPE); |
| 303 | const bool drawNormal = getIsDebugItemDisplayed(DebugItem::COLLISION_SHAPE_NORMAL); |
| 304 | |
| 305 | // For each face of the convex mesh |
| 306 | for (uint32 f = 0; f < convexMesh->getNbFaces(); f++) { |
| 307 | |
| 308 | const HalfEdgeStructure::Face& face = convexMesh->getFace(f); |
| 309 | assert(face.faceVertices.size() >= 3); |
| 310 | |
| 311 | Vector3 centroid; |
| 312 | |
| 313 | // Perform a fan triangulation of the convex polygon face |
| 314 | const uint32 nbFaceVertices = static_cast<uint32>(face.faceVertices.size()); |
| 315 | for (uint32 v = 2; v < nbFaceVertices; v++) { |
| 316 | |
| 317 | uint32 v1Index = face.faceVertices[v - 2]; |
| 318 | uint32 v2Index = face.faceVertices[v - 1]; |
| 319 | uint32 v3Index = face.faceVertices[v]; |
| 320 | |
| 321 | Vector3 v1 = convexMesh->getVertexPosition(v1Index); |
| 322 | Vector3 v2 = convexMesh->getVertexPosition(v2Index); |
| 323 | Vector3 v3 = convexMesh->getVertexPosition(v3Index); |
| 324 | |
| 325 | v1 = transform * v1; |
| 326 | v2 = transform * v2; |
| 327 | v3 = transform * v3; |
| 328 | |
| 329 | if (v == 2) { |
| 330 | centroid += v1 + v2; |
| 331 | } |
| 332 | |
| 333 | centroid += v3; |
| 334 | |
| 335 | if (drawShape) { |
| 336 | mTriangles.add(DebugTriangle(v1, v2, v3, colorShape)); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | if (drawNormal) { |
| 341 | |
| 342 | centroid /= nbFaceVertices; |
| 343 | const Vector3 normalPoint = centroid + transform.getOrientation() * convexMesh->getFaceNormal(f) * mCollisionShapeNormalLength; |
| 344 | mLines.add(DebugLine(centroid, normalPoint, colorShapeNormals)); |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // Draw a concave mesh shape |
| 350 | void DebugRenderer::drawConcaveMeshShape(const Transform& transform, const ConcaveMeshShape* concaveMeshShape, |
nothing calls this directly
no test coverage detected