diff --git a/ground/gcs/src/libs/osgearth/copydata.pro b/ground/gcs/src/libs/osgearth/copydata.pro index 09509ff14..97ad37ab0 100644 --- a/ground/gcs/src/libs/osgearth/copydata.pro +++ b/ground/gcs/src/libs/osgearth/copydata.pro @@ -2,8 +2,7 @@ # copy osg and osgearth libraries and data to build dir # -# set debug suffix if needed -#win32:CONFIG(debug, debug|release):DS = "d" +OSG_VERSION = 3.5.1 contains(QT_ARCH, x86_64) { LIB_DIR_NAME = lib64 @@ -11,12 +10,8 @@ contains(QT_ARCH, x86_64) { LIB_DIR_NAME = lib } -win32 { - OSG_VERSION = 3.5.1 -} else { - OSG_VERSION = 3.4.0 -} - +# set debug suffix if needed +#win32:CONFIG(debug, debug|release):DS = "d" osg:linux { # copy osg libraries diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGModelNode.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGModelNode.cpp index 63907e37c..13c681f42 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGModelNode.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGModelNode.cpp @@ -59,7 +59,7 @@ public: public: - Hidden(OSGModelNode *parent) : QObject(parent), self(parent), modelData(NULL), sceneData(NULL), offset(-1.0), clampToTerrain(false), dirty(false) + Hidden(OSGModelNode *parent) : QObject(parent), self(parent), modelData(NULL), sceneData(NULL), offset(-1.0), clampToTerrain(false), intoTerrain(false), dirty(false) {} ~Hidden() diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp index 18a78ea2e..67508ac7a 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp @@ -91,8 +91,6 @@ public: updateMode(UpdateMode::Discrete), frameTimer(-1) { - qDebug() << "OSGViewport::Hidden"; - OsgEarth::initialize(); createViewer(); @@ -102,9 +100,6 @@ public: ~Hidden() { - qDebug() << "OSGViewport::~Hidden"; - // osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "OSGViewport::~Hidden"); - stop(); destroyViewer(); @@ -127,6 +122,7 @@ public slots: } this->window = window; } + public: bool acceptSceneData(OSGNode *node) @@ -161,15 +157,17 @@ public: qWarning() << "OSGViewport::attach - invalid scene!"; return false; } - if (!attach(view, sceneData->node())) { - qWarning() << "OSGViewport::attach - failed to attach node!"; - return false; - } + // attach camera if (camera) { camera->attach(view); } else { qWarning() << "OSGViewport::attach - no camera!"; } + // attach scene + if (!attach(view, sceneData->node())) { + qWarning() << "OSGViewport::attach - failed to attach node!"; + return false; + } return true; } @@ -198,6 +196,7 @@ public: } #endif + qDebug() << "OSGViewport::attach - set scene" << node; view->setSceneData(node); return true; @@ -233,14 +232,14 @@ public: void initializeResources() { qDebug() << "OSGViewport::initializeResources"; - if (!view.valid()) { - qDebug() << "OSGViewport::initializeResources - creating view"; - view = createView(); - self->attach(view.get()); - viewer->addView(view); - start(); - // osgDB::writeNodeFile(*(h->self->sceneData()->node()), "saved.osg"); + if (view.valid()) { + qWarning() << "OSGViewport::initializeResources - view already created!"; + return; } + view = createView(); + self->attach(view.get()); + viewer->addView(view); + start(); } void releaseResources() @@ -259,7 +258,6 @@ public: bool acceptUpdateMode(UpdateMode::Enum mode) { - // qDebug() << "OSGViewport::acceptUpdateMode" << mode; if (updateMode == mode) { return true; } diff --git a/ground/gcs/src/libs/osgearth/osgearth.cpp b/ground/gcs/src/libs/osgearth/osgearth.cpp index 73181fd30..cc1d7bb7b 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.cpp +++ b/ground/gcs/src/libs/osgearth/osgearth.cpp @@ -72,6 +72,7 @@ void OsgEarth::registerQmlTypes() registered = true; // redirect osg logging to Qt (and export OSG_NOTIFY_LEVEL=DEBUG to enable osg logging) + // Note : enabling the notify handler seems to cause crashes (the notifier is probably not thread safe) // osg::setNotifyHandler(new QtNotifyHandler()); // initialize(); @@ -106,11 +107,6 @@ void OsgEarth::initialize() initializeCache(); - // force early initialization of osgEarth capabilities - // Doing this too early (before main window is displayed) causes rendering glitches (black holes) - // Not sure why... See OSGViewport for when it is called (late...) - // osgEarth::Registry::capabilities(); - displayInfo(); } @@ -151,7 +147,7 @@ void OsgEarth::initializeCache() } else { qWarning() << "OsgEarth::initializeCache - Failed to initialize cache"; } -#endif // ifdef USE_OSGEARTH +#endif } void OsgEarth::displayInfo() diff --git a/ground/gcs/src/libs/osgearth/qtwindowingsystem.cpp b/ground/gcs/src/libs/osgearth/qtwindowingsystem.cpp index f25faa822..3ac9a0297 100644 --- a/ground/gcs/src/libs/osgearth/qtwindowingsystem.cpp +++ b/ground/gcs/src/libs/osgearth/qtwindowingsystem.cpp @@ -297,7 +297,6 @@ bool GraphicsWindowQt::makeCurrentImplementation() return false; } if (_owned && _glContext) { - // qDebug() << "GraphicsWindowQt::makeCurrentImplementation : " << _surface; if (!_glContext->makeCurrent(_surface)) { qWarning() << "GraphicsWindowQt::makeCurrentImplementation : failed to make context current"; return false; diff --git a/make/3rdparty/osgearth/osg-3.4.0.patch b/make/3rdparty/osgearth/osg-3.4.0.patch new file mode 100644 index 000000000..e8ebd4457 --- /dev/null +++ b/make/3rdparty/osgearth/osg-3.4.0.patch @@ -0,0 +1,24 @@ +diff --git a/include/osg/OperationThread b/include/osg/OperationThread +index a62157e..75adfba 100644 +--- a/include/osg/OperationThread ++++ b/include/osg/OperationThread +@@ -80,6 +80,7 @@ protected: + _keep(false) {} + + Operation(const Operation& op): ++ Referenced(), + _name(op._name), + _keep(op._keep) {} + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 33edf57..d2ea025 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -27,7 +27,6 @@ FOREACH( mylibfolder + osgUI + osgVolume + osgWrappers/serializers +- osgWrappers/deprecated-dotosg + osgPlugins + ) + diff --git a/make/3rdparty/osgearth/osgearth-2.7.patch b/make/3rdparty/osgearth/osgearth-2.7.patch index 690eae3af..d6ef84719 100644 --- a/make/3rdparty/osgearth/osgearth-2.7.patch +++ b/make/3rdparty/osgearth/osgearth-2.7.patch @@ -1,3 +1,56 @@ +diff --git a/src/osgEarth/ElevationQuery b/src/osgEarth/ElevationQuery +index d8e4d14..50db567 100644 +--- a/src/osgEarth/ElevationQuery ++++ b/src/osgEarth/ElevationQuery +@@ -37,7 +37,11 @@ namespace osgEarth + + void pruneUnusedDatabaseCache(); + ++#if OSG_VERSION_GREATER_OR_EQUAL(3,5,0) ++ virtual osg::ref_ptr readNodeFile(const std::string& filename); ++#else + virtual osg::Node* readNodeFile(const std::string& filename); ++#endif + + protected: + +diff --git a/src/osgEarth/ElevationQuery.cpp b/src/osgEarth/ElevationQuery.cpp +index 5fb8222..8c03309 100644 +--- a/src/osgEarth/ElevationQuery.cpp ++++ b/src/osgEarth/ElevationQuery.cpp +@@ -55,7 +55,11 @@ void ElevationQueryCacheReadCallback::pruneUnusedDatabaseCache() + { + } + ++#if OSG_VERSION_GREATER_OR_EQUAL(3,5,0) ++osg::ref_ptr ElevationQueryCacheReadCallback::readNodeFile(const std::string& filename) ++#else + osg::Node* ElevationQueryCacheReadCallback::readNodeFile(const std::string& filename) ++#endif + { + // first check to see if file is already loaded. + { +@@ -71,7 +75,7 @@ osg::Node* ElevationQueryCacheReadCallback::readNodeFile(const std::string& file + } + + // now load the file. +- osg::ref_ptr node = osgDB::readNodeFile(filename); ++ osg::ref_ptr node = osgDB::readRefNodeFile(filename); + + // insert into the cache. + if (node.valid()) +@@ -105,7 +109,11 @@ osg::Node* ElevationQueryCacheReadCallback::readNodeFile(const std::string& file + } + } + ++#if OSG_VERSION_GREATER_OR_EQUAL(3,5,0) ++ return node; ++#else + return node.release(); ++#endif + } + + ElevationQuery::ElevationQuery(const Map* map) : diff --git a/src/osgEarthSymbology/Resource b/src/osgEarthSymbology/Resource index a8a1441..934fc7d 100644 --- a/src/osgEarthSymbology/Resource diff --git a/make/3rdparty/osgearth/osgearth.mk b/make/3rdparty/osgearth/osgearth.mk index b820f2881..9f68c4c22 100644 --- a/make/3rdparty/osgearth/osgearth.mk +++ b/make/3rdparty/osgearth/osgearth.mk @@ -31,12 +31,8 @@ OSG_NAME_SUFIX := -qt-$(QT_VERSION) # ################################ -#OSG_VERSION := 0b63c8ffde -#OSG_GIT_BRANCH := $(OSG_VERSION) -#OSG_VERSION := 3.4.0-rc5 -#OSG_GIT_BRANCH := tags/OpenSceneGraph-$(OSG_VERSION) -OSG_VERSION := 3.4 -OSG_GIT_BRANCH := OpenSceneGraph-$(OSG_VERSION) +OSG_VERSION := 3.5.1 +OSG_GIT_TAG := OpenSceneGraph-$(OSG_VERSION) OSG_BASE_NAME := osg-$(OSG_VERSION) @@ -137,15 +133,14 @@ prepare_osg: clone_osg .PHONY: clone_osg clone_osg: - $(V1) if [ ! -d "$(OSG_SRC_DIR)" ]; then \ - $(ECHO) "Cloning osg..." ; \ - $(GIT) clone --no-checkout git://github.com/openscenegraph/osg.git $(OSG_SRC_DIR) ; \ + $(V1) if [ -d "$(OSG_SRC_DIR)" ]; then \ + $(ECHO) "Deleting osg clone..." ; \ + $(RM) -rf $(OSG_SRC_DIR) ; \ fi - @$(ECHO) "Fetching osg..." - $(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) fetch ; ) - @$(ECHO) "Checking out osg $(OSG_GIT_BRANCH)" - $(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) fetch --tags ; ) - $(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) checkout --quiet --force $(OSG_GIT_BRANCH) ; ) + @$(ECHO) "Cloning osg..." + $(V1) $(GIT) clone --depth 1 --no-checkout -b $(OSG_GIT_TAG) git://github.com/openscenegraph/osg.git $(OSG_SRC_DIR) + @$(ECHO) "Checkout osg $(OSG_GIT_TAG)" + $(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) checkout --force tags/$(OSG_GIT_TAG) ; ) $(V1) if [ -e $(OSG_PATCH_FILE) ]; then \ $(ECHO) "Patching osg..." ; \ ( $(CD) $(OSG_SRC_DIR) && $(GIT) apply $(OSG_PATCH_FILE) ; ) \ @@ -173,17 +168,14 @@ clean_all_osg: clean_osg # fix Debug build # add option to not build the applications (in Debug mode in particular) -#OSGEARTH_VERSION := 1873b3a9489 -#OSGEARTH_GIT_BRANCH := $(OSGEARTH_VERSION) -OSGEARTH_VERSION := 2.7 -OSGEARTH_GIT_BRANCH := osgearth-$(OSGEARTH_VERSION) +OSGEARTH_VERSION := 2.7 +OSGEARTH_GIT_TAG := osgearth-$(OSGEARTH_VERSION) OSGEARTH_BASE_NAME := osgearth-$(OSGEARTH_VERSION) OSGEARTH_BUILD_CONF := $(OSG_BUILD_CONF) # osgearth cmake script calls the osgversion executable to find the osg version -# this makes it necessary to have osg in the pathes (bin and lib) to make sure the correct one is found -# ideally this should not be necessary +# this makes it necessary to have osg in the path (bin and lib) to make sure the correct one is found ifeq ($(UNAME), Linux) ifeq ($(ARCH), x86_64) OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-linux-x64 @@ -259,16 +251,15 @@ prepare_osgearth: clone_osgearth .PHONY: clone_osgearth clone_osgearth: - $(V1) if [ ! -d "$(OSGEARTH_SRC_DIR)" ]; then \ - $(ECHO) "Cloning osgearth..." ; \ - $(GIT) clone --no-checkout git://github.com/gwaldron/osgearth.git $(OSGEARTH_SRC_DIR) ; \ + $(V1) if [ -d "$(OSGEARTH_SRC_DIR)" ]; then \ + $(ECHO) "Deleting osgearth clone..." ; \ + $(RM) -rf $(OSGEARTH_SRC_DIR) ; \ fi - @$(ECHO) "Fetching osgearth..." - $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) fetch ; ) - @$(ECHO) "Checking out osgearth $(OSGEARTH_GIT_BRANCH)" - $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) fetch --tags ; ) - $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) checkout --quiet --force $(OSGEARTH_GIT_BRANCH) ; ) - $(V1) if [ -f "$(OSGEARTH_PATCH_FILE)" ]; then \ + @$(ECHO) "Cloning osgearth..." + $(V1) $(GIT) clone --depth 1 --no-checkout -b $(OSGEARTH_GIT_TAG) git://github.com/gwaldron/osgearth.git $(OSGEARTH_SRC_DIR) + @$(ECHO) "Checkout osgearth $(OSGEARTH_GIT_TAG)" + $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) checkout --force tags/$(OSGEARTH_GIT_TAG) ; ) + $(V1) if [ -e $(OSGEARTH_PATCH_FILE) ]; then \ $(ECHO) "Patching osgearth..." ; \ ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) apply $(OSGEARTH_PATCH_FILE) ; ) \ fi diff --git a/make/tools.mk b/make/tools.mk index 714de682c..779b289be 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -89,13 +89,13 @@ ifeq ($(UNAME), Linux) QT_SDK_ARCH := gcc_64 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x64-5.5.1.run QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x64-5.5.1.run.md5 - OSG_URL := http://librepilot.github.io/tools/osg-3.4-linux-x64-qt-5.5.1.tar.gz + OSG_URL := http://librepilot.github.io/tools/osg-3.5.1-linux-x64-qt-5.5.1.tar.gz OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-linux-x64-qt-5.5.1.tar.gz else QT_SDK_ARCH := gcc QT_SDK_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x86-5.5.1.run QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x86-5.5.1.run.md5 - OSG_URL := http://librepilot.github.io/tools/osg-3.4-linux-x86-qt-5.5.1.tar.gz + OSG_URL := http://librepilot.github.io/tools/osg-3.5.1-linux-x86-qt-5.5.1.tar.gz OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-linux-x86-qt-5.5.1.tar.gz endif UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz @@ -108,7 +108,7 @@ else ifeq ($(UNAME), Darwin) QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-clang-5.5.1/qt-opensource-mac-x64-clang-5.5.1.app/Contents/MacOS/qt-opensource-mac-x64-clang-5.5.1 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz - OSG_URL := http://librepilot.github.io/tools/osg-3.4-clang_64-qt-5.5.1.tar.gz + OSG_URL := http://librepilot.github.io/tools/osg-3.5.1-clang_64-qt-5.5.1.tar.gz OSGEARTH_URL := http://librepilot.github.io/tools/osgearth-2.7-clang_64-qt-5.5.1.tar.gz else ifeq ($(UNAME), Windows) QT_SDK_ARCH := mingw492_32 @@ -134,14 +134,14 @@ OSG_TOOLS_DIR := $(TOOLS_DIR) ifeq ($(UNAME), Linux) ifeq ($(ARCH), x86_64) - OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-linux-x64-qt-$(QT_VERSION) + OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.5.1-linux-x64-qt-$(QT_VERSION) OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-linux-x64-qt-$(QT_VERSION) else - OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-linux-x86-qt-$(QT_VERSION) + OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.5.1-linux-x86-qt-$(QT_VERSION) OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-linux-x86-qt-$(QT_VERSION) endif else ifeq ($(UNAME), Darwin) - OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.4-clang_64-qt-$(QT_VERSION) + OSG_SDK_DIR := $(OSG_TOOLS_DIR)/osg-3.5.1-clang_64-qt-$(QT_VERSION) OSGEARTH_SDK_DIR := $(OSG_TOOLS_DIR)/osgearth-2.7-clang_64-qt-$(QT_VERSION) else ifeq ($(UNAME), Windows) MINGW_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)