]> git.mxchange.org Git - simgear.git/commitdiff
Update for OpenSceneGraph 3.3.2 API changes.
authorThomas Geymayer <tomgey@gmail.com>
Sat, 9 Aug 2014 15:18:21 +0000 (17:18 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Sat, 9 Aug 2014 16:13:45 +0000 (18:13 +0200)
14 files changed:
simgear/canvas/ODGauge.cxx
simgear/canvas/elements/CanvasElement.cxx
simgear/canvas/elements/CanvasImage.cxx
simgear/canvas/elements/CanvasPath.cxx
simgear/canvas/elements/CanvasText.cxx
simgear/scene/material/EffectGeode.hxx
simgear/scene/material/Technique.cxx
simgear/scene/sky/CloudShaderGeometry.hxx
simgear/scene/tgdb/SGVasiDrawable.cxx
simgear/scene/tgdb/SGVasiDrawable.hxx
simgear/scene/tgdb/ShaderGeometry.cxx
simgear/scene/tgdb/ShaderGeometry.hxx
simgear/scene/util/SGEnlargeBoundingBox.cxx
simgear/scene/util/UpdateOnceCallback.cxx

index 5c547eafa1af784ddc0cfffb46f278bad1cae190..4a2b7facf54b83644e633430cf4abfd4c9001ce2 100644 (file)
@@ -44,6 +44,7 @@
 #include <osg/ShadeModel>
 #include <osg/StateSet>
 #include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
+#include <osg/Version>
 #include <osgUtil/RenderBin>
 
 #include <cassert>
@@ -266,7 +267,15 @@ namespace canvas
   //----------------------------------------------------------------------------
   void ODGauge::reinit()
   {
-    osg::NodeCallback* cull_callback = camera ? camera->getCullCallback() : 0;
+    osg::NodeCallback* cull_callback =
+      camera
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      ? camera->getCullCallback()
+#else
+      ? dynamic_cast<osg::NodeCallback*>(camera->getCullCallback())
+#endif
+      : 0;
+
     clear();
     allocRT(cull_callback);
   }
index 478cfb8b7f5ebcfbb77b671f71ef2d37856c1188..f89529259e2faf95a964c6c755515bc3250df6a1 100644 (file)
@@ -27,6 +27,7 @@
 #include <osg/Drawable>
 #include <osg/Geode>
 #include <osg/StateAttribute>
+#include <osg/Version>
 
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/foreach.hpp>
@@ -649,7 +650,11 @@ namespace canvas
   osg::BoundingBox Element::getBoundingBox() const
   {
     if( _drawable )
+#if OSG_VERSION_LESS_THAN(3,3,2)
       return _drawable->getBound();
+#else
+      return _drawable->getBoundingBox();
+#endif
 
     osg::BoundingBox bb;
 
@@ -672,7 +677,13 @@ namespace canvas
       return osg::BoundingBox();
 
     osg::BoundingBox transformed;
-    const osg::BoundingBox& bb = _drawable->getBound();
+    const osg::BoundingBox& bb =
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      _drawable->getBound();
+#else
+      _drawable->getBoundingBox();
+#endif
+
     for(int i = 0; i < 4; ++i)
       transformed.expandBy( bb.corner(i) * m );
 
index 4f4ffc7b14eccf7860985f729aac8ad52c05ff91..c89c71a40f8a30732d636d2237bd66db790b3800 100644 (file)
@@ -413,7 +413,14 @@ namespace canvas
         && child->getNameString() == "visible"
         && child->getBoolValue() )
     {
-      CullCallback* cb = static_cast<CullCallback*>(_geom->getCullCallback());
+      CullCallback* cb =
+#if OSG_VERSION_LESS_THAN(3,3,2)
+        static_cast<CullCallback*>
+#else
+        dynamic_cast<CullCallback*>
+#endif
+        ( _geom->getCullCallback() );
+
       if( cb )
         cb->cullNextFrame();
     }
index ba5351fe6f0ca4053698f254b42dfa0fe033f408..9eddcb31b588bb4040155e39475a2864dd37260c 100644 (file)
@@ -20,6 +20,7 @@
 #include <simgear/scene/util/parse_color.hxx>
 
 #include <osg/Drawable>
+#include <osg/Version>
 
 #include <vg/openvg.h>
 #include <cassert>
@@ -372,7 +373,13 @@ namespace canvas
       /**
        * Compute the bounding box
        */
-      virtual osg::BoundingBox computeBound() const
+      virtual osg::BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      computeBound()
+#else
+      computeBoundingBox()
+#endif
+      const
       {
         if( _path == VG_INVALID_HANDLE || (_attributes_dirty & PATH) )
           return osg::BoundingBox();
index ebe76d416870555743a7464bd5f6d3963319729e..239383ca2dba51181b690128b35d4119eba3c1cc 100644 (file)
@@ -45,7 +45,13 @@ namespace canvas
       SGVec2i sizeForWidth(int w) const;
       osg::Vec2 handleHit(const osg::Vec2f& pos);
 
-      virtual osg::BoundingBox computeBound() const;
+      virtual osg::BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      computeBound()
+#else
+      computeBoundingBox()
+#endif
+      const;
 
     protected:
 
@@ -467,9 +473,20 @@ namespace canvas
   }
 
   //----------------------------------------------------------------------------
-  osg::BoundingBox Text::TextOSG::computeBound() const
+  osg::BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+  Text::TextOSG::computeBound()
+#else
+  Text::TextOSG::computeBoundingBox()
+#endif
+  const
   {
-    osg::BoundingBox bb = osgText::Text::computeBound();
+    osg::BoundingBox bb =
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      osgText::Text::computeBound();
+#else
+      osgText::Text::computeBoundingBox();
+#endif
 
 #if OSG_VERSION_LESS_THAN(3,1,0)
     if( bb.valid() )
index 515b1a0ac57a8c565ff0a20e26f20e69dd90225a..34b87e3af0f36117a13d4554facd64d7c308a76e 100644 (file)
@@ -18,6 +18,9 @@
 #define SIMGEAR_EFFECT_GEODE_HXX 1
 
 #include <osg/Geode>
+#include <osg/Version>
+
+#include <boost/iterator/iterator_adaptor.hpp>
 
 #include "Effect.hxx"
 
@@ -25,7 +28,41 @@ namespace simgear
 {
 class EffectGeode : public osg::Geode
 {
-public:
+  public:
+
+#if OSG_VERSION_LESS_THAN(3,3,2)
+    typedef DrawableList::iterator DrawablesIterator;
+#else
+    class DrawablesIterator:
+      public boost::iterator_adaptor<
+        DrawablesIterator,
+        osg::NodeList::iterator,
+        osg::ref_ptr<osg::Drawable>,
+        boost::use_default,
+        osg::ref_ptr<osg::Drawable> // No reference as Reference type.
+                                    // The child list does not contain Drawable
+                                    // ref_ptr so we can not return any
+                                    // references to them.
+      >
+    {
+      public:
+
+        DrawablesIterator()
+        {}
+
+        explicit DrawablesIterator(osg::NodeList::iterator const& node_it):
+          DrawablesIterator::iterator_adaptor_(node_it)
+        {}
+
+      private:
+        friend class boost::iterator_core_access;
+        osg::ref_ptr<osg::Drawable> dereference() const
+        {
+          return base_reference()->get()->asDrawable();
+        }
+    };
+#endif
+
     EffectGeode();
     EffectGeode(const EffectGeode& rhs,
                 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
@@ -34,9 +71,15 @@ public:
     void setEffect(Effect* effect);
     virtual void resizeGLObjectBuffers(unsigned int maxSize);
     virtual void releaseGLObjects(osg::State* = 0) const;
-    typedef DrawableList::iterator DrawablesIterator;
+
+#if OSG_VERSION_LESS_THAN(3,3,2)
     DrawablesIterator drawablesBegin() { return _drawables.begin(); }
     DrawablesIterator drawablesEnd() { return _drawables.end(); }
+#else
+    DrawablesIterator drawablesBegin() { return DrawablesIterator(_children.begin()); }
+    DrawablesIterator drawablesEnd() { return DrawablesIterator(_children.end()); }
+#endif
+
     void runGenerators(osg::Geometry *geometry);
 private:
     osg::ref_ptr<Effect> _effect;
index d5d9b06960265c16e85b3de8596bac7e895e027b..93a17b87fc9be3d57675a000ae6c18e7b39f8f19 100644 (file)
@@ -140,27 +140,40 @@ Technique::processDrawables(const EffectGeode::DrawablesIterator& begin,
     EffectGeode::DrawablesIterator itr = begin;
     bool computeNearFar
         = cv->getComputeNearFarMode() != CullVisitor::DO_NOT_COMPUTE_NEAR_FAR;
-    for (int i = 0; i < NUM_DRAWABLES && itr != end; ++itr, ++i) {
-        Drawable* drawable = itr->get();
-        const BoundingBox& bb = drawable->getBound();
-        if ((drawable->getCullCallback()
-             && drawable->getCullCallback()->cull(cv, drawable,
-                                                  &cv->getRenderInfo()))
-            || (isCullingActive && cv->isCulled(bb))) {
-            depth[i] = FLT_MAX;
-            continue;
-        }
-        if (computeNearFar && bb.valid()) {
-            if (!cv->updateCalculatedNearFar(matrix, *drawable, false)) {
-                depth[i] = FLT_MAX;
-                continue;
-            }
+    for (int i = 0; i < NUM_DRAWABLES && itr != end; ++itr, ++i)
+    {
+      Drawable* drawable = itr->get();
+
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      const BoundingBox& bb = drawable->getBound();
+      osg::Drawable::CullCallback* cull = drawable->getCullCallback();
+#else
+      const BoundingBox& bb = drawable->getBoundingBox();
+      osg::Drawable::CullCallback* cull =
+        dynamic_cast<osg::Drawable::CullCallback*>(drawable->getCullCallback());
+#endif
+
+      if(   (cull && cull->cull(cv, drawable, &cv->getRenderInfo()))
+         || (isCullingActive && cv->isCulled(bb)) )
+      {
+        depth[i] = FLT_MAX;
+        continue;
+      }
+
+      if( computeNearFar && bb.valid() )
+      {
+        if( !cv->updateCalculatedNearFar(matrix, *drawable, false) )
+        {
+          depth[i] = FLT_MAX;
+          continue;
         }
-        depth[i] = (bb.valid()
-                    ? cv->getDistanceFromEyePoint(bb.center(), false)
-                    : 0.0f);
-        if (isNaN(depth[i]))
-            depth[i] = FLT_MAX;
+      }
+
+      depth[i] = bb.valid()
+               ? cv->getDistanceFromEyePoint(bb.center(), false)
+               : 0.0f;
+      if( isNaN(depth[i]) )
+        depth[i] = FLT_MAX;
     }
     EffectCullVisitor* ecv = dynamic_cast<EffectCullVisitor*>( cv );
     EffectGeode::DrawablesIterator drawablesEnd = itr;
index 20d0db8172d4d68be3fb43042b495757d63eb5b6..6d78af2fef74a6ca35081ac2faeaac4a4df6fc57 100644 (file)
@@ -95,7 +95,13 @@ class CloudShaderGeometry : public osg::Drawable
         { return _cloudsprites[i]; }
         
         virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
-        virtual osg::BoundingBox computeBound() const
+        virtual osg::BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+        computeBound()
+#else
+        computeBoundingBox()
+#endif
+        const
         {
             return _bbox;
         }
index bb3ce0e49795a46f0cee85265865c49afe06236a..d66474fea401be23b9ef84e5542a4b2417569d26 100644 (file)
@@ -104,7 +104,12 @@ SGVasiDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
 }
 
 osg::BoundingBox
-SGVasiDrawable::computeBound() const
+#if OSG_VERSION_LESS_THAN(3,3,2)
+SGVasiDrawable::computeBound()
+#else
+SGVasiDrawable::computeBoundingBox()
+#endif
+const
 {
   osg::BoundingBox bb;
   for (unsigned i = 0; i < _lights.size(); ++i)
index 242e39351c8ef72e9e0633aa72ed67a0d981cc17..e4b0479a8be3f08679d3fb2b5e108c01b9c86602 100644 (file)
 #define _SG_VASI_DRAWABLE_HXX
 
 #include <simgear/compiler.h>
+#include <simgear/math/SGMath.hxx>
 
 #include <osg/Drawable>
-#include <simgear/math/SGMath.hxx>
+#include <osg/Version>
 
 class SGVasiDrawable : public osg::Drawable {
   struct LightData;
@@ -49,7 +50,13 @@ public:
                 const SGVec3f& up);
 
   virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
-  virtual osg::BoundingBox computeBound() const;
+  virtual osg::BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+  computeBound()
+#else
+  computeBoundingBox()
+#endif
+  const;
 
 private:
   SGVec4f getColor(float angleDeg) const;
index 36a3093471cb628e5e603c29ef4cec8861ba397f..5d286c317d50028fe16529d02b3055bcb120c6f8 100644 (file)
@@ -60,9 +60,21 @@ void ShaderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
     }
 }
 
-BoundingBox ShaderGeometry::computeBound() const
+BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+ShaderGeometry::computeBound()
+#else
+ShaderGeometry::computeBoundingBox()
+#endif
+const
 {
-    const BoundingBox& geom_box = _geometry->getBound();
+    const BoundingBox& geom_box =
+#if OSG_VERSION_LESS_THAN(3,3,2)
+      _geometry->getBound();
+#else
+      _geometry->getBoundingBox();
+#endif
+
     BoundingBox bb;
     const Vec4Array* posScales = _posScaleArray.get();
     if (!posScales)
index 30c72fbe0d3092a5f64d278f6d2ab054fcfb5ada..a5de095f566bca126e4cbbf5c2e0cb07055a7757 100644 (file)
@@ -58,8 +58,15 @@ class ShaderGeometry : public osg::Drawable
         META_Object(flightgear, ShaderGeometry);
 
         virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
-        virtual osg::BoundingBox computeBound() const;
         
+        virtual osg::BoundingBox
+#if OSG_VERSION_LESS_THAN(3,3,2)
+        computeBound()
+#else
+        computeBoundingBox()
+#endif
+        const;
+
         void setGeometry(osg::Geometry* geometry)
         {
             _geometry = geometry;
index 8e5d8f3d9e5d53b459014b6121a353fbf771705f..5ff198554a2275a4524aa12850b3ed47ebcf77a0 100644 (file)
@@ -24,7 +24,9 @@
 #endif
 
 #include "SGEnlargeBoundingBox.hxx"
+
 #include <osg/Drawable>
+#include <osg/Version>
 
 SGEnlargeBoundingBox::SGEnlargeBoundingBox(float offset) :
   _offset(offset)
@@ -41,7 +43,13 @@ SGEnlargeBoundingBox::SGEnlargeBoundingBox(const SGEnlargeBoundingBox& cb,
 osg::BoundingBox
 SGEnlargeBoundingBox::computeBound(const osg::Drawable& drawable) const
 {
-  osg::BoundingBox bound = drawable.computeBound();
+  osg::BoundingBox bound =
+#if OSG_VERSION_LESS_THAN(3,3,2)
+    drawable.computeBound();
+#else
+    drawable.computeBoundingBox();
+#endif
+
   if (!bound.valid())
     return bound;
   return osg::BoundingBox(bound._min - osg::Vec3(_offset, _offset, _offset),
index 2615df4a9253a352702059f46eefd0b87b57a124..99d0192b0f5d3e2ab056d13a58e3281a50dfdb32 100644 (file)
@@ -20,6 +20,7 @@
 #include "UpdateOnceCallback.hxx"
 
 #include <osg/Node>
+#include <osg/NodeVisitor>
 
 namespace simgear
 {