// **************************************************************************** void CStaticStringMapper::memoryCompress() { _MemoryCompressed = true; std::map<TSStringId, std::string>::iterator it = _TempIdTable.begin(); uint nTotalSize = 0; uint32 nNbStrings = 0; while (it != _TempIdTable.end()) { nTotalSize += (uint)it->second.size() + 1; nNbStrings++; it++; } _AllStrings = new char[nTotalSize]; _IdToStr.resize(nNbStrings); nNbStrings = 0; nTotalSize = 0; it = _TempIdTable.begin(); while (it != _TempIdTable.end()) { strcpy(_AllStrings + nTotalSize, it->second.c_str()); _IdToStr[nNbStrings] = _AllStrings + nTotalSize; nTotalSize += (uint)it->second.size() + 1; nNbStrings++; it++; } contReset(_TempStringTable); contReset(_TempIdTable); }
// *************************************************************************** void CRawSkinNormalCache::clearArrays() { Vertices1.clear(); Vertices2.clear(); Vertices3.clear(); Vertices4.clear(); contReset(Geomorphs); contReset(RdrPass); contReset(VertexRemap); }
// **************************************************************************** void CStaticStringMapper::clear() { contReset(_TempStringTable); contReset(_TempIdTable); delete [] _AllStrings; contReset(_IdToStr); _IdCounter = 0; _AllStrings = NULL; _MemoryCompressed = false; add(""); }
// *************************************************************************** void CAnimationSet::buildChannelNameFromMap() { contReset(_ChannelName); _ChannelName.resize(_ChannelIdByName.size()); std::map <std::string, uint32>::iterator it; for(it= _ChannelIdByName.begin();it!=_ChannelIdByName.end();it++) { _ChannelName[it->second]= it->first; } }
void PlayerSetupDialog::setupUI() { connect(ui->addPlayerBtn, SIGNAL(clicked()), this, SLOT(newPlayer())); connect(ui->removePlayerBtn, SIGNAL(clicked()), this, SLOT(removePlayer())); connect(ui->newSubviewBtn, SIGNAL(clicked()), this, SLOT(newSubview())); connect(ui->delSubviewBtn, SIGNAL(clicked()), this, SLOT(removeSubview())); connect(ui->testConnectionBtn, SIGNAL(clicked()), this, SLOT(testConnection())); connect(ui->connectBtn, SIGNAL(clicked()), this, SLOT(connectPlayer())); connect(ui->autoconnectBox, SIGNAL(toggled(bool)), this, SLOT(autoconBoxChanged(bool))); connect(ui->playerListview, SIGNAL(activated(const QModelIndex &)), this, SLOT(playerSelected(const QModelIndex &))); connect(ui->playerListview, SIGNAL(clicked(const QModelIndex &)), this, SLOT(playerSelected(const QModelIndex &))); connect(ui->subviewListview, SIGNAL(activated(const QModelIndex &)), this, SLOT(subviewSelected(const QModelIndex &))); connect(ui->subviewListview, SIGNAL(clicked(const QModelIndex &)), this, SLOT(subviewSelected(const QModelIndex &))); connect(ui->aphaMaskBrowseBtn, SIGNAL(clicked()), this, SLOT(alphamaskBrowse())); connect(ui->keyTLx, SIGNAL(valueChanged(int)), this, SLOT(subviewTopLeftXChanged(int))); connect(ui->keyTLy, SIGNAL(valueChanged(int)), this, SLOT(subviewTopLeftYChanged(int))); connect(ui->keyTRx, SIGNAL(valueChanged(int)), this, SLOT(subviewTopRightXChanged(int))); connect(ui->keyTRy, SIGNAL(valueChanged(int)), this, SLOT(subviewTopRightYChanged(int))); connect(ui->keyBLx, SIGNAL(valueChanged(int)), this, SLOT(subviewBottomLeftXChanged(int))); connect(ui->keyBLy, SIGNAL(valueChanged(int)), this, SLOT(subviewBottomLeftYChanged(int))); connect(ui->keyBRx, SIGNAL(valueChanged(int)), this, SLOT(subviewBottomRightXChanged(int))); connect(ui->keyBRy, SIGNAL(valueChanged(int)), this, SLOT(subviewBottomRightYChanged(int))); connect(ui->outputX, SIGNAL(valueChanged(int)), this, SLOT(screenXChanged(int))); connect(ui->outputY, SIGNAL(valueChanged(int)), this, SLOT(screenYChanged(int))); connect(ui->outputWidth, SIGNAL(valueChanged(int)), this, SLOT(screenWChanged(int))); connect(ui->outputHeight, SIGNAL(valueChanged(int)), this, SLOT(screenHChanged(int))); connect(ui->viewportX, SIGNAL(valueChanged(int)), this, SLOT(viewportXChanged(int))); connect(ui->viewportY, SIGNAL(valueChanged(int)), this, SLOT(viewportYChanged(int))); connect(ui->viewportWidth, SIGNAL(valueChanged(int)), this, SLOT(viewportWChanged(int))); connect(ui->viewportHeight, SIGNAL(valueChanged(int)), this, SLOT(viewportHChanged(int))); connect(ui->optIgnoreAR, SIGNAL(toggled(bool)), this, SLOT(ignoreArBoxChanged(bool))); connect(ui->aphaMaskBrowseBtn, SIGNAL(clicked()), this, SLOT(alphamaskBrowse())); connect(ui->alphaMaskFile, SIGNAL(textChanged(QString)), this, SLOT(showAlphaMaskPreview(QString))); connect(ui->brightnessResetBtn, SIGNAL(clicked()), this, SLOT(brightReset())); connect(ui->contrastResetBtn, SIGNAL(clicked()), this, SLOT(contReset())); connect(ui->hueResetBtn, SIGNAL(clicked()), this, SLOT(hueReset())); connect(ui->saturationResetBtn, SIGNAL(clicked()), this, SLOT(satReset())); }
// **************************************************************************** void CStaticStringMapper::memoryUncompress() { std::map<std::string, TSStringId> tempStringTable; std::map<TSStringId, std::string> tempIdTable; for(uint k = 0; k < _IdToStr.size(); ++k) { tempStringTable[_IdToStr[k]] = (TSStringId) k; tempIdTable[(TSStringId) k] = _IdToStr[k]; } delete [] _AllStrings; _AllStrings = NULL; contReset(_IdToStr); _TempStringTable.swap(tempStringTable); _TempIdTable.swap(tempIdTable); _MemoryCompressed = false; }
void CDriverD3D::endProfileIBLock(std::vector<std::string> &result) { if(!_IBProfiling) return; // Fill infos. result.clear(); result.resize(_IBProfiles.size() + 2); float total= 0; for(uint i=0;i<_IBProfiles.size();i++) { const uint tmpSize= 256; char tmp[tmpSize]; CIBProfile &ibProf= _IBProfiles[i]; const char *ibName; if(ibProf.IB && !ibProf.IB->getName().empty()) { ibName= ibProf.IB->getName().c_str(); } else { ibName= "????"; } // Display in ms. float timeLock= (float)CTime::ticksToSecond(ibProf.AccumTime)*1000 / max(_NumIBProfileFrame,1U); smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", ibName, ibProf.Change?'*':' ', timeLock ); total+= timeLock; result[i]= tmp; } result[_IBProfiles.size()]= toString("Total: %2.3f", total); float volatileIBTimeLock = (float)CTime::ticksToSecond(_VolatileIBLockTime)*1000 / max(_NumIBProfileFrame,1U); result[_IBProfiles.size() + 1]= toString("Volatile Index Buffer lock time = %2.3f", volatileIBTimeLock); nlwarning("IB lock time = %2.3f", total); nlwarning("Volatile IB lock time = %2.3f", volatileIBTimeLock); // clear. _IBProfiling= false; contReset(_IBProfiles); }
void CDriverD3D::endProfileVBHardLock(std::vector<std::string> &result) { if(!_VBHardProfiling) return; // Fill infos. result.clear(); result.resize(_VBHardProfiles.size() + 2); float total= 0; for(uint i=0;i<_VBHardProfiles.size();i++) { const uint tmpSize= 256; char tmp[tmpSize]; CVBHardProfile &vbProf= _VBHardProfiles[i]; const char *vbName; if(vbProf.VBHard && !vbProf.VBHard->getName().empty()) { vbName= vbProf.VBHard->getName().c_str(); } else { vbName= "????"; } // Display in ms. float timeLock= (float)CTime::ticksToSecond(vbProf.AccumTime)*1000 / max(_NumVBHardProfileFrame,1U); smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock ); total+= timeLock; result[i]= tmp; } result[_VBHardProfiles.size()]= toString("Total: %2.3f", total); // float volatileVBTimeLock = (float)CTime::ticksToSecond(_VolatileVBLockTime)*1000 / max(_NumVBHardProfileFrame,1U); result[_VBHardProfiles.size() + 1]= toString("Volatile Vertex Buffer lock time = %2.3f", _VolatileVBLockTime); // clear. _VBHardProfiling= false; contReset(_VBHardProfiles); }
void CSheetId::loadSheetId () { H_AUTO(CSheetIdInit); //nldebug("Loading sheet_id.bin"); // Open the sheet id to sheet file name association CIFile file; std::string path = CPath::lookup("sheet_id.bin", false, false); if(!path.empty() && file.open(path)) { // clear entries _FileExtensions.clear (); _SheetIdToName.clear (); _SheetNameToId.clear (); // reserve space for the vector of file extensions _FileExtensions.resize(1 << (NL_SHEET_ID_TYPE_BITS)); // Get the map from the file map<uint32,string> tempMap; contReset(tempMap); file.serialCont(tempMap); file.close(); if (_RemoveUnknownSheet) { uint32 removednbfiles = 0; uint32 nbfiles = (uint32)tempMap.size(); // now we remove all files that not available map<uint32,string>::iterator itStr2; for( itStr2 = tempMap.begin(); itStr2 != tempMap.end(); ) { if (CPath::exists ((*itStr2).second)) { ++itStr2; } else { map<uint32,string>::iterator olditStr = itStr2; //nldebug ("Removing file '%s' from CSheetId because the file not exists", (*olditStr).second.c_str ()); itStr2++; tempMap.erase (olditStr); removednbfiles++; } } nlinfo ("SHEETID: Removed %d files on %d from CSheetId because these files doesn't exists", removednbfiles, nbfiles); } // Convert the map to one big string and 1 static map (id to name) { // Get the number and size of all strings vector<CChar> tempVec; // Used to initialise the first map uint32 nNb = 0; uint32 nSize = 0; map<uint32,string>::const_iterator it = tempMap.begin(); while (it != tempMap.end()) { nSize += (uint32)it->second.size()+1; nNb++; it++; } // Make the big string (composed of all strings) and a vector referencing each string tempVec.resize(nNb); _AllStrings.Ptr = new char[nSize]; it = tempMap.begin(); nSize = 0; nNb = 0; while (it != tempMap.end()) { tempVec[nNb].Ptr = _AllStrings.Ptr+nSize; strcpy(_AllStrings.Ptr+nSize, it->second.c_str()); toLower(_AllStrings.Ptr+nSize); nSize += (uint32)it->second.size()+1; nNb++; it++; } // Finally build the static map (id to name) _SheetIdToName.reserve(tempVec.size()); it = tempMap.begin(); nNb = 0; while (it != tempMap.end()) { _SheetIdToName.add(pair<uint32, CChar>(it->first, CChar(tempVec[nNb]))); nNb++; it++; } // The vector of all small string is not needed anymore we have all the info in // the static map and with the pointer AllStrings referencing the beginning. } // Build the invert map (Name to Id) & file extension vector { uint32 nSize = (uint32)_SheetIdToName.size(); _SheetNameToId.reserve(nSize); CStaticMap<uint32,CChar>::iterator itStr; for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) { // add entry to the inverse map _SheetNameToId.add( make_pair((*itStr).second, (*itStr).first) ); // work out the type value for this entry in the map TSheetId sheetId; sheetId.Id=(*itStr).first; uint32 type = sheetId.IdInfos.Type; // check whether we need to add an entry to the file extensions vector if (_FileExtensions[type].empty()) { // find the file extension part of the given file name _FileExtensions[type] = toLower(CFile::getExtension((*itStr).second.Ptr)); } nSize--; } _SheetNameToId.endAdd(); } } else { nlerror("<CSheetId::init> Can't open the file sheet_id.bin"); } nldebug("Finished loading sheet_id.bin: %u entries read",_SheetIdToName.size()); }