/** * Class destructor, free allocated memory. Release PhysX object and remove actors and materials. */ PhysicsManager::~PhysicsManager() { delete collisionHandler; PxCloseExtensions(); scene->release(); cooking->release(); physicsSDK->release(); }
void TermGamePhys() { #if WITH_BOX2D FPhysicsIntegration2D::ShutdownPhysics(); #endif #if WITH_PHYSX // Do nothing if they were never initialized if(GPhysXFoundation == NULL) { return; } if (GPhysCommandHandler != NULL) { GPhysCommandHandler->Flush(); //finish off any remaining commands delete GPhysCommandHandler; GPhysCommandHandler = NULL; } #if WITH_APEX #if WITH_APEX_LEGACY if(GApexModuleLegacy != NULL) { GApexModuleLegacy->release(); GApexModuleLegacy = NULL; } #endif // WITH_APEX_LEGACY if(GApexSDK != NULL) { GApexSDK->release(); GApexSDK = NULL; } #endif // #if WITH_APEX #if WITH_PHYSICS_COOKING || WITH_RUNTIME_PHYSICS_COOKING if(GPhysXCooking != NULL) { GPhysXCooking->release(); GPhysXCooking = NULL; } #endif PxCloseExtensions(); PxCloseVehicleSDK(); if(GPhysXSDK != NULL) { GPhysXSDK->release(); GPhysXSDK = NULL; } // @todo delete FPhysXAllocator // @todo delete FPhysXOutputStream UnloadPhysXModules(); #endif }
} void Game::CloseGame() { if(sceneManager) { delete sceneManager; sceneManager = NULL; } InputNotifier::DestroySingleton(); InputManager::GetInstance()->DestroySingleton(); RandomNumberGenerator::DestroyInstance(); ///Release Physx Systems if(mProfileZoneManager) { mProfileZoneManager->release(); mProfileZoneManager = NULL; } if(mPvdConnection) { mPvdConnection->release(); mPvdConnection = NULL; } #ifdef USE_PHYSX_COOKING PhysXCookingWrapper::ShutdownCookingLibrary();//Checks for NULL before shutting down #endif if(gPhysicsSDK) { gPhysicsSDK->release(); gPhysicsSDK = NULL; } PhysXSerializerWrapper::CleanMemory(); PxCloseExtensions(); if(foundation) { foundation->release(); foundation = NULL; }
bool Px3World::restartSDK( bool destroyOnly, Px3World *clientWorld, Px3World *serverWorld) { // If either the client or the server still exist // then we cannot reset the SDK. if ( clientWorld || serverWorld ) return false; if(smPvdConnection) smPvdConnection->release(); if(smCooking) smCooking->release(); if(smCpuDispatcher) smCpuDispatcher->release(); // Destroy the existing SDK. if ( gPhysics3SDK ) { PxCloseExtensions(); gPhysics3SDK->release(); } if(smErrorCallback) { SAFE_DELETE(smErrorCallback); } if(smFoundation) { smFoundation->release(); SAFE_DELETE(smErrorCallback); } // If we're not supposed to restart... return. if ( destroyOnly ) return true; bool memTrack = false; #ifdef TORQUE_DEBUG memTrack = true; #endif smErrorCallback = new Px3ConsoleStream; smFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, smMemoryAlloc, *smErrorCallback); smProfileZoneManager = &physx::PxProfileZoneManager::createProfileZoneManager(smFoundation); gPhysics3SDK = PxCreatePhysics(PX_PHYSICS_VERSION, *smFoundation, physx::PxTolerancesScale(),memTrack,smProfileZoneManager); if ( !gPhysics3SDK ) { Con::errorf( "PhysX3 failed to initialize!" ); Platform::messageBox( Con::getVariable( "$appName" ), avar("PhysX3 could not be started!\r\n"), MBOk, MIStop ); Platform::forceShutdown( -1 ); // We shouldn't get here, but this shuts up // source diagnostic tools. return false; } if(!PxInitExtensions(*gPhysics3SDK)) { Con::errorf( "PhysX3 failed to initialize extensions!" ); Platform::messageBox( Con::getVariable( "$appName" ), avar("PhysX3 could not be started!\r\n"), MBOk, MIStop ); Platform::forceShutdown( -1 ); return false; } smCooking = PxCreateCooking(PX_PHYSICS_VERSION, *smFoundation, physx::PxCookingParams(physx::PxTolerancesScale())); if(!smCooking) { Con::errorf( "PhysX3 failed to initialize cooking!" ); Platform::messageBox( Con::getVariable( "$appName" ), avar("PhysX3 could not be started!\r\n"), MBOk, MIStop ); Platform::forceShutdown( -1 ); return false; } #ifdef TORQUE_DEBUG physx::PxVisualDebuggerConnectionFlags connectionFlags(physx::PxVisualDebuggerExt::getAllConnectionFlags()); smPvdConnection = physx::PxVisualDebuggerExt::createConnection(gPhysics3SDK->getPvdConnectionManager(), "localhost", 5425, 100, connectionFlags); #endif return true; }
void TermGamePhys() { #if WITH_BOX2D FPhysicsIntegration2D::ShutdownPhysics(); #endif #if WITH_PHYSX FPhysxSharedData::Terminate(); // Do nothing if they were never initialized if(GPhysXFoundation == NULL) { return; } if (GPhysCommandHandler != NULL) { GPhysCommandHandler->Flush(); //finish off any remaining commands FCoreUObjectDelegates::PreGarbageCollect.Remove(GPreGarbageCollectDelegateHandle); delete GPhysCommandHandler; GPhysCommandHandler = NULL; } #if WITH_APEX #if WITH_APEX_LEGACY if(GApexModuleLegacy != NULL) { GApexModuleLegacy->release(); GApexModuleLegacy = NULL; } #endif // WITH_APEX_LEGACY if(GApexSDK != NULL) { GApexSDK->release(); GApexSDK = NULL; } #endif // #if WITH_APEX //Remove all scenes still registered if (int32 NumScenes = GPhysXSDK->getNbScenes()) { TArray<PxScene*> PScenes; PScenes.AddUninitialized(NumScenes); GPhysXSDK->getScenes(PScenes.GetData(), sizeof(PxScene*)* NumScenes); for (PxScene* PScene : PScenes) { if (PScene) { PScene->release(); } } } #if WITH_PHYSICS_COOKING || WITH_RUNTIME_PHYSICS_COOKING if(GPhysXCooking != NULL) { GPhysXCooking->release(); GPhysXCooking = NULL; } #endif PxCloseExtensions(); PxCloseVehicleSDK(); if(GPhysXSDK != NULL) { GPhysXSDK->release(); GPhysXSDK = NULL; } // @todo delete FPhysXAllocator // @todo delete FPhysXOutputStream UnloadPhysXModules(); #endif }
void closeExtensions() { PxCloseExtensions(); }
void CurrentApp::DeInit() { m_gPassTarget->Destroy(); m_lightPassTarget->Destroy(); IconShader::GetInstance()->Destroy(); Input::GetInstance()->Destroy(); m_assetManager->Destroy(); for(unsigned int i = 0; i < g_PhysXActors.size(); ++i) { if (g_PhysXActors[i] != nullptr) { PxU32 shapeNo = g_PhysXActors[i]->getNbShapes(); PxShape** shapes = new PxShape*[shapeNo]; g_PhysXActors[i]->getShapes(shapes, shapeNo); for (unsigned int j = 0; j < shapeNo; ++j) { g_PhysXActors[i]->detachShape(*shapes[j]); } delete[] shapes; g_PhysXActors[i]->release(); g_PhysXActors[i] = nullptr; } g_PhysXActors.clear(); } if (g_ControllerManager != nullptr) { g_ControllerManager->release(); g_ControllerManager = nullptr; } if (g_cpuDispatcher != nullptr) { delete g_cpuDispatcher; g_cpuDispatcher = nullptr; } if (g_PhysicsCooker != nullptr) { g_PhysicsCooker->release(); g_PhysicsCooker = nullptr; } if (g_PhysicsScene != nullptr) { g_PhysicsScene->release(); g_PhysicsScene = nullptr; } if (g_Physics != nullptr) { PxCloseExtensions(); g_Physics->release(); g_Physics = nullptr; } if (g_PhysicsFoundation != nullptr) { g_PhysicsFoundation->release(); g_PhysicsFoundation = nullptr; } if (g_PhysicsAllocator != nullptr) { delete g_PhysicsAllocator; g_PhysicsAllocator = nullptr; } delete m_renderer; delete m_gPassTarget; delete m_lightPassTarget; delete m_world; delete m_skybox; delete m_nodeMap; delete m_assetManager; delete m_camera; delete g_PlayerCollisions; delete m_particleEmitter; for (unsigned int i = 0; i < 5; ++i) { delete m_AI[i]; } glDeleteVertexArrays(1, &m_fullscreenQuad); Gizmos::destroy(); }