1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-22 14:19:42 +01:00

Merged in filnet/librepilot/filnet/LP-29_osgearth_integration (pull request #172)

Filnet/lp 29_osgearth_integration
This commit is contained in:
Philippe Renon 2016-02-12 09:06:59 +01:00
commit 3fe5d1f7a4
9 changed files with 124 additions and 68 deletions

View File

@ -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

View File

@ -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()

View File

@ -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;
}

View File

@ -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()

View File

@ -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;

24
make/3rdparty/osgearth/osg-3.4.0.patch vendored Normal file
View File

@ -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
)

View File

@ -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<osg::Node> 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<osg::Node> 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<osg::Node> node = osgDB::readNodeFile(filename);
+ osg::ref_ptr<osg::Node> 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

View File

@ -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

View File

@ -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)