void RenderPhysX3Debug::update(const PxRenderBuffer& debugRenderable, const Camera& camera) { // Points const PxU32 numPoints = debugRenderable.getNbPoints(); if(numPoints) { const PxDebugPoint* PX_RESTRICT points = debugRenderable.getPoints(); checkResizePoint(numPoints); for(PxU32 i=0; i<numPoints; i++) { const PxDebugPoint& point = points[i]; addPoint(point.pos, RendererColor(point.color)); } } // Lines const PxU32 numLines = debugRenderable.getNbLines(); if(numLines) { const PxDebugLine* PX_RESTRICT lines = debugRenderable.getLines(); checkResizeLine(numLines * 2); PxU32 nbVisible = 0; for(PxU32 i=0; i<numLines; i++) { const PxDebugLine& line = lines[i]; PxBounds3 b; b.minimum.x = PxMin(line.pos0.x, line.pos1.x); b.minimum.y = PxMin(line.pos0.y, line.pos1.y); b.minimum.z = PxMin(line.pos0.z, line.pos1.z); b.maximum.x = PxMax(line.pos0.x, line.pos1.x); b.maximum.y = PxMax(line.pos0.y, line.pos1.y); b.maximum.z = PxMax(line.pos0.z, line.pos1.z); if(camera.cull(b)==PLANEAABB_EXCLUSION) continue; addLine(line.pos0, line.pos1, RendererColor(line.color0)); nbVisible++; } printf("%f\n", float(nbVisible)/float(numLines)); } // Triangles const PxU32 numTriangles = debugRenderable.getNbTriangles(); if(numTriangles) { const PxDebugTriangle* PX_RESTRICT triangles = debugRenderable.getTriangles(); checkResizeTriangle(numTriangles * 3); for(PxU32 i=0; i<numTriangles; i++) { const PxDebugTriangle& triangle = triangles[i]; addTriangle(triangle.pos0, triangle.pos1, triangle.pos2, RendererColor(triangle.color0)); } } }
static void BatchPxRenderBufferLines(class ULineBatchComponent& LineBatcherToUse, const PxRenderBuffer& DebugData) { int32 NumPoints = DebugData.getNbPoints(); if (NumPoints > 0) { const PxDebugPoint* Points = DebugData.getPoints(); for (int32 i = 0; i<NumPoints; i++) { LineBatcherToUse.DrawPoint(P2UVector(Points->pos), FColor((uint32)Points->color), 2, SDPG_World); Points++; } } // Build a list of all the lines we want to draw TArray<FBatchedLine> DebugLines; // Add all the 'lines' from PhysX int32 NumLines = DebugData.getNbLines(); if (NumLines > 0) { const PxDebugLine* Lines = DebugData.getLines(); for (int32 i = 0; i<NumLines; i++) { new(DebugLines)FBatchedLine(P2UVector(Lines->pos0), P2UVector(Lines->pos1), FColor((uint32)Lines->color0), 0.f, 0.0f, SDPG_World); Lines++; } } // Add all the 'triangles' from PhysX int32 NumTris = DebugData.getNbTriangles(); if (NumTris > 0) { const PxDebugTriangle* Triangles = DebugData.getTriangles(); for (int32 i = 0; i<NumTris; i++) { new(DebugLines)FBatchedLine(P2UVector(Triangles->pos0), P2UVector(Triangles->pos1), FColor((uint32)Triangles->color0), 0.f, 0.0f, SDPG_World); new(DebugLines)FBatchedLine(P2UVector(Triangles->pos1), P2UVector(Triangles->pos2), FColor((uint32)Triangles->color1), 0.f, 0.0f, SDPG_World); new(DebugLines)FBatchedLine(P2UVector(Triangles->pos2), P2UVector(Triangles->pos0), FColor((uint32)Triangles->color2), 0.f, 0.0f, SDPG_World); Triangles++; } } // Draw them all in one call. if (DebugLines.Num() > 0) { LineBatcherToUse.DrawLines(DebugLines); } }
void RenderPhysX3Debug::update(const PxRenderBuffer& debugRenderable) { // Points const PxU32 numPoints = debugRenderable.getNbPoints(); if(numPoints) { const PxDebugPoint* PX_RESTRICT points = debugRenderable.getPoints(); checkResizePoint(numPoints); for(PxU32 i=0; i<numPoints; i++) { const PxDebugPoint& point = points[i]; addPoint(point.pos, RendererColor(point.color)); } } // Lines const PxU32 numLines = debugRenderable.getNbLines(); if(numLines) { const PxDebugLine* PX_RESTRICT lines = debugRenderable.getLines(); checkResizeLine(numLines * 2); for(PxU32 i=0; i<numLines; i++) { const PxDebugLine& line = lines[i]; addLine(line.pos0, line.pos1, RendererColor(line.color0)); } } // Triangles const PxU32 numTriangles = debugRenderable.getNbTriangles(); if(numTriangles) { const PxDebugTriangle* PX_RESTRICT triangles = debugRenderable.getTriangles(); checkResizeTriangle(numTriangles * 3); for(PxU32 i=0; i<numTriangles; i++) { const PxDebugTriangle& triangle = triangles[i]; addTriangle(triangle.pos0, triangle.pos1, triangle.pos2, RendererColor(triangle.color0)); } } }