diff --git a/apps/Launcher/infowidget.cpp b/apps/Launcher/infowidget.cpp index ff2537c407..ddde63591a 100644 --- a/apps/Launcher/infowidget.cpp +++ b/apps/Launcher/infowidget.cpp @@ -75,7 +75,7 @@ InfoWidget::InfoWidget(QString name, int totalBytes) setLayout(layout); } -void InfoWidget::update(openspace::DownloadManager::FileFuture* f) { +void InfoWidget::update(std::shared_ptr f) { _bytes->setText( QString("%1 / %2") .arg(f->currentSize) diff --git a/apps/Launcher/infowidget.h b/apps/Launcher/infowidget.h index 2099a774af..2eaec279b9 100644 --- a/apps/Launcher/infowidget.h +++ b/apps/Launcher/infowidget.h @@ -40,7 +40,7 @@ Q_OBJECT public: InfoWidget(QString name, int totalBytes = -1); - void update(openspace::DownloadManager::FileFuture* f); + void update(std::shared_ptr f); void update(libtorrent::torrent_status s); void error(QString message); diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp index 6ed87b2544..0710378173 100644 --- a/apps/Launcher/syncwidget.cpp +++ b/apps/Launcher/syncwidget.cpp @@ -230,7 +230,7 @@ void SyncWidget::setSceneFiles(QMap sceneFiles) { } void SyncWidget::clear() { - for (openspace::DownloadManager::FileFuture* f : _futures) + for (std::shared_ptr f : _futures) f->abortDownload = true; using libtorrent::torrent_handle; @@ -254,7 +254,7 @@ void SyncWidget::handleDirectFiles() { for (const DirectFile& f : _directFiles) { LDEBUG(f.url.toStdString() << " -> " << f.destination.toStdString()); - openspace::DownloadManager::FileFuture* future = DlManager.downloadFile( + std::shared_ptr future = DlManager.downloadFile( f.url.toStdString(), absPath("${SCENE}/" + f.module.toStdString() + "/" + f.destination.toStdString()), OverwriteFiles @@ -571,8 +571,8 @@ void SyncWidget::handleTimer() { using namespace libtorrent; using FileFuture = openspace::DownloadManager::FileFuture; - std::vector toRemove; - for (FileFuture* f : _futures) { + std::vector> toRemove; + for (std::shared_ptr f : _futures) { InfoWidget* w = _futureInfoWidgetMap[f]; if (CleanInfoWidgets && (f->isFinished || f->isAborted)) { @@ -585,13 +585,12 @@ void SyncWidget::handleTimer() { w->update(f); } - for (FileFuture* f : toRemove) { + for (std::shared_ptr f : toRemove) { _futures.erase(std::remove(_futures.begin(), _futures.end(), f), _futures.end()); - delete f; } while (_mutex.test_and_set()) {} - for (openspace::DownloadManager::FileFuture* f : _futuresToAdd) { + for (std::shared_ptr f : _futuresToAdd) { InfoWidget* w = new InfoWidget(QString::fromStdString(f->filePath), -1); _downloadLayout->insertWidget(_downloadLayout->count() - 1, w); @@ -679,7 +678,7 @@ void SyncWidget::handleTimer() { } void SyncWidget::handleFileFutureAddition( - const std::vector& futures) + const std::vector>& futures) { while (_mutex.test_and_set()) {} _futuresToAdd.insert(_futuresToAdd.end(), futures.begin(), futures.end()); diff --git a/apps/Launcher/syncwidget.h b/apps/Launcher/syncwidget.h index b4b2c108e4..e17f54be7f 100644 --- a/apps/Launcher/syncwidget.h +++ b/apps/Launcher/syncwidget.h @@ -83,7 +83,7 @@ private: void clear(); QStringList selectedScenes() const; - void handleFileFutureAddition(const std::vector& futures); + void handleFileFutureAddition(const std::vector>& futures); void handleDirectFiles(); void handleFileRequest(); @@ -101,10 +101,10 @@ private: QList _fileRequests; QList _torrentFiles; - std::vector _futures; - std::map _futureInfoWidgetMap; + std::vector> _futures; + std::map, InfoWidget*> _futureInfoWidgetMap; - std::vector _futuresToAdd; + std::vector> _futuresToAdd; std::atomic_flag _mutex; }; diff --git a/include/openspace/engine/downloadmanager.h b/include/openspace/engine/downloadmanager.h index c155774818..fcd5200f14 100644 --- a/include/openspace/engine/downloadmanager.h +++ b/include/openspace/engine/downloadmanager.h @@ -64,20 +64,20 @@ public: using DownloadFinishedCallback = std::function; using RequestFinishedCallback = std::function; using AsyncDownloadFinishedCallback = - std::function&)>; + std::function>&)>; DownloadManager(std::string requestURL, int applicationVersion, bool useMultithreadedDownload = true); // callers responsibility to delete // callbacks happen on a different thread - FileFuture* downloadFile(const std::string& url, const ghoul::filesystem::File& file, + std::shared_ptr downloadFile(const std::string& url, const ghoul::filesystem::File& file, bool overrideFile = true, DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(), DownloadProgressCallback progressCallback = DownloadProgressCallback() ); - std::vector downloadRequestFiles(const std::string& identifier, + std::vector> downloadRequestFiles(const std::string& identifier, const ghoul::filesystem::Directory& destination, int version, bool overrideFiles = true, DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(), diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 0ae92c4713..e547159681 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -71,6 +71,7 @@ public: //void addNode(SceneGraphNode* child); + void addChild(SceneGraphNode* child); void setParent(SceneGraphNode* parent); //bool abandonChild(SceneGraphNode* child); diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index 76b18d889a..80f7ccbe04 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -225,7 +225,7 @@ void RenderableFieldlines::render(const RenderData& data) { _program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix()); _program->setUniform("modelTransform", glm::mat4(1.0)); _program->setUniform("cameraViewDir", data.camera.viewDirection()); - setPscUniforms(_program.get(), &data.camera, data.position); + setPscUniforms(*(_program.get()), data.camera, data.position); _program->setUniform("classification", _classification); if (!_classification) diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index bbde399204..c41665682d 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -50,7 +50,7 @@ namespace { const std::string RequestApplicationVersion = "application_version"; struct ProgressInformation { - openspace::DownloadManager::FileFuture* future; + std::shared_ptr future; std::chrono::system_clock::time_point startTime; const openspace::DownloadManager::DownloadProgressCallback* callback; }; @@ -139,14 +139,14 @@ DownloadManager::DownloadManager(std::string requestURL, int applicationVersion, // TODO: Allow for multiple requestURLs } -DownloadManager::FileFuture* DownloadManager::downloadFile( +std::shared_ptr DownloadManager::downloadFile( const std::string& url, const ghoul::filesystem::File& file, bool overrideFile, DownloadFinishedCallback finishedCallback, DownloadProgressCallback progressCallback) { if (!overrideFile && FileSys.fileExists(file)) return nullptr; - FileFuture* future = new FileFuture(file.filename()); + std::shared_ptr future = std::make_shared(file.filename()); FILE* fp = fopen(file.path().c_str(), "wb"); LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'"); @@ -202,13 +202,12 @@ DownloadManager::FileFuture* DownloadManager::downloadFile( return future; } - -std::vector DownloadManager::downloadRequestFiles( +std::vector> DownloadManager::downloadRequestFiles( const std::string& identifier, const ghoul::filesystem::Directory& destination, int version, bool overrideFiles, DownloadFinishedCallback finishedCallback, DownloadProgressCallback progressCallback) { - std::vector futures; + std::vector> futures; FileSys.createDirectory(destination, ghoul::filesystem::FileSystem::Recursive::Yes); // TODO: Check s ---abock // TODO: Escaping is necessary ---abock @@ -239,7 +238,7 @@ std::vector DownloadManager::downloadRequestFiles( LDEBUG("\tLine: " << line << " ; Dest: " << destination.path() + "/" + file); - FileFuture* future = DlManager.downloadFile( + std::shared_ptr future = DlManager.downloadFile( line, destination.path() + "/" + file, overrideFiles, @@ -251,7 +250,7 @@ std::vector DownloadManager::downloadRequestFiles( isFinished = true; }; - FileFuture* f = downloadFile( + std::shared_ptr f = downloadFile( fullRequest, requestFile, true, @@ -268,7 +267,7 @@ void DownloadManager::downloadRequestFilesAsync(const std::string& identifier, AsyncDownloadFinishedCallback callback) { auto downloadFunction = [this, identifier, destination, version, overrideFiles, callback](){ - std::vector f = downloadRequestFiles( + std::vector> f = downloadRequestFiles( identifier, destination, version, diff --git a/src/rendering/abufferrenderer.cpp b/src/rendering/abufferrenderer.cpp index 84c7d16840..0d0dd27d45 100644 --- a/src/rendering/abufferrenderer.cpp +++ b/src/rendering/abufferrenderer.cpp @@ -99,6 +99,9 @@ void ABufferRenderer::initialize() { glGenTextures(1, &_fragmentTexture); _nAaSamples = OsEng.windowWrapper().currentNumberOfAaSamples(); + if (_nAaSamples == 0) { + _nAaSamples = 1; + } if (_nAaSamples > 8) { LERROR("ABuffer renderer does not support more than 8 MSAA samples."); _nAaSamples = 8; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index f9a441aafe..e2e7213ede 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -123,6 +123,9 @@ void FramebufferRenderer::initialize() { OsEng.renderEngine().raycasterManager().addListener(*this); _nAaSamples = OsEng.windowWrapper().currentNumberOfAaSamples(); + if (_nAaSamples == 0) { + _nAaSamples = 1; + } if (_nAaSamples > 8) { LERROR("Framebuffer renderer does not support more than 8 MSAA samples."); _nAaSamples = 8; diff --git a/src/scene/scenegraph.cpp b/src/scene/scenegraph.cpp index cf69955fb5..00975b8485 100644 --- a/src/scene/scenegraph.cpp +++ b/src/scene/scenegraph.cpp @@ -261,6 +261,8 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) { } node->node->setParent(parentNode); + parentNode->addChild(node->node); + } // Setup dependencies diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index c3f36f9e23..5f88de541d 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -155,10 +155,10 @@ bool SceneGraphNode::deinitialize() { delete _ephemeris; _ephemeris = nullptr; - for (SceneGraphNode* child : _children) { - child->deinitialize(); - delete child; - } + // for (SceneGraphNode* child : _children) { + // child->deinitialize(); + // delete child; + //} _children.clear(); // reset variables @@ -283,6 +283,11 @@ void SceneGraphNode::setParent(SceneGraphNode* parent) _parent = parent; } +void SceneGraphNode::addChild(SceneGraphNode* child) { + _children.push_back(child); +} + + //not used anymore @AA //bool SceneGraphNode::abandonChild(SceneGraphNode* child) { // std::vector < SceneGraphNode* >::iterator it = std::find(_children.begin(), _children.end(), child);