#include <osg/ShadeModel>
#include <osg/StateSet>
#include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
+#include <osg/Version>
#include <osgUtil/RenderBin>
#include <cassert>
//----------------------------------------------------------------------------
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);
}
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/StateAttribute>
+#include <osg/Version>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/foreach.hpp>
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;
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 );
&& 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();
}
#include <simgear/scene/util/parse_color.hxx>
#include <osg/Drawable>
+#include <osg/Version>
#include <vg/openvg.h>
#include <cassert>
/**
* 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();
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:
}
//----------------------------------------------------------------------------
- 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() )
#define SIMGEAR_EFFECT_GEODE_HXX 1
#include <osg/Geode>
+#include <osg/Version>
+
+#include <boost/iterator/iterator_adaptor.hpp>
#include "Effect.hxx"
{
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);
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;
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;
{ 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;
}
}
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)
#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;
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;
}
}
-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)
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;
#endif
#include "SGEnlargeBoundingBox.hxx"
+
#include <osg/Drawable>
+#include <osg/Version>
SGEnlargeBoundingBox::SGEnlargeBoundingBox(float offset) :
_offset(offset)
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),
#include "UpdateOnceCallback.hxx"
#include <osg/Node>
+#include <osg/NodeVisitor>
namespace simgear
{