listModel* deleteListModel(listModel* _list) { if(_list != NULL) { listModel* prev = NULL; while(_list->next != NULL) { prev = _list; _list = _list->next; deleteModel(prev->mod); free(prev); } deleteModel(_list->mod); free(_list); } return NULL; }
editorBrush::~editorBrush() { deleteModel(); /*for(unsigned int i = 0; i < faces.size(); i++) delete faces[i];*/ //free(faces); faces.clear(); }
ModelPicker::ModelPicker(QWidget* parent) : QWidget(parent) , ui(new Ui::ModelPicker) , favouriteList(new FavouriteList(this)) , modelList(new ModelList(this)) /*, modelIconSize(QSize(78, 78)) , modelIconMargin(QSize(0, 0)) , columns((width() - 50) / (modelIconSize.width() + modelIconMargin.width())) , box(new ToolBox())*/ { ui->setupUi(this); setMinimumHeight(200); //ui->verticalLayout->insertWidget(0, box); ui->horizontalLayout_2->addWidget(modelList); ui->gridLayout->addWidget(favouriteList, 3, 0, 1, 2); connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteModel())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearModels())); connect(ui->searchLine, SIGNAL(textChanged(QString)), this, SLOT(search(QString))); connect(favouriteList, SIGNAL(currentRowChanged(int)), this, SLOT(modelSelected(int))); connect(modelList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(modelSelected(QTreeWidgetItem*, QTreeWidgetItem*))); hide(); }
/* * Safely frees a PlanetStruct */ LOCAL void deletePlanet(struct PlanetStruct planet) { GLuint i; for(i = 0; i < 6; i++) { deleteModel(planet.terrainModels[i]); } }
int updateModel(listModel* _list, model* _model, char* _key) { if(_list != NULL && _model != NULL) { while(strcmp(_list->mod->key, _key) != 0) { if(_list->next == NULL) { return 1; } _list = _list->next; } deleteModel(_list->mod); _list->mod = _model; return 0; } return 1; }
// *************************************************************************** void CScene::deleteInstance(CTransformShape *pTrfmShp) { IShape *pShp = NULL; if( pTrfmShp == NULL ) return; pShp = pTrfmShp->Shape; deleteModel( pTrfmShp ); if (pShp) { // Even if model already deleted by smarptr the release function works _ShapeBank->release( pShp ); } }
// This is used to set the model we want to view in the control object. void GuiMaterialPreview::setObjectModel(const char* modelName) { deleteModel(); Resource<TSShape> model = ResourceManager::get().load(modelName); if (! bool(model)) { Con::warnf(avar("GuiMaterialPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName)); return; } mModel = new TSShapeInstance(model, true); AssertFatal(mModel, avar("GuiMaterialPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName)); // Initialize camera values: mOrbitPos = mModel->getShape()->center; mMinOrbitDist = mModel->getShape()->radius; lastRenderTime = Platform::getVirtualMilliseconds(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_pOAuth2 = new OAuth2(this); m_API_key = m_pOAuth2->getSimpleAPIKey(); connect(m_pOAuth2, SIGNAL(loginDone()), this, SLOT(loginDone())); m_managerPrediction.setAPIKey(m_API_key); connect(&m_managerPrediction, SIGNAL(replyText(QString)), this, SLOT(addReplyText(QString))); connect(&m_managerPrediction, SIGNAL(recvModelsList(QVariantList)), this, SLOT(recvModelsList(QVariantList))); connect(&m_managerPrediction, SIGNAL(recvModelDescription(QVariant)), this, SLOT(recvModelDescription(QVariant))); connect(&m_managerPrediction, SIGNAL(recvPredictionResult(QVariant)), this, SLOT(recvPredictionResult(QVariant))); connect(&m_managerPrediction, SIGNAL(recvAddToModelComplete(bool)), this, SLOT(recvAddToModelComplete(bool))); connect(ui->lwModelsList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedModelChanged())); connect(ui->actionDeleteModel, SIGNAL(triggered()), this, SLOT(deleteModel())); connect(ui->actionNewModel, SIGNAL(triggered()), this, SLOT(newModel())); connect(ui->actionUpdateModelsList, SIGNAL(triggered()), this, SLOT(updateModelsList())); connect(ui->actionUpdateModelInfo, SIGNAL(triggered()), this, SLOT(updateModelInfo())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->predictButton, SIGNAL(clicked()), this, SLOT(predict())); connect(ui->lineEditTextToPredict, SIGNAL(returnPressed()), this, SLOT(predict())); connect(ui->actionLogin, SIGNAL(triggered()), this, SLOT(login())); connect(&timerTest, SIGNAL(timeout()), this, SLOT(testSendRequest())); startLogin(false); }
// *************************************************************************** void CScene::endPartRender(bool keepTrav) { nlassert(_IsRendering); _IsRendering = false; if (!keepTrav) { // Delete model deleted during the rendering uint i; for (i=0; i<_ToDelete.size(); i++) deleteModel (_ToDelete[i]); _ToDelete.clear (); // Special for SkeletonSpawnScript animation. create models spawned now flushSSSModelRequests(); // Particle system handling (remove the resources of those which are too far, as their clusters may not have been parsed). // Note that only a few of them are tested at each call _ParticleSystemManager.refreshModels(ClipTrav.WorldFrustumPyramid, ClipTrav.CamPos); // Waiting Instance handling double deltaT = _DeltaSystemTimeBetweenRender; clamp (deltaT, 0.01, 0.1); updateWaitingInstances(deltaT); } // Reset profiling _NextRenderProfile= false; IDriver *drv = getDriver(); drv->activeVertexProgram(NULL); drv->activePixelProgram(NULL); drv->activeGeometryProgram(NULL); // Ensure nothing animates on subsequent renders _EllapsedTime = 0.f; /* uint64 total = PSStatsRegisterPSModelObserver + PSStatsRemovePSModelObserver + PSStatsUpdateOpacityInfos + PSStatsUpdateLightingInfos + PSStatsGetAABBox + PSStatsReallocRsc + PSStatsReleasePSPointer + PSStatsRefreshRscDeletion + PSStatsReleaseRsc + PSStatsReleaseRscAndInvalidate + PSStatsGetNumTriangles + PSStatsCheckAgainstPyramid + PSStatsTraverseAnimDetail + PSStatsDoAnimate + PSStatsTraverseRender + PSStatsTraverseClip + PSStatsCheckDestroyCondition + PSStatsForceInstanciate + PSStatsDoAnimatePart1 + PSStatsDoAnimatePart2 + PSStatsDoAnimatePart3 + PSStatsTraverseAnimDetailPart1 + PSStatsTraverseAnimDetailPart2 + PSStatsTraverseAnimDetailPart3 + PSStatsTraverseAnimDetailPart4 + PSAnim1 + PSAnim2+ PSAnim3+ PSAnim4+ PSAnim5+ PSAnim6+ PSAnim7+ PSAnim8+ PSAnim9+ PSAnim10+ PSAnim11; if (((double) total / (double) NLMISC::CSystemInfo::getProcessorFrequency()) > 0.01) { nlinfo("***** PS STATS ****"); #define PS_STATS(var) \ nlinfo("time for " #var " = %.2f", (float) (1000 * ((double) var / (double) CSystemInfo::getProcessorFrequency()))); PS_STATS(PSStatsRegisterPSModelObserver) PS_STATS(PSStatsRemovePSModelObserver) PS_STATS(PSStatsUpdateOpacityInfos) PS_STATS(PSStatsUpdateLightingInfos) PS_STATS(PSStatsGetAABBox) PS_STATS(PSStatsReallocRsc) PS_STATS(PSStatsReleasePSPointer) PS_STATS(PSStatsRefreshRscDeletion) PS_STATS(PSStatsReleaseRsc) PS_STATS(PSStatsReleaseRscAndInvalidate) PS_STATS(PSStatsGetNumTriangles) PS_STATS(PSStatsCheckAgainstPyramid) PS_STATS(PSStatsTraverseAnimDetail) PS_STATS(PSStatsDoAnimate) PS_STATS(PSStatsTraverseRender) PS_STATS(PSStatsTraverseClip) PS_STATS(PSStatsClipSystemInstanciated); PS_STATS(PSStatsClipSystemNotInstanciated); PS_STATS(PSStatsClipSystemCheckAgainstPyramid); PS_STATS(PSStatsInsertInVisibleList); PS_STATS(PSStatsCheckDestroyCondition) PS_STATS(PSStatsForceInstanciate) PS_STATS(PSStatsDoAnimatePart1) PS_STATS(PSStatsDoAnimatePart2) PS_STATS(PSStatsDoAnimatePart3) PS_STATS(PSStatsTraverseAnimDetailPart1) PS_STATS(PSStatsTraverseAnimDetailPart2) PS_STATS(PSStatsTraverseAnimDetailPart3) PS_STATS(PSStatsTraverseAnimDetailPart4) PS_STATS(PSAnim1) PS_STATS(PSAnim2) PS_STATS(PSAnim3) PS_STATS(PSAnim4) PS_STATS(PSAnim5) PS_STATS(PSAnim6) PS_STATS(PSAnim7) PS_STATS(PSAnim8) PS_STATS(PSAnim9) PS_STATS(PSAnim10) PS_STATS(PSAnim11) PS_STATS(PSStatsZonePlane) PS_STATS(PSStatsZoneSphere) PS_STATS(PSStatsZoneDisc) PS_STATS(PSStatsZoneRectangle) PS_STATS(PSStatsZoneCylinder) PS_STATS(PSMotion1) PS_STATS(PSMotion2) PS_STATS(PSMotion3) PS_STATS(PSMotion4) PS_STATS(PSStatCollision) PS_STATS(PSStatEmit) PS_STATS(PSStatRender) nlinfo("num do animate = %d", (int) PSStatsNumDoAnimateCalls); nlinfo("Max et = %.2f", PSMaxET); nlinfo("Max ps nb pass = %d", (int) PSMaxNBPass); PS_STATS(total) } PSStatsRegisterPSModelObserver = 0; PSStatsRemovePSModelObserver = 0; PSStatsUpdateOpacityInfos = 0; PSStatsUpdateLightingInfos = 0; PSStatsGetAABBox = 0; PSStatsReallocRsc = 0; PSStatsReleasePSPointer = 0; PSStatsRefreshRscDeletion = 0; PSStatsReleaseRsc = 0; PSStatsReleaseRscAndInvalidate = 0; PSStatsGetNumTriangles = 0; PSStatsCheckAgainstPyramid = 0; PSStatsTraverseAnimDetail = 0; PSStatsDoAnimate = 0; PSStatsTraverseRender = 0; PSStatsTraverseClip = 0; PSStatsCheckDestroyCondition = 0; PSStatsForceInstanciate = 0; PSStatsClipSystemInstanciated = 0; PSStatsClipSystemNotInstanciated = 0; PSStatsClipSystemCheckAgainstPyramid = 0; PSStatsInsertInVisibleList = 0; PSStatsDoAnimatePart1 = 0; PSStatsDoAnimatePart2 = 0; PSStatsDoAnimatePart3 = 0; PSStatsTraverseAnimDetailPart1 = 0; PSStatsTraverseAnimDetailPart2 = 0; PSStatsTraverseAnimDetailPart3 = 0; PSStatsTraverseAnimDetailPart4 = 0; PSStatsNumDoAnimateCalls = 0; PSAnim1 = 0; PSAnim2 = 0; PSAnim3 = 0; PSAnim4 = 0; PSAnim5 = 0; PSAnim6 = 0; PSAnim7 = 0; PSAnim8 = 0; PSAnim9 = 0; PSAnim10 = 0; PSAnim11 = 0; PSMaxET = 0.f; PSMaxNBPass = 0; PSStatsZonePlane = 0; PSStatsZoneSphere = 0; PSStatsZoneDisc = 0; PSStatsZoneRectangle = 0; PSStatsZoneCylinder = 0; PSMotion1 = 0; PSMotion2 = 0; PSMotion3 = 0; PSMotion4 = 0; PSStatCollision = 0; PSStatEmit = 0; PSStatRender = 0; */ }
// *************************************************************************** void CScene::release() { // reset the _QuadGridClipManager, => unlink models, and delete clusters. if( _QuadGridClipManager ) _QuadGridClipManager->reset(); // First, delete models. set<CTransform*>::iterator it; it= _Models.begin(); while( it!=_Models.end()) { CTransform *tr= *it; // Don't delete The Roots, because used, for instance in ~CSkeletonModel() if(tr!=Root && tr!=RootCluster && tr!=SonsOfAncestorSkeletonModelGroup) deleteModel(tr); // temp erase from the list else _Models.erase(it); // NB: important to take begin(), and not it++, cause ~CSkeletonModel() may delete ScriptSpawned models it= _Models.begin(); } // Then delete the roots // reinsert if(Root) _Models.insert(Root); if(RootCluster) _Models.insert(RootCluster); if(SonsOfAncestorSkeletonModelGroup) _Models.insert(SonsOfAncestorSkeletonModelGroup); // delete in the reverse order of initDefaultRoots() if(SonsOfAncestorSkeletonModelGroup) { deleteModel(SonsOfAncestorSkeletonModelGroup); SonsOfAncestorSkeletonModelGroup= NULL; } if(RootCluster) { deleteModel(RootCluster); RootCluster= NULL; } if(Root) { deleteModel(Root); Root= NULL; } // No models at all. _UpdateModelList= NULL; // reset ptrs _ShapeBank = NULL; Root= NULL; RootCluster= NULL; SonsOfAncestorSkeletonModelGroup= NULL; CurrentCamera= NULL; _QuadGridClipManager= NULL; ClipTrav.setQuadGridClipManager(NULL); // DON'T reset the _LodCharacterManager, because it can be shared across scenes /* if(_LodCharacterManager) _LodCharacterManager->reset(); */ _LodCharacterManager= NULL; // delete the coarseMeshManager if(_CoarseMeshManager) { delete _CoarseMeshManager; _CoarseMeshManager= NULL; } if(_GlobalInstanceGroup) { delete _GlobalInstanceGroup; _GlobalInstanceGroup = NULL; } // delete the play list _LMAnimsAuto.deleteAll(); }