From bd666f952ef8db22a902e518c89d4f7b02dc2727 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 18 Jun 2020 17:25:01 +0100 Subject: [PATCH] Raise minimum OSG version to 3.4.1 --- CMakeLists.txt | 2 +- src/Canvas/FGCanvasSystemAdapter.cxx | 8 ----- src/Main/main.cxx | 4 --- src/Model/panelnode.cxx | 8 +---- src/Model/panelnode.hxx | 8 +---- src/Scenery/SceneryPager.hxx | 2 -- src/Scenery/terrain_pgt.cxx | 5 +-- src/Viewer/CameraGroup_compositor.cxx | 1 - src/Viewer/CameraGroup_legacy.cxx | 1 - src/Viewer/FGEventHandler.hxx | 5 ++- src/Viewer/GraphicsWindowQt5.cpp | 4 --- src/Viewer/PUICamera.cxx | 45 +-------------------------- src/Viewer/PUICamera.hxx | 4 --- src/Viewer/splash.cxx | 13 +------- utils/fgviewer/Viewer.cxx | 4 --- utils/fgviewer/fgviewer.cxx | 8 ----- 16 files changed, 8 insertions(+), 114 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9be677904..b90f971db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,7 +297,7 @@ endif() # check required dependencies find_package(Boost REQUIRED) find_package(OpenGL REQUIRED) -find_package(OpenSceneGraph 3.2.0 REQUIRED +find_package(OpenSceneGraph 3.4.1 REQUIRED osgText osgSim osgDB diff --git a/src/Canvas/FGCanvasSystemAdapter.cxx b/src/Canvas/FGCanvasSystemAdapter.cxx index 7743b020e..68f5b036a 100644 --- a/src/Canvas/FGCanvasSystemAdapter.cxx +++ b/src/Canvas/FGCanvasSystemAdapter.cxx @@ -85,11 +85,7 @@ namespace canvas { SGPath valid_path = fgValidatePath(p, false); if( !valid_path.isNull() ) -#if OSG_VERSION_LESS_THAN(3,4,0) return osgDB::readRefImageFile(valid_path.utf8Str()); -#else - return osgDB::readRefImageFile(valid_path.utf8Str()); -#endif SG_LOG(SG_IO, SG_ALERT, "canvas::Image: reading '" << path << "' denied"); } @@ -97,11 +93,7 @@ namespace canvas { SGPath tpath = globals->resolve_resource_path(path); if( !tpath.isNull() ) -#if OSG_VERSION_LESS_THAN(3,4,0) - return osgDB::readImageFile(tpath.utf8Str()); -#else return osgDB::readRefImageFile(tpath.utf8Str()); -#endif SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'"); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 36cd04231..e2fb89066 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -577,10 +577,6 @@ int fgMainInit( int argc, char **argv ) SG_LOG( SG_GENERAL, SG_INFO, "Jenkins number/ID " << JENKINS_BUILD_NUMBER << ":" << JENKINS_BUILD_ID); -#if OSG_VERSION_LESS_THAN(3,4,1) - SG_LOG(SG_GENERAL, SG_ALERT, "Minimum supported OpenScenegraph is V3.4.1 - currently using " << osgGetVersion() << " This can cause fatal OSG 'final reference count' errors at runtime"); -#endif - flightgear::addSentryTag("jenkins-build-number", std::to_string(JENKINS_BUILD_NUMBER)); flightgear::addSentryTag("osg-version", osgGetVersion()); diff --git a/src/Model/panelnode.cxx b/src/Model/panelnode.cxx index 72224fdc7..e59b9a5b6 100644 --- a/src/Model/panelnode.cxx +++ b/src/Model/panelnode.cxx @@ -314,13 +314,7 @@ FGPanelNode::drawImplementation(osg::State& state) const _panel->draw(state); } -osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) -FGPanelNode::computeBound() -#else -FGPanelNode::computeBoundingBox() -#endif -const +osg::BoundingBox FGPanelNode::computeBoundingBox() const { osg::Vec3 coords[3]; diff --git a/src/Model/panelnode.hxx b/src/Model/panelnode.hxx index 05748d147..c42ea5693 100644 --- a/src/Model/panelnode.hxx +++ b/src/Model/panelnode.hxx @@ -32,13 +32,7 @@ public: void drawImplementation(osg::State& state) const; - virtual osg::BoundingBox -#if OSG_VERSION_LESS_THAN(3,3,2) - computeBound() -#else - computeBoundingBox() -#endif - const; + osg::BoundingBox computeBoundingBox() const override; /** Return true, FGPanelNode does support accept(PrimitiveFunctor&). */ diff --git a/src/Scenery/SceneryPager.hxx b/src/Scenery/SceneryPager.hxx index b225ecfe2..c4557571c 100644 --- a/src/Scenery/SceneryPager.hxx +++ b/src/Scenery/SceneryPager.hxx @@ -27,8 +27,6 @@ #include #include -#include - namespace flightgear { class SceneryPager : public osgDB::DatabasePager diff --git a/src/Scenery/terrain_pgt.cxx b/src/Scenery/terrain_pgt.cxx index f91441b0f..f7c5be713 100644 --- a/src/Scenery/terrain_pgt.cxx +++ b/src/Scenery/terrain_pgt.cxx @@ -121,11 +121,8 @@ void FGPgtTerrain::init( osg::Group* terrain ) { options->setDem(_dem); SG_LOG(SG_TERRAIN, SG_INFO, "Terrain init - Load w180s90-360x180.pgt" ); -#if OSG_VERSION_LESS_THAN(3,4,0) - osg::ref_ptr loadedModel = osgDB::readNodeFile("w180s90-360x180.pgt", options.get()); -#else osg::ref_ptr loadedModel = osgDB::readRefNodeFile("w180s90-360x180.pgt", options.get()); -#endif + if ( loadedModel ) { terrain_branch->addChild( loadedModel.get() ); diff --git a/src/Viewer/CameraGroup_compositor.cxx b/src/Viewer/CameraGroup_compositor.cxx index 98c190b39..638203344 100644 --- a/src/Viewer/CameraGroup_compositor.cxx +++ b/src/Viewer/CameraGroup_compositor.cxx @@ -29,7 +29,6 @@ #include // for copyProperties #include #include -#include #include #include #include diff --git a/src/Viewer/CameraGroup_legacy.cxx b/src/Viewer/CameraGroup_legacy.cxx index 2e946a568..6d7b09692 100644 --- a/src/Viewer/CameraGroup_legacy.cxx +++ b/src/Viewer/CameraGroup_legacy.cxx @@ -32,7 +32,6 @@ #include #include // for copyProperties #include -#include #include #include diff --git a/src/Viewer/FGEventHandler.hxx b/src/Viewer/FGEventHandler.hxx index fa8a24572..391023643 100644 --- a/src/Viewer/FGEventHandler.hxx +++ b/src/Viewer/FGEventHandler.hxx @@ -5,7 +5,6 @@ #include #include #include -#include #include
@@ -34,8 +33,8 @@ public: virtual void init(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us); #endif - virtual bool handle(const osgGA::GUIEventAdapter& ea, - osgGA::GUIActionAdapter& us); + bool handle(const osgGA::GUIEventAdapter& ea, + osgGA::GUIActionAdapter& us) override; void setIdleHandler(fgIdleHandler idleHandler) { diff --git a/src/Viewer/GraphicsWindowQt5.cpp b/src/Viewer/GraphicsWindowQt5.cpp index 9361476f8..52f514745 100644 --- a/src/Viewer/GraphicsWindowQt5.cpp +++ b/src/Viewer/GraphicsWindowQt5.cpp @@ -421,10 +421,8 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f ) getState()->setGraphicsContext(this); getState()->setContextID( osg::GraphicsContext::createNewContextID() ); -#if OSG_VERSION_GREATER_OR_EQUAL(3, 4, 0) // make sure the event queue has the correct window rectangle size and input range getEventQueue()->syncWindowRectangleWithGraphicsContext(); -#endif return true; } @@ -632,10 +630,8 @@ bool GraphicsWindowQt5::realizeImplementation() _window->show(); } -#if OSG_VERSION_GREATER_OR_EQUAL(3, 4, 0) // make sure the event queue has the correct window rectangle size and input range getEventQueue()->syncWindowRectangleWithGraphicsContext(); -#endif getEventQueue()->getCurrentEventState()->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS); diff --git a/src/Viewer/PUICamera.cxx b/src/Viewer/PUICamera.cxx index d198d93b0..8203a5ce8 100644 --- a/src/Viewer/PUICamera.cxx +++ b/src/Viewer/PUICamera.cxx @@ -57,40 +57,6 @@ using namespace flightgear; -#if OSG_VERSION_LESS_THAN(3,4,0) - -// this class kindly provided by Wojtek Lewandowsk on ths OpenSceneGraph-users -// mailing list from his code-archive, it's needed to poke the camera setup -// after resizing the FBO backing storage, on OSG 3.2.x - -class PUICamera::UpdateViewportAndFBOAfterTextureResizeCallback : public osg::NodeCallback -{ -public: - UpdateViewportAndFBOAfterTextureResizeCallback(bool dirty = false) : _dirty(dirty) {} - - void setDirty(bool dirty) { _dirty = dirty; } - bool getDirty() { return _dirty; } - - void operator()(osg::Node *node, osg::NodeVisitor *nv) - { - if (_dirty) - { - osgUtil::CullVisitor *cv = static_cast(nv); - if (cv && node == cv->getCurrentRenderStage()->getCamera()) - { - cv->getCurrentRenderStage()->setCameraRequiresSetUp(true); - _dirty = false; - } - } - - traverse(node, nv); - } -protected: - bool _dirty; -}; - -#endif - double static_pixelRatio = 1.0; class PUIDrawable : public osg::Drawable @@ -326,11 +292,6 @@ void PUICamera::init(osg::Group* parent, osgViewer::Viewer* viewer) // set the camera's node mask, ensure the pick bit is clear setNodeMask(SG_NODEMASK_GUI_BIT); -#if OSG_VERSION_LESS_THAN(3,4,0) - _resizeCullCallback = new UpdateViewportAndFBOAfterTextureResizeCallback; - setCullCallback(_resizeCullCallback); -#endif - // geode+drawable to call puDisplay, as a child of this FBO-camera osg::Geode* geode = new osg::Geode; geode->setName("PUIDrawableGeode"); @@ -393,13 +354,9 @@ void PUICamera::resizeUi(int width, int height) const int scaledHeight = static_cast(height / static_pixelRatio); setViewport(0, 0, scaledWidth, scaledHeight); -#if OSG_VERSION_LESS_THAN(3,4,0) - manuallyResizeFBO(scaledWidth, scaledHeight); - _resizeCullCallback->setDirty(true); -#else + osg::Camera::resize(scaledWidth, scaledHeight); resizeAttachments(scaledWidth, scaledHeight); -#endif const float puiZ = 1.0; // resize the full-screen quad diff --git a/src/Viewer/PUICamera.hxx b/src/Viewer/PUICamera.hxx index 57ff41124..5bfa34f79 100644 --- a/src/Viewer/PUICamera.hxx +++ b/src/Viewer/PUICamera.hxx @@ -49,10 +49,6 @@ public: void init(osg::Group* parent, osgViewer::Viewer* viewer); private: -#if OSG_VERSION_LESS_THAN(3,4,0) - class UpdateViewportAndFBOAfterTextureResizeCallback; - UpdateViewportAndFBOAfterTextureResizeCallback* _resizeCullCallback = nullptr; -#endif void manuallyResizeFBO(int width, int height); osg::Texture2D* _fboTexture = nullptr; diff --git a/src/Viewer/splash.cxx b/src/Viewer/splash.cxx index eeb69269e..5e8a3bccc 100644 --- a/src/Viewer/splash.cxx +++ b/src/Viewer/splash.cxx @@ -86,13 +86,10 @@ SplashScreen::~SplashScreen() void SplashScreen::createNodes() { std::string splashImage = selectSplashImage(); -#if OSG_VERSION_LESS_THAN(3,4,0) - _splashImage = osgDB::readImageFile(splashImage); -#else + osg::ref_ptr staticOptions = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); staticOptions->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); _splashImage = osgDB::readRefImageFile(splashImage, staticOptions); -#endif if (!_splashImage){ SG_LOG(SG_VIEW, SG_INFO, "Splash Image " << splashImage << " failed to load"); @@ -307,11 +304,7 @@ void SplashScreen::setupLogoImage() osg::ref_ptr staticOptions = simgear::SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); staticOptions->setLoadOriginHint(simgear::SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); -#if OSG_VERSION_LESS_THAN(3, 4, 0) - _logoImage = osgDB::readImageFile(logoPath.utf8Str(), staticOptions); -#else _logoImage = osgDB::readRefImageFile(logoPath.utf8Str(), staticOptions); -#endif if (!_logoImage) { SG_LOG(SG_VIEW, SG_INFO, "Splash logo image " << logoPath << " failed to load"); return; @@ -590,11 +583,7 @@ void SplashScreen::resize( int width, int height ) _height = height; _splashQuadCamera->setViewport(0, 0, width, height); -#if OSG_VERSION_LESS_THAN(3,4,0) - manuallyResizeFBO(width, height); -#else _splashFBOCamera->resizeAttachments(width, height); -#endif _splashFBOCamera->setViewport(0, 0, width, height); _splashFBOCamera->setProjectionMatrixAsOrtho2D(-width * 0.5, width * 0.5, -height * 0.5, height * 0.5); diff --git a/utils/fgviewer/Viewer.cxx b/utils/fgviewer/Viewer.cxx index 5f98fef1d..8f54a568c 100644 --- a/utils/fgviewer/Viewer.cxx +++ b/utils/fgviewer/Viewer.cxx @@ -553,12 +553,8 @@ Viewer::insertSceneData(const std::string& fileName, const osgDB::Options* optio proxyNode->setFileName(0, fileName); insertSceneData(proxyNode); return true; -#else -#if OSG_VERSION_LESS_THAN(3,4,0) - osg::ref_ptr node = osgDB::readNodeFile(fileName, options); #else osg::ref_ptr node = osgDB::readRefNodeFile(fileName, options); -#endif if (!node.valid()) return false; insertSceneData(node.get()); diff --git a/utils/fgviewer/fgviewer.cxx b/utils/fgviewer/fgviewer.cxx index 9270209b0..76a14879e 100644 --- a/utils/fgviewer/fgviewer.cxx +++ b/utils/fgviewer/fgviewer.cxx @@ -254,19 +254,11 @@ main(int argc, char** argv) osg::ref_ptr loadedModel; if (1 < arguments.argc()) { // read the scene from the list of file specified command line args. -#if OSG_VERSION_LESS_THAN(3,4,1) - loadedModel = osgDB::readNodeFiles(arguments, options.get()); -#else loadedModel = osgDB::readRefNodeFiles(arguments, options.get()); -#endif } else { // if no arguments given resort to the whole world scenery options->setPluginStringData("SimGear::FG_EARTH", "ON"); -#if OSG_VERSION_LESS_THAN(3,4,0) - loadedModel = osgDB::readNodeFile("w180s90-360x180.spt", options.get()); -#else loadedModel = osgDB::readRefNodeFile("w180s90-360x180.spt", options.get()); -#endif } // if no model has been successfully loaded report failure.