void UnloadObjects(const rct_object_entry * entries, size_t count) override { // TODO there are two performance issues here: // - FindObject for every entry which is a dictionary lookup // - GetLoadedObjectIndex for every entry which enumerates _loadedList size_t numObjectsUnloaded = 0; for (size_t i = 0; i < count; i++) { const rct_object_entry * entry = &entries[i]; const ObjectRepositoryItem * ori = _objectRepository->FindObject(entry); if (ori != nullptr) { Object * loadedObject = ori->LoadedObject; if (loadedObject != nullptr) { UnloadObject(loadedObject); numObjectsUnloaded++; } } } if (numObjectsUnloaded > 0) { UpdateLegacyLoadedObjectList(); UpdateSceneryGroupIndexes(); reset_type_to_ride_entry_index_map(); } }
void UnloadAll() override { if (_loadedObjects != nullptr) { for (sint32 i = 0; i < OBJECT_ENTRY_COUNT; i++) { UnloadObject(_loadedObjects[i]); } } UpdateLegacyLoadedObjectList(); UpdateSceneryGroupIndexes(); reset_type_to_ride_entry_index_map(); }
void CleanupObjectViewer() { if(UIrend3d) { UnloadObject(); // just in case :) UIrend3d->Cleanup(); delete UIrend3d; UIrend3d=NULL; } if(gBSPList != NULL) { gBSPList->RemoveAll(); delete gBSPList; gBSPList=NULL; } }
bool ImageCanvas::LoadObject(const QString & session, const QString & cam, const QString & img, const double & ux, const double & uy) { if ((current_session == session) && (current_cam == cam) && (current_img == img)) { CenterOnWorldPosition(ux, uy, 1.0); return true; } UnloadObject(); QFileInfo image_file(db->GetImageLocation(session, cam, img)); if(!image_file.isFile() || !image_file.isReadable()) return false; image_layer = new QgsRasterLayer(image_file.filePath(),image_file.fileName()); connect(image_layer,SIGNAL(progressUpdate(int)),this,SLOT(ShowProgress(int))); image_layer->setLayerName("image"); image_provider = image_layer->dataProvider(); if (!image_layer->isValid()) return false; QgsContrastEnhancement* qgsContrastEnhRed = new QgsContrastEnhancement(QGis::UInt16); QgsContrastEnhancement* qgsContrastEnhGreen = new QgsContrastEnhancement(QGis::UInt16); QgsContrastEnhancement* qgsContrastEnhBlue = new QgsContrastEnhancement(QGis::UInt16); QgsMultiBandColorRenderer* renderer = new QgsMultiBandColorRenderer( image_provider, 1, 2, 3, qgsContrastEnhRed, qgsContrastEnhGreen, qgsContrastEnhBlue); image_layer->setRenderer( renderer ); layer_registry->addMapLayer(image_layer); QList<QgsMapCanvasLayer> layer_set; layer_set.append(image_layer); setLayerSet(layer_set); CenterOnWorldPosition(ux, uy, 1.0); current_session = session; current_cam = cam; current_img = img; return true; }
void UnloadObjectsExcept(Object * * newLoadedObjects) { if (_loadedObjects == nullptr) { return; } // Build a hash set for quick checking auto exceptSet = std::unordered_set<Object *>(); for (sint32 i = 0; i < OBJECT_ENTRY_COUNT; i++) { Object * object = newLoadedObjects[i]; if (object != nullptr) { exceptSet.insert(object); } } // Unload objects that are not in the hash set size_t totalObjectsLoaded = 0; size_t numObjectsUnloaded = 0; for (sint32 i = 0; i < OBJECT_ENTRY_COUNT; i++) { Object * object = _loadedObjects[i]; if (object != nullptr) { totalObjectsLoaded++; if (exceptSet.find(object) == exceptSet.end()) { UnloadObject(object); numObjectsUnloaded++; } } } log_verbose("%u / %u objects unloaded", numObjectsUnloaded, totalObjectsLoaded); }
VoxelObject::~VoxelObject() { UnloadObject(); Reset(); }