// Destructor CXFileEntity::~CXFileEntity(void) { if (m_animController) { m_animController->Release(); m_animController=0; } if (m_frameRoot) { // Create a mesh heirarchy class to control the removal of memory for the frame heirarchy CMeshHierarchy memoryAllocator; D3DXFrameDestroy(m_frameRoot, &memoryAllocator); m_frameRoot=0; } if (m_boneMatrices) { delete []m_boneMatrices; m_boneMatrices=0; } }
/** * Delete manager variables. */ void IND_3dMeshManager::freeVars() { // Deletes all the manager entities list <IND_3dMesh *>::iterator _listIter; for (_listIter = _list3dMesh->begin(); _listIter != _list3dMesh->end(); _listIter++) { g_debug->header("Freeing 3d mesh:", 3); g_debug->dataChar((*_listIter)->GetMeshName(), 1); // Free mesh if ((*_listIter)->_3dMesh._animController) { (*_listIter)->_3dMesh._animController->Release(); (*_listIter)->_3dMesh._animController = 0; } // Free heirarchy if ((*_listIter)->_3dMesh._frameRoot) { // Create a mesh heirarchy class to control the removal of memory for the frame heirarchy XMeshHierarchy memoryAllocator; D3DXFrameDestroy((*_listIter)->_3dMesh._frameRoot, &memoryAllocator); (*_listIter)->_3dMesh._frameRoot = 0; } // Free bones if ((*_listIter)->_3dMesh._boneMatrices) { DISPOSEARRAY((*_listIter)->_3dMesh._boneMatrices); } } // Clear list _list3dMesh->clear(); // Free list DISPOSE(_list3dMesh); }
//----------------------------------------------------------------------------- // The mesh class destructor. //----------------------------------------------------------------------------- Mesh::~Mesh() { // Destroy the frame hierarchy. AllocateHierarchy ah; D3DXFrameDestroy( m_firstFrame, &ah ); // Destroy the frames list and reference points list. m_frames->ClearPointers(); SAFE_DELETE( m_frames ); m_refPoints->ClearPointers(); SAFE_DELETE( m_refPoints ); // Release the animation controller. SAFE_RELEASE( m_animationController ); // Destroy the bone matrices. SAFE_DELETE_ARRAY( m_boneMatrices ); // Destroy the static mesh. if( m_staticMesh ) { // Remove all the static mesh's textures. for( unsigned long m = 0; m < m_staticMesh->NumMaterials; m++ ) if( m_staticMesh->materials ) Engine::GetInstance()->GetMaterialManager()->Remove( &m_staticMesh->materials[m] ); // Clean up the rest of it. SAFE_DELETE_ARRAY( m_staticMesh->materials ); SAFE_RELEASE( m_staticMesh->originalMesh ); SAFE_DELETE( m_staticMesh ); } // Destroy the vertex and index arrays. SAFE_DELETE_ARRAY( m_vertices ); SAFE_DELETE_ARRAY( m_indices ); }