Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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
}