void CPhysicsManager::exit() { if (!m_pPhyWorld) {return;} // already deleted #if PHYSICS_MANAGER_DEBUG == 1 CInputListenerManager::getSingleton().removeInputListener(this); #endif // PHYSICS_MANAGER_DEBUG #ifdef PHYSICS_DEBUG if (m_pDbgDraw) {delete m_pDbgDraw; m_pDbgDraw = nullptr;} #endif for (int i = m_pPhyWorld->getNumCollisionObjects() - 1; i >= 0; i--) { btCollisionObject * obj = m_pPhyWorld->getCollisionObjectArray()[i]; btRigidBody * body = btRigidBody::upcast(obj); if (body && body->getMotionState()) delete body->getMotionState(); m_pPhyWorld->removeCollisionObject(obj); delete obj; } //destroy collision shapes for (auto &sh : m_CollisionObjects) { auto triShape = dynamic_cast<btBvhTriangleMeshShape*>(sh.second.getShape()); if (triShape) { delete triShape->getMeshInterface(); } delete sh.second.getShape(); } m_CollisionObjects.clear(); if (m_pGhostPairCallback) {delete m_pGhostPairCallback; m_pGhostPairCallback = nullptr;} if (m_pPhyWorld) { delete m_pPhyWorld; m_pPhyWorld = nullptr; delete mSolver; delete mBroadphaseInterface; delete mDispatcher; delete mCollisionConfig; } }
bool CExporter::buildMesh() { m_meshes.clear(); for (std::vector<INode*>::iterator iterNode = m_meshNodes.begin(); iterNode != m_meshNodes.end(); ++iterNode) { INode* node = *iterNode; assert(node != NULL); ISkin* skin = NULL; ISkinContextData* data = NULL; Mesh* mesh = NULL; if (!getMeshInterface(node, skin, data, mesh)) { continue; } grp::MeshExporter* meshFile = NULL; if (skin != NULL) { grp::SkinnedMeshExporter *skinnedMesh = new grp::SkinnedMeshExporter; if (!buildOneMeshSkin(skinnedMesh, node, skin, data, mesh)) { delete skinnedMesh; return false; } meshFile = skinnedMesh; } else { grp::RigidMeshExporter *rigidMesh = new grp::RigidMeshExporter; if (!buildOneMeshRigid(rigidMesh, node, mesh)) { delete rigidMesh; return false; } meshFile = rigidMesh; } assert(meshFile != NULL); m_meshes.push_back(meshFile); } return true; }