void Gu::ConvexMesh::debugVisualize(Cm::RenderOutput& out, const PxTransform& pose, const PxMeshScale& scale) const { const PxU32 scolor = PxU32(PxDebugColor::eARGB_MAGENTA); const PxVec3* vertices = mHullData.getHullVertices(); const PxU8* indexBuffer = mHullData.getVertexData8(); const PxU32 nbPolygons = getNbPolygonsFast(); const PxMat44 m44(PxMat33(pose.q) * scale.toMat33(), pose.p); out << m44 << scolor; // PT: no need to output this for each segment! for (PxU32 i = 0; i < nbPolygons; i++) { const PxU32 pnbVertices = mHullData.mPolygons[i].mNbVerts; PxVec3 begin = m44.transform(vertices[indexBuffer[0]]); // PT: transform it only once before the loop starts for (PxU32 j = 1; j < pnbVertices; j++) { PxVec3 end = m44.transform(vertices[indexBuffer[j]]); out.outputSegment(begin, end); begin = end; } out.outputSegment(begin, m44.transform(vertices[indexBuffer[0]])); indexBuffer += pnbVertices; } }
void RenderPhysX3Debug::addConvex(const PxConvexMeshGeometry& cg, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags) { const PxConvexMesh& mesh = *cg.convexMesh; const PxMat33 rot = PxMat33(tr.q) * cg.scale.toMat33(); // PT: you can't use PxTransform with a non-uniform scaling const PxMat44 globalPose(rot, tr.p); const PxU32 polygonCount = mesh.getNbPolygons(); const PxU8* indexBuffer = mesh.getIndexBuffer(); const PxU32 vertexCount = mesh.getNbVertices(); const PxVec3* vertexBuffer = mesh.getVertices(); if(renderFlags & RENDER_DEBUG_WIREFRAME) { for(PxU32 i=0; i<polygonCount; i++) { PxHullPolygon data; mesh.getPolygonData(i, data); const PxU32 vertexCount = data.mNbVerts; PxU32 i0 = indexBuffer[vertexCount-1]; PxU32 i1 = *indexBuffer++; addLine(globalPose.transform(vertexBuffer[i0]), globalPose.transform(vertexBuffer[i1]), color); for(PxU32 j=1; j<vertexCount; j++) { i0 = indexBuffer[-1]; i1 = *indexBuffer++; addLine(globalPose.transform(vertexBuffer[i0]), globalPose.transform(vertexBuffer[i1]), color); } } } if(renderFlags & RENDER_DEBUG_SOLID) { for(PxU32 i=0; i<polygonCount; i++) { PxHullPolygon data; mesh.getPolygonData(i, data); const PxU32 vertexCount = data.mNbVerts; const PxVec3& v0 = vertexBuffer[indexBuffer[0]]; for(PxU32 j=0; j<vertexCount-2; j++) { const PxVec3& v1 = vertexBuffer[indexBuffer[j+1]]; const PxVec3& v2 = vertexBuffer[indexBuffer[j+2]]; addTriangle(globalPose.transform(v0), globalPose.transform(v1), globalPose.transform(v2), color); } indexBuffer += vertexCount; } } }