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;