From 8b596dfcbe8a142a77b0af54f257343c16469cc2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 12 Feb 2016 14:46:45 +0100 Subject: [PATCH 1/3] Remove support for OSG 3.2 Since commit e8662bea3133ba9dbb09b86c3abb1af39425e90d, we're using OSG functionality that contains an unfixed crash bug in version 3.2. The bug is fixed in version 3.4 (OSG commit 6351e5020371b0b72b300088a5c6772f58379b84) --- CMakeLists.txt | 2 +- apps/openmw/mwrender/animation.cpp | 14 ----------- apps/openmw/mwrender/objects.cpp | 15 ----------- apps/openmw/mwrender/sky.cpp | 4 --- components/nifosg/nifloader.cpp | 32 ------------------------ components/resource/imagemanager.cpp | 7 ------ components/resource/scenemanager.cpp | 17 ------------- components/sceneutil/clone.cpp | 5 ---- components/sceneutil/controller.cpp | 8 ------ components/sceneutil/riggeometry.cpp | 2 -- components/sdlutil/sdlgraphicswindow.cpp | 8 ------ components/terrain/terraingrid.cpp | 6 ----- 12 files changed, 1 insertion(+), 119 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52970cfb59..df2ee6f49a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,7 +233,7 @@ if (USE_QT) set (OSG_QT osgQt) endif() -find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle ${OSG_QT} osgUtil osgFX) +find_package(OpenSceneGraph 3.4.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle ${OSG_QT} osgUtil osgFX) include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 398fe53225..e3cc57bc42 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -201,17 +201,10 @@ namespace class RemoveDrawableVisitor : public RemoveVisitor { public: - virtual void apply(osg::Geode &geode) - { - applyImpl(geode); - } - -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) virtual void apply(osg::Drawable& drw) { applyImpl(drw); } -#endif void applyImpl(osg::Node& node) { @@ -239,17 +232,10 @@ namespace class RemoveTriBipVisitor : public RemoveVisitor { public: - virtual void apply(osg::Geode &node) - { - applyImpl(node); - } - -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) virtual void apply(osg::Drawable& drw) { applyImpl(drw); } -#endif void applyImpl(osg::Node& node) { diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 516d10b959..d249a7602e 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -43,26 +43,11 @@ namespace traverse(node); } - virtual void apply(osg::Geode& geode) - { - std::vector partsysVector; - for (unsigned int i=0; i(drw)) - partsysVector.push_back(partsys); - } - - for (std::vector::iterator it = partsysVector.begin(); it != partsysVector.end(); ++it) - geode.removeDrawable(*it); - } -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) virtual void apply(osg::Drawable& drw) { if (osgParticle::ParticleSystem* partsys = dynamic_cast(&drw)) mToRemove.push_back(partsys); } -#endif void remove() { diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 40283ba275..1757314fe2 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -1282,11 +1282,7 @@ public: if (stateset->getAttribute(osg::StateAttribute::MATERIAL)) { SceneUtil::CompositeStateSetUpdater* composite = NULL; -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) osg::Callback* callback = node.getUpdateCallback(); -#else - osg::NodeCallback* callback = node.getUpdateCallback(); -#endif while (callback) { if ((composite = dynamic_cast(callback))) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 6c6061063e..61fbc9b966 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -934,13 +934,7 @@ namespace NifOsg updater->addParticleSystem(partsys); parentNode->addChild(updater); -#if OSG_VERSION_LESS_THAN(3,3,3) - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(partsys); - osg::Node* toAttach = geode.get(); -#else osg::Node* toAttach = partsys.get(); -#endif if (rf == osgParticle::ParticleProcessor::RELATIVE_RF) parentNode->addChild(toAttach); @@ -1017,11 +1011,6 @@ namespace NifOsg triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags); } -#if OSG_VERSION_LESS_THAN(3,3,3) - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(geometry); -#endif - if (geometry->getDataVariance() == osg::Object::DYNAMIC) { // Add a copy, we will alternate between the two copies every other frame using the FrameSwitch @@ -1029,24 +1018,14 @@ namespace NifOsg geometry->setDataVariance(osg::Object::STATIC); osg::ref_ptr frameswitch = new FrameSwitch; -#if OSG_VERSION_LESS_THAN(3,3,3) - osg::ref_ptr geode2 = static_cast(osg::clone(geode.get(), osg::CopyOp::DEEP_COPY_NODES|osg::CopyOp::DEEP_COPY_DRAWABLES)); - frameswitch->addChild(geode); - frameswitch->addChild(geode2); -#else osg::ref_ptr geom2 = static_cast(osg::clone(geometry.get(), osg::CopyOp::DEEP_COPY_NODES|osg::CopyOp::DEEP_COPY_DRAWABLES)); frameswitch->addChild(geometry); frameswitch->addChild(geom2); -#endif parentNode->addChild(frameswitch); } else -#if OSG_VERSION_LESS_THAN(3,3,3) - parentNode->addChild(geode); -#else parentNode->addChild(geometry); -#endif } osg::ref_ptr handleMorphGeometry(const Nif::NiGeomMorpherController* morpher, const Nif::NiTriShape *triShape, osg::Node* parentNode, SceneUtil::CompositeStateSetUpdater* composite, const std::vector& boundTextures, int animflags) @@ -1151,21 +1130,10 @@ namespace NifOsg osg::ref_ptr frameswitch = new FrameSwitch; -#if OSG_VERSION_LESS_THAN(3,3,3) - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(rig); - - osg::Geode* geode2 = static_cast(osg::clone(geode.get(), osg::CopyOp::DEEP_COPY_NODES| - osg::CopyOp::DEEP_COPY_DRAWABLES)); - - frameswitch->addChild(geode); - frameswitch->addChild(geode2); -#else SceneUtil::RigGeometry* rig2 = static_cast(osg::clone(rig.get(), osg::CopyOp::DEEP_COPY_NODES| osg::CopyOp::DEEP_COPY_DRAWABLES)); frameswitch->addChild(rig); frameswitch->addChild(rig2); -#endif parentNode->addChild(frameswitch); } diff --git a/components/resource/imagemanager.cpp b/components/resource/imagemanager.cpp index 79da7d7abf..a4278eb0f8 100644 --- a/components/resource/imagemanager.cpp +++ b/components/resource/imagemanager.cpp @@ -62,17 +62,10 @@ namespace Resource case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): { -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) osg::GLExtensions* exts = osg::GLExtensions::Get(0, false); if (exts && !exts->isTextureCompressionS3TCSupported // This one works too. Should it be included in isTextureCompressionS3TCSupported()? Submitted as a patch to OSG. && !osg::isGLExtensionSupported(0, "GL_S3_s3tc")) -#else - osg::Texture::Extensions* exts = osg::Texture::getExtensions(0, false); - if (exts && !exts->isTextureCompressionS3TCSupported() - // This one works too. Should it be included in isTextureCompressionS3TCSupported()? Submitted as a patch to OSG. - && !osg::isGLExtensionSupported(0, "GL_S3_s3tc")) -#endif { std::cerr << "Error loading " << filename << ": no S3TC texture compression support installed" << std::endl; return false; diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 29f7076f0c..52db2decc9 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -52,23 +52,6 @@ namespace && partsys->getUserDataContainer()->getDescriptions()[0] == "worldspace"); } - void apply(osg::Geode& geode) - { - for (unsigned int i=0;i(geode.getDrawable(i))) - { - if (isWorldSpaceParticleSystem(partsys)) - { - // HACK: Ignore the InverseWorldMatrix transform the geode is attached to - if (geode.getNumParents() && geode.getParent(0)->getNumParents()) - transformInitialParticles(partsys, geode.getParent(0)->getParent(0)); - } - geode.setNodeMask(mMask); - } - } - } - #if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) // in OSG 3.3 and up Drawables can be directly in the scene graph without a Geode decorating them. void apply(osg::Drawable& drw) diff --git a/components/sceneutil/clone.cpp b/components/sceneutil/clone.cpp index 784195e7ef..26f3f5c7cd 100644 --- a/components/sceneutil/clone.cpp +++ b/components/sceneutil/clone.cpp @@ -81,11 +81,6 @@ namespace SceneUtil #endif osg::Drawable* cloned = osg::clone(drawable, copyop); -#if OSG_VERSION_LESS_THAN(3,3,3) - // work around OSG 3.2 not respecting the DEEP_COPY_CALLBACK flag - if (cloned->getUpdateCallback()) - cloned->setUpdateCallback(osg::clone(cloned->getUpdateCallback(), *this)); -#endif return cloned; } if (dynamic_cast(drawable)) diff --git a/components/sceneutil/controller.cpp b/components/sceneutil/controller.cpp index 7762b48d07..916d4f80bd 100644 --- a/components/sceneutil/controller.cpp +++ b/components/sceneutil/controller.cpp @@ -65,11 +65,7 @@ namespace SceneUtil void ControllerVisitor::apply(osg::Node &node) { -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) osg::Callback* callback = node.getUpdateCallback(); -#else - osg::NodeCallback* callback = node.getUpdateCallback(); -#endif while (callback) { if (Controller* ctrl = dynamic_cast(callback)) @@ -96,11 +92,7 @@ namespace SceneUtil { osg::Drawable* drw = geode.getDrawable(i); -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) osg::Callback* callback = drw->getUpdateCallback(); -#else - osg::Drawable::UpdateCallback* callback = drw->getUpdateCallback(); -#endif if (Controller* ctrl = dynamic_cast(callback)) visit(geode, *ctrl); diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index be8d97a4cb..da7d424311 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -289,11 +289,9 @@ void RigGeometry::updateBounds(osg::NodeVisitor *nv) _boundingBox = box; _boundingBoxComputed = true; -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) // in OSG 3.3.3 and up Drawable inherits from Node, so has a bounding sphere as well. _boundingSphere = osg::BoundingSphere(_boundingBox); _boundingSphereComputed = true; -#endif for (unsigned int i=0; idirtyBound(); } diff --git a/components/sdlutil/sdlgraphicswindow.cpp b/components/sdlutil/sdlgraphicswindow.cpp index a0483e84df..e5bad1f009 100644 --- a/components/sdlutil/sdlgraphicswindow.cpp +++ b/components/sdlutil/sdlgraphicswindow.cpp @@ -112,11 +112,7 @@ void GraphicsWindowSDL2::init() mValid = true; -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,4) getEventQueue()->syncWindowRectangleWithGraphicsContext(); -#else - getEventQueue()->syncWindowRectangleWithGraphcisContext(); -#endif } @@ -133,11 +129,7 @@ bool GraphicsWindowSDL2::realizeImplementation() SDL_ShowWindow(mWindow); -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,4) getEventQueue()->syncWindowRectangleWithGraphicsContext(); -#else - getEventQueue()->syncWindowRectangleWithGraphcisContext(); -#endif mRealized = true; diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index 4f0e464ce2..96584172a8 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -193,13 +193,7 @@ osg::ref_ptr TerrainGrid::buildTerrain (osg::Group* parent, float chu transform->addChild(effect); -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) osg::Node* toAttach = geometry.get(); -#else - osg::ref_ptr geode (new osg::Geode); - geode->addDrawable(geometry); - osg::Node* toAttach = geode.get(); -#endif effect->addChild(toAttach); From f94722b271c83ffbbe55a46eff19619f0083d87c Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 12 Feb 2016 14:55:00 +0100 Subject: [PATCH 2/3] OSG 3.3.4 is the first release to include the DDS crash fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df2ee6f49a..520279e504 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,7 +233,7 @@ if (USE_QT) set (OSG_QT osgQt) endif() -find_package(OpenSceneGraph 3.4.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle ${OSG_QT} osgUtil osgFX) +find_package(OpenSceneGraph 3.3.4 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle ${OSG_QT} osgUtil osgFX) include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}) From 5824619a95f5ad16dae84de41ab9a635bb16f56b Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 12 Feb 2016 19:28:10 +0100 Subject: [PATCH 3/3] Clean up includes --- apps/openmw/mwrender/animation.cpp | 1 - apps/openmw/mwrender/objects.cpp | 1 - apps/openmw/mwrender/sky.cpp | 1 - components/nifosg/nifloader.cpp | 1 - components/resource/imagemanager.cpp | 1 - components/resource/scenemanager.cpp | 3 --- components/sceneutil/controller.cpp | 1 - components/sceneutil/riggeometry.cpp | 1 - components/sdlutil/sdlgraphicswindow.cpp | 2 -- components/terrain/terraingrid.cpp | 1 - 10 files changed, 13 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index e3cc57bc42..abca3b2667 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index d249a7602e..a13ee03ac9 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 1757314fe2..f10beca6ca 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 61fbc9b966..8f40768845 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include // resource diff --git a/components/resource/imagemanager.cpp b/components/resource/imagemanager.cpp index a4278eb0f8..870fa370b1 100644 --- a/components/resource/imagemanager.cpp +++ b/components/resource/imagemanager.cpp @@ -2,7 +2,6 @@ #include #include -#include #include diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 52db2decc9..85a4afa301 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -52,7 +51,6 @@ namespace && partsys->getUserDataContainer()->getDescriptions()[0] == "worldspace"); } -#if OSG_VERSION_GREATER_OR_EQUAL(3,3,3) // in OSG 3.3 and up Drawables can be directly in the scene graph without a Geode decorating them. void apply(osg::Drawable& drw) { @@ -67,7 +65,6 @@ namespace partsys->setNodeMask(mMask); } } -#endif void transformInitialParticles(osgParticle::ParticleSystem* partsys, osg::Node* node) { diff --git a/components/sceneutil/controller.cpp b/components/sceneutil/controller.cpp index 916d4f80bd..0978999116 100644 --- a/components/sceneutil/controller.cpp +++ b/components/sceneutil/controller.cpp @@ -5,7 +5,6 @@ #include #include #include -#include namespace SceneUtil { diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index da7d424311..f915ee39c3 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include "skeleton.hpp" diff --git a/components/sdlutil/sdlgraphicswindow.cpp b/components/sdlutil/sdlgraphicswindow.cpp index e5bad1f009..66d53b0961 100644 --- a/components/sdlutil/sdlgraphicswindow.cpp +++ b/components/sdlutil/sdlgraphicswindow.cpp @@ -2,8 +2,6 @@ #include -#include - namespace SDLUtil { diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index 96584172a8..981a984e48 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include