| 1715 | } |
| 1716 | |
| 1717 | void PhysicsBackend::Shutdown() |
| 1718 | { |
| 1719 | // Remove all scenes still registered |
| 1720 | const int32 numScenes = PhysX ? PhysX->getNbScenes() : 0; |
| 1721 | if (numScenes) |
| 1722 | { |
| 1723 | Array<PxScene*> scenes; |
| 1724 | scenes.Resize(numScenes); |
| 1725 | scenes.SetAll(nullptr); |
| 1726 | PhysX->getScenes(scenes.Get(), sizeof(PxScene*) * numScenes); |
| 1727 | for (PxScene* scene : scenes) |
| 1728 | { |
| 1729 | if (scene) |
| 1730 | scene->release(); |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | // Cleanup any resources |
| 1735 | #if WITH_VEHICLE |
| 1736 | RELEASE_PHYSX(WheelTireFrictions); |
| 1737 | WheelVehiclesResultsPerWheel.Resize(0); |
| 1738 | WheelVehiclesResultsPerVehicle.Resize(0); |
| 1739 | #endif |
| 1740 | RELEASE_PHYSX(DefaultMaterial); |
| 1741 | |
| 1742 | // Shutdown PhysX |
| 1743 | #if WITH_CLOTH |
| 1744 | if (ClothFactory) |
| 1745 | { |
| 1746 | NvClothDestroyFactory(ClothFactory); |
| 1747 | ClothFactory = nullptr; |
| 1748 | } |
| 1749 | #endif |
| 1750 | #if WITH_VEHICLE |
| 1751 | if (VehicleSDKInitialized) |
| 1752 | { |
| 1753 | VehicleSDKInitialized = false; |
| 1754 | PxCloseVehicleSDK(); |
| 1755 | } |
| 1756 | #endif |
| 1757 | #if COMPILE_WITH_PHYSICS_COOKING |
| 1758 | RELEASE_PHYSX(Cooking); |
| 1759 | #endif |
| 1760 | if (PhysX) |
| 1761 | { |
| 1762 | PxCloseExtensions(); |
| 1763 | PhysX->release(); |
| 1764 | PhysX = nullptr; |
| 1765 | } |
| 1766 | #if WITH_PVD |
| 1767 | RELEASE_PHYSX(PVD); |
| 1768 | #endif |
| 1769 | #if PLATFORM_THREADS_LIMIT > 1 |
| 1770 | RELEASE_PHYSX(CpuDispatcher); |
| 1771 | #else |
| 1772 | SAFE_DELETE(CpuDispatcher); |
| 1773 | #endif |
| 1774 | RELEASE_PHYSX(Foundation); |