void PhsXWorld::build(void) { PxTolerancesScale scale = PxTolerancesScale(); PxFoundation* gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback); PxProfileZoneManager* profileZoneManager = &PxProfileZoneManager::createProfileZoneManager(gFoundation); PxPhysics* gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, scale, true, profileZoneManager); if (gPhysics->getPvdConnectionManager()) { gPhysics->getVisualDebugger()->setVisualizeConstraints(true); gPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_CONTACTS, true); gPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_SCENEQUERIES, true); //gPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_CONSTRAINTS, true); gConnection = PxVisualDebuggerExt::createConnection(gPhysics->getPvdConnectionManager(), "127.0.0.1", 5425, 100); } PxSceneDesc sceneDesc(gPhysics->getTolerancesScale()); sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f); PxDefaultCpuDispatcher* gDispatcher = PxDefaultCpuDispatcherCreate(2); sceneDesc.cpuDispatcher = gDispatcher; sceneDesc.filterShader = PxDefaultSimulationFilterShader; sceneDesc.flags |= PxSceneFlag::eENABLE_ACTIVETRANSFORMS; m_pDynamicsWorld = gPhysics->createScene(sceneDesc); //m_pDynamicsWorld->setFlag(PxSceneFlag::eENABLE_ACTIVETRANSFORMS, true); mCooking = PxCreateCooking(PX_PHYSICS_VERSION, *gFoundation, PxCookingParams(scale)); manager = PxCreateControllerManager(*m_pDynamicsWorld); std::srand(time(NULL)); }
void PVDHelper::createPvdConnection(const EditableParams& params) { PvdConnectionManager* pvd = mPhysics->getPvdConnectionManager(); if(!pvd) return; /* if(0) { PxDebuggerConnectionFlags PDebuggerFlags; PDebuggerFlags |= PxExtensionConnectionType::Debug; PDebuggerFlags |= PxExtensionConnectionType::Profile; PDebuggerFlags |= PxExtensionConnectionType::Memory; PxExtensionVisualDebugger::connect( pvd, PVD_HOST, 5425, 3000, PDebuggerFlags ); return; }*/ //The connection flags state overall what data is to be sent to PVD. Currently //the Debug connection flag requires support from the implementation (don't send //the data when debug isn't set) but the other two flags, profile and memory //are taken care of by the PVD SDK. //Use these flags for a clean profile trace with minimal overhead //TConnectionFlagsType theConnectionFlags( PvdConnectionType::Profile ) #ifdef BETA2 TConnectionFlagsType theConnectionFlags( PvdConnectionType::Debug | PvdConnectionType::Profile | PvdConnectionType::Memory ); if(!params.mUseFullPvdConnection) theConnectionFlags = TConnectionFlagsType(PvdConnectionType::Profile); #else PxVisualDebuggerConnectionFlags theConnectionFlags( PxVisualDebuggerExt::getAllConnectionFlags() ); if(!params.mUseFullPvdConnection) theConnectionFlags = PxVisualDebuggerConnectionFlag::Profile; #endif //Create a pvd connection that writes data straight to the filesystem. This is //the fastest connection on windows for various reasons. First, the transport is quite fast as //pvd writes data in blocks and filesystems work well with that abstraction. //Second, you don't have the PVD application parsing data and using CPU and memory bandwidth //while your application is running. //PxExtensionVisualDebugger::connect(pvd,"c:\\temp.pxd2", PxDebuggerConnectionFlags( (PxU32)theConnectionFlags)); //The normal way to connect to pvd. PVD needs to be running at the time this function is called. //We don't worry about the return value because we are already registered as a listener for connections //and thus our onPvdConnected call will take care of setting up our basic connection state. #ifdef BETA2 PxExtensionVisualDebugger::connect(pvd, PVD_HOST, 5425, 10, PxDebuggerConnectionFlags( (PxU32)theConnectionFlags) ); #else PVD::PvdConnection* theConnection = PxVisualDebuggerExt::createConnection(mPhysics->getPvdConnectionManager(), PVD_HOST, 5425, 10, theConnectionFlags ); if(theConnection) theConnection->release(); #endif }
bool PxInitExtensions(PxPhysics& physics) { PX_ASSERT(static_cast<Ps::Foundation*>(&physics.getFoundation()) == &Ps::Foundation::getInstance()); Ps::Foundation::incRefCount(); physics.registerClass(PxConcreteType::eUSER_SPHERICAL_JOINT, Ext::SphericalJoint::createInstance); physics.registerClass(PxConcreteType::eUSER_REVOLUTE_JOINT, Ext::RevoluteJoint::createInstance); physics.registerClass(PxConcreteType::eUSER_DISTANCE_JOINT, Ext::DistanceJoint::createInstance); physics.registerClass(PxConcreteType::eUSER_D6_JOINT, Ext::D6Joint::createInstance); physics.registerClass(PxConcreteType::eUSER_PRISMATIC_JOINT, Ext::PrismaticJoint::createInstance); physics.registerClass(PxConcreteType::eUSER_FIXED_JOINT, Ext::FixedJoint::createInstance); #if PX_SUPPORT_VISUAL_DEBUGGER if ( physics.getPvdConnectionManager() != NULL ) physics.getPvdConnectionManager()->addHandler( gPvdHandler ); #endif return true; }
void PVDHelper::togglePvdConnection(const EditableParams& params) { PvdConnectionManager* pvd = mPhysics->getPvdConnectionManager(); if(!pvd) return; if(pvd->isConnected()) pvd->disconnect(); else createPvdConnection(params); }