bool CPhysicsManager::ReleasePhysicActor (CPhysicActor* actor) { assert(actor != NULL); assert(m_pScene != NULL); assert(m_pPhysicsSDK != NULL); bool isOk = false; NxActor* nxActor = actor->GetPhXActor(); if( nxActor != 0) { NxArray<NxCCDSkeleton*> skeletons; for (NxU32 i = 0; i < nxActor->getNbShapes(); i++) { NxShape* shape = nxActor->getShapes()[i]; if (shape->getCCDSkeleton() != NULL) { skeletons.pushBack(shape->getCCDSkeleton()); } } for (NxU32 i = 0; i < skeletons.size(); i++) { m_pPhysicsSDK->releaseCCDSkeleton(*skeletons[i]); } m_pScene->releaseActor(*nxActor); nxActor = 0; } return true; }
//---------------------------------------------------------------------------- // ReleaseAllActors : Alliberem tots els actors de l'escena de PhysX //---------------------------------------------------------------------------- bool CPhysicsManager::ReleaseAllActors ( void ) //EUserDataFlag _eFlags ) { assert ( m_pScene != NULL ); assert ( m_pPhysicsSDK != NULL ); bool isOk = true; NxActor** l_ppActorList = m_pScene->getActors(); NxU32 l_TotalActors = m_pScene->getNbActors(); while ( l_TotalActors -- ) { NxActor* nxActor = *l_ppActorList; if ( nxActor != 0) { NxArray<NxCCDSkeleton*> skeletons; for (NxU32 i = 0; i < nxActor->getNbShapes(); i++) { NxShape* shape = nxActor->getShapes()[i]; if (shape->getCCDSkeleton() != NULL) { skeletons.pushBack(shape->getCCDSkeleton()); } } for (NxU32 i = 0; i < skeletons.size(); i++) { m_pPhysicsSDK->releaseCCDSkeleton(*skeletons[i]); } m_pScene->releaseActor(*nxActor); nxActor = 0; } } return isOk; }