void GroundEyeshot::close() { m_pMapStream = 0; m_groundRenderQueue.finalize(); m_vTextures.clear(); safeDeleteArray(m_pGroundTileTable); if(m_pGroundTile) { int nTotalGrid = m_nTotalGridX * m_nTotalGridY; for(int i = 0;i < nTotalGrid;i++) { handle h = m_pGroundTile[i].getResHandle(); if(m_pResourceManager) { m_pResourceManager->releaseResource(h); m_pGroundTile[i].setResHandle(0); } } } //资源加载器不能释放,否则会造成异步加载时加载器为野指针 // if(m_pResourceManager) // { // m_pResourceManager->unregisterResourceLoader(typeResourceGroundTile); // safeDelete(m_ResourceLoader); // } safeDeleteArray(m_pGroundTile); safeRelease(m_pDefaultTexture); }
void cBatchRenderManager::finalize() { // line safeDeleteArray(m_lineList); safeDeleteArray(m_lineStrip); // entity for (uint i = 0; i < MASK_NUM; ++i) safeDelete(m_entityList[i]); }
Mesh::~Mesh() { safeDeleteArray(m_vertices); safeDeleteArray(m_normals); safeDeleteArray(m_uvs); safeDeleteArray(m_triangles); safeDelete(m_spatialAccel); if (m_batch != 0) glDeleteLists(m_batch, 1); }
bool FileStream::save(const char* newName) { Assert(!m_path.empty()); if (newName == NULL) return flush(); int oldPos = 0; uint size = 0; uchar* buffer = 0; FileStream fs(newName); bool isopen = isOpen(); if (!fs.open("wb")) goto IOErr; if (isopen) { flush(); oldPos = getPosition(); } else { if (!open()) goto IOErr; } size = getLength(); buffer = 0; if (size > 0) { buffer = new uchar[size]; if (!seekToBegin() || !read(buffer, size) || !fs.write(buffer, size)) goto IOErr; } fs.close(); if (isopen) seek(oldPos); else close(); safeDeleteArray(buffer); return true; IOErr: if (!isopen && isOpen()) close(); fs.close(); safeDeleteArray(buffer); return false; }
CWall3D::~CWall3D() { for( int i = 0; i < RMCOUNT; ++i ) { safeDelete( mRenderables[i] ); } safeDelete( mFadeInMesh ); stl_utils::wipe( mPiecesCombined ); safeDeleteArray( mPieces3D ); safeDeleteArray( mFracturedPieces ); safeDeleteArray( mPieceRestoreTimes ); safeDeleteArray( mQuadtree ); safeDeleteArray( mResTimeGrid ); }
void QuadraticBrush::makeMask() { // @TODO: [BRUSH] Set up the mask for your Quadratic brush here... // begin ta code { int size = 2 * m_radius + 1; if (m_mask) safeDeleteArray(m_mask); float *mask_ptr = m_mask = new float[size * size]; float flow = (float)m_flow / 255.0f; for(int y = 0; y < size; y++) { float fy = map_int_to_float(y, size); for(int x = 0; x < size; x++) { float fx = map_int_to_float(x, size); float radius_squared = fx * fx + fy * fy; if(radius_squared <= 1.0f) { float one_minus_radius = 1.0f - sqrtf(radius_squared); *mask_ptr++ = flow * one_minus_radius * one_minus_radius; } else *mask_ptr++ = 0.0f; } } } }
bool CResUpdater::WriteOldData( DWORD dwFileCount, const UHashValue* pRemoveList, DWORD dwRemoveFileCount ) { /** *@note 1. 首先预留一个文件头 */ DWORD dwFileHeadSize = Util::GetFileHeadSize<File_Version_1_0>(dwFileCount); m_NewResFile.Seek(dwFileHeadSize); m_dwPosNow = dwFileHeadSize; /** *@note 2. 将老文件中保留的数据索引放进m_NewFileDataIndex */ GetReserveDataIndexFromOldFile( m_pOldFileHead, pRemoveList, dwRemoveFileCount); /** *@note 将需要保留的数据从老文件中读出,并保存新文件 */ bool bRc = true; char* pBuf = NULL; DWORD nBufSize = 0; set<DataIndex0>::iterator iter = m_NewFileDataIndex.begin(); for (; iter!=m_NewFileDataIndex.end(); ++iter) { DataIndex0& TmpDataIndex = *iter; const DWORD& dwDataLen = TmpDataIndex.dwLen; DWORD& dwDataOffset = TmpDataIndex.dwOffset; /** *@note 看上次的buf是否够这个读文件,不够就重新new一个 * 这样设计的目的,减少对内存的new,delete,提高效率 */ Util::TryResetBuf(pBuf, nBufSize, dwDataLen); /** *@note 从老文件读数据,并写进新文件 */ m_OldResFile.Seek(dwDataOffset); if ( dwDataLen != m_OldResFile.Read(pBuf, dwDataLen) ) { bRc = false; break; } m_NewResFile.Write(pBuf, dwDataLen); /** *@note 改写新的文件索引,并刷新文件位置 */ dwDataOffset = m_dwPosNow; // 重新设定数据在新文件的位置 m_dwPosNow += dwDataLen; } safeDeleteArray(pBuf); m_OldResFile.Close(); return bRc; }
/** 关闭 @param @param @return */ void FrameInfoHeader::Close(void) { if(m_streamImageData.getBuffer() != NULL) { uchar * pBuff = m_streamImageData.detach(); safeDeleteArray(pBuff); } }
void GroundEyeshot::load(xs::Stream* pMapFile) { m_pMapStream = pMapFile; pMapFile->seekToBegin(); m_vTextures.clear(); safeDeleteArray(m_pGroundTileTable); m_strDistanceTextureFileName.clear(); xs::DataChunk chunk; xs::DataChunk::stChunk *pChunk = chunk.beginChunk(pMapFile); while(pChunk) { switch(pChunk->m_ui32Type) { case 'MTEX': { // 纹理列表 getNameList(m_vTextures,(char*)pChunk->m_pData,pChunk->m_ui32DataSize); } break; case 'MTID': { // 对应的纹理ID m_pGroundTileTable = new DWORD[m_nTotalGridX * m_nTotalGridY]; memcpy(m_pGroundTileTable,pChunk->m_pData,pChunk->m_ui32DataSize); } break; case 'MDIS': { // 远景图片 ASSERT(pChunk->m_pData != NULL); BYTE cbFileNameLength = *((BYTE*)(pChunk->m_pData)); char* szFileName = new char[cbFileNameLength + 1]; memcpy(szFileName, (BYTE*)(pChunk->m_pData) + sizeof(BYTE), cbFileNameLength); szFileName[cbFileNameLength] = 0; normalize_path(szFileName,strlen(szFileName)); SetDistanceTexture(szFileName); delete[] szFileName; } break; } pChunk = chunk.nextChunk(pMapFile); } for(int i = 0;i < m_nTotalGridX;i++) for(int j = 0;j < m_nTotalGridY;j++) { GroundTile *pTile = static_cast<GroundTile*>(getGroundTile(i,j)); m_pMapStream->seek(m_pGroundTileTable[j * m_nTotalGridX + i]); pTile->loadBasicInfo(m_pMapStream,m_vTextures); } }
void SceneMgr::close() { #if defined(RELEASEDEBUG) || defined(_DEBUG) m_mapTileInfo.clear(); #endif m_nMapVersion = ORIGIN_MAP_VERSION; SceneManager * pRealSceneMgr = static_cast<SceneManager * >( m_pSceneManager); SceneEntityList::iterator it = m_EntityList.begin(); SceneEntityList::iterator end = m_EntityList.end(); for(;it != end;) { bool ret = pRealSceneMgr->IsReferencedBySceneManager( (*it) ); if( ret ) { ++it; continue; } if (m_pSceneManager->getRunType() == RUN_TYPE_GAME) { EntityView *pEntity = (*it); pEntity->removeFlag(flagFade); // 地图上的物件(主要是magicview)在切换地图,原先没有正确释放掉,这里增加flagReleaseImmediate标志,使其立即释放避免内存泄露 [5/5/2011 zgz] pEntity->addFlag(flagReleaseImmediate); pEntity->update(0,0,0); safeRelease((*it)); } it = m_EntityList.erase(it); } safeDeleteArray(m_pMapTable); safeDeleteArray(m_pMultiValueTable); safeDeleteArray(m_pTiles); if(m_pTiles)m_nMatrixWidth = 0; m_EntityList.clear(); m_LayerListCache.close(); }
void MinimapEyeshot::close() { if(m_pResourceManager) { m_pResourceManager->unregisterResourceLoader(typeResourceMinimap); } if (m_pWorldMap) { m_pWorldMap->finalize(); safeDelete(m_pWorldMap); } safeRelease(m_pMinimapMask); safeDeleteArray(m_pTile); }
void CResReaderBase<Version>::Release( CUnPackDataInfo* pUnPackDataInfo) { ResMemType t = (ResMemType)pUnPackDataInfo->m_nMemType; switch (t) { case Mem_Unknown: case User_Allocate: break; case Reader_Static_Buf: case Reader_Allocate: safeDeleteArray(pUnPackDataInfo->m_pData); default: break; } }
/* Computes the normals. The vertex positions should be set. The normals * will be averaged (Gouraud Shading) */ void Mesh::computeNormals() { /*bool *normalFlip = new bool[m_nTriangles * 3]; for (unsigned i = 0; i < m_nTriangles; i++) { const Vector3 &normal = m_triangles[i].getNormal(pt); const Vector3 &nA = m_normals[m_triangles[i].nA]; const Vector3 &nB = m_normals[m_triangles[i].nB]; const Vector3 &nC = m_normals[m_triangles[i].nC]; normalFlip[i*3 + 0] = normal.dot(nA) < 0; normalFlip[i*3 + 1] = normal.dot(nB) < 0; normalFlip[i*3 + 2] = normal.dot(nC) < 0; }*/ Normal *normals = new Normal[m_nVertices]; m_nNormals = m_nVertices; for(unsigned i = 0; i < m_nTriangles; i++) { unsigned v1 = m_triangles[i].A; unsigned v2 = m_triangles[i].B; unsigned v3 = m_triangles[i].C; m_triangles[i].nA = v1; m_triangles[i].nB = v2; m_triangles[i].nC = v3; const Vector3 &normal = m_triangles[i].getNormal(); normals[v1] += normal; normals[v2] += normal; normals[v3] += normal; } for(unsigned i = 0; i < m_nNormals; i++) normals[i].normalize(); Normal *oldNormals = m_normals; m_normals = normals; setPreviewDirty(); safeDeleteArray(oldNormals); //safeDeleteArray(normalFlip); }
cTerrain::~cTerrain() { safeDelete(m_cell); safeDeleteArray(m_vertexList); }
SpectralSampleSet::~SpectralSampleSet() { safeDeleteArray(m_data); }
CIVPlaybackDataBuf::ChannelTarget::~ChannelTarget() { safeDeleteArray(m_pTargetBuf); };
cShadowCSM::~cShadowCSM() { safeDeleteArray(m_renderContext); safeDelete(m_depthShader); }
CGameMap::~CGameMap() { safeDeleteArray( mCells ); }
CResUpdaterByPatchData::~CResUpdaterByPatchData() { if ( m_bAutoDel ){safeDeleteArray(m_pPatchData);} }
cTerrainHeightMeshCell::~cTerrainHeightMeshCell() { safeDeleteArray(m_cellList); }
cAnimationMotion::~cAnimationMotion() { safeDeleteArray(m_frame); }
cTerrainNaviMeshCell::~cTerrainNaviMeshCell() { safeDeleteArray(m_cellList); safeDeleteArray(m_pathDataList); }