Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to debug using PhysX Visual Debugger

📅 2013-Dec-05 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ physx, physx visual debugger ⬩ 📚 Archive

The PhysX Visual Debugger is a great tool to visualize and debug your PhysX program. It helps you to view the bodies, velocities and constraints (joints) in your PhysX scene and how they change during the program execution.

You can use PhysX Visual Debugger in a few steps:

  1. Open PhysX Visual Debugger. It needs to be running in the background to listen to information sent by your PhysX program.

  2. In the Preferences sub-window of the debugger make sure that all the elements which you are interested to view are set to Everything. For example, center of mass, velocities or constraints. If you do not do this, you may find yourself staring at an empty DirectX Render window.

  3. In your PhysX code, connect to the debugger. You do this by connecting to its IP and port and informing it what elements should be visualized. A bit of self-explanatory code that does this can be found here:

physx::PxPhysics* physics;

// Assuming physics is created here ...

// Check if PhysX Visual Debuger is running and listening
if (!physics->getPvdConnectionManager())
    std::cout << "Warning: PhysX Visual Debugger not found running!\n";

const char* pvdHostIP = "";
int port = 5425;
unsigned int timeout = 100;
physx::PxVisualDebuggerConnectionFlags flags =
    | physx::PxVisualDebuggerConnectionFlag::Profile
    | physx::PxVisualDebuggerConnectionFlag::Memory;

// Create connection with PhysX Visual Debugger
physx::debugger::comm::PvdConnection* conn = physx::PxVisualDebuggerExt::createConnection(

if (conn)
    std::cout << "Connected to PhysX Visual Debugger!\n";

    physics->getVisualDebugger()->setVisualDebuggerFlag(physx::PxVisualDebuggerFlags::eTRANSMIT_CONTACTS, true);
  1. Compile your PhysX program and execute it. You must ensure that your program is able to connect to the debugger.

  2. Let your program run its physics. Close it once it is done.

  3. All the physics from the last execution of your program would be captured by the debugger. Replay it back by using the play buttons at the top of the debugger. Hopefully, this visualization helps you examine the physics of your program better.

Tried with: PhysX 3.2.4, PhysX Visual Debugger 2.0100.01.13105 and Windows 8 x64

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧