From 568a6a3416e22d5b9d40c06a6d70a56aa9127120 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Fri, 1 Apr 2016 17:47:00 +0200 Subject: [PATCH 1/4] fix bug when numberOfSamples is 0 --- src/rendering/abufferrenderer.cpp | 3 +++ src/rendering/framebufferrenderer.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/rendering/abufferrenderer.cpp b/src/rendering/abufferrenderer.cpp index e0f4783ec5..15e2911877 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; From 019092e98ebb29b7eef3316f9060ae5d4eeb7af9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 4 Apr 2016 20:26:10 +0200 Subject: [PATCH 2/4] Correctly set child nodes for SceneGraphNode%s --- ext/ghoul | 2 +- include/openspace/scene/scenegraphnode.h | 1 + src/scene/scenegraph.cpp | 2 ++ src/scene/scenegraphnode.cpp | 13 +++++++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 849cc67bdc..901a96beda 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 849cc67bdc2550a43d8174490d39b14ee148b795 +Subproject commit 901a96bedad5fa789b4e45e61e97c5c1d909631c 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/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); From e23a1f3e3cd1bf42937b7335d2a4857363ca0436 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 4 Apr 2016 20:26:27 +0200 Subject: [PATCH 3/4] Fix compilatioon of renderablefieldlines --- modules/fieldlines/rendering/renderablefieldlines.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 0d0f761d6ef520010b50fd9c498e16ef48a1108a Mon Sep 17 00:00:00 2001 From: Michael Nilsson Date: Tue, 5 Apr 2016 11:33:58 -0400 Subject: [PATCH 4/4] downloadmanager return shared_ptr to FileFutures instead of bare pointers --- apps/Launcher/infowidget.cpp | 2 +- apps/Launcher/infowidget.h | 2 +- apps/Launcher/syncwidget.cpp | 15 +++++++-------- apps/Launcher/syncwidget.h | 8 ++++---- include/openspace/engine/downloadmanager.h | 6 +++--- src/engine/downloadmanager.cpp | 16 ++++++++-------- 6 files changed, 24 insertions(+), 25 deletions(-) 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 653dd1edd1..53b90cf683 100644 --- a/include/openspace/engine/downloadmanager.h +++ b/include/openspace/engine/downloadmanager.h @@ -63,20 +63,20 @@ public: using DownloadProgressCallback = std::function; using DownloadFinishedCallback = 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/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 7c69aa0638..e4f608fd36 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; }; @@ -133,14 +133,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() << "'"); @@ -196,12 +196,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 @@ -232,7 +232,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, @@ -244,7 +244,7 @@ std::vector DownloadManager::downloadRequestFiles( isFinished = true; }; - FileFuture* f = downloadFile( + std::shared_ptr f = downloadFile( fullRequest, requestFile, true, @@ -261,7 +261,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,