This commit is contained in:
Robert Osfield
2016-01-20 17:51:03 +00:00
8 changed files with 47 additions and 11 deletions

View File

@@ -102,7 +102,12 @@ class OSG_EXPORT Drawable : public Node
META_Node(osg, Drawable);
/** Convert 'this' into a Drawable pointer if Object is a Drawable, otherwise return 0.
* Equivalent to dynamic_cast<Drawable*>(this).*/
virtual Drawable* asDrawable() { return this; }
/** convert 'const this' into a const Drawable pointer if Object is a Drawable, otherwise return 0.
* Equivalent to dynamic_cast<const Drawable*>(this).*/
virtual const Drawable* asDrawable() const { return this; }
/** Compute the DataVariance based on an assessment of callback etc.*/

View File

@@ -103,6 +103,13 @@ class OSG_EXPORT Node : public Object
* Equivalent to dynamic_cast<const Node*>(this).*/
virtual const Node* asNode() const { return this; }
/** convert 'this' into a Drawable pointer if Node is a Drawable, otherwise return 0.
* Equivalent to dynamic_cast<Group*>(this).*/
virtual Drawable* asDrawable() { return 0; }
/** convert 'const this' into a const Drawable pointer if Node is a Drawable, otherwise return 0.
* Equivalent to dynamic_cast<const Group*>(this).*/
virtual const Drawable* asDrawable() const { return 0; }
/** convert 'this' into a Geometry pointer if Node is a Geometry, otherwise return 0.
* Equivalent to dynamic_cast<Group*>(this).*/
virtual Geometry* asGeometry() { return 0; }
@@ -126,13 +133,6 @@ class OSG_EXPORT Node : public Object
virtual const Transform* asTransform() const { return 0; }
/** Convert 'this' into a Camera pointer if Node is a Camera, otherwise return 0.
* Equivalent to dynamic_cast<Camera*>(this).*/
virtual Camera* asCamera() { return 0; }
/** convert 'const this' into a const Camera pointer if Node is a Camera, otherwise return 0.
* Equivalent to dynamic_cast<const Camera*>(this).*/
virtual const Camera* asCamera() const { return 0; }
/** Convert 'this' into a Switch pointer if Node is a Switch, otherwise return 0.
* Equivalent to dynamic_cast<Switch*>(this).*/

View File

@@ -46,6 +46,14 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
META_NodeVisitor(osgGA, EventVisitor)
/** Convert 'this' into a osgGA::EventVisitor pointer if Object is a osgGA::EventVisitor, otherwise return 0.
* Equivalent to dynamic_cast<osgGA::EventVisitor*>(this).*/
virtual osgGA::EventVisitor* asEventVisitor() { return this; }
/** convert 'const this' into a const osgGA::EventVisitor pointer if Object is a osgGA::EventVisitor, otherwise return 0.
* Equivalent to dynamic_cast<const osgGA::EventVisitor*>(this).*/
virtual const osgGA::EventVisitor* asEventVisitor() const { return this; }
void setActionAdapter(osgGA::GUIActionAdapter* actionAdapter) { _actionAdapter=actionAdapter; }
osgGA::GUIActionAdapter* getActionAdapter() { return _actionAdapter; }

View File

@@ -59,6 +59,14 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
META_NodeVisitor(osgUtil, CullVisitor)
/** Convert 'this' into a osgUtil::CullVisitor pointer if Object is a osgUtil::CullVisitor, otherwise return 0.
* Equivalent to dynamic_cast<osgUtil::CullVisitor*>(this).*/
virtual osgUtil::CullVisitor* asCullVisitor() { return this; }
/** convert 'const this' into a const osgUtil::CullVisitor pointer if Object is a osgUtil::CullVisitor, otherwise return 0.
* Equivalent to dynamic_cast<const osgUtil::CullVisitor*>(this).*/
virtual const osgUtil::CullVisitor* asCullVisitor() const { return this; }
/** Create a shallow copy of the CullVisitor, used by CullVisitor::create() to clone the prototype. */
virtual CullVisitor* clone() const { return new CullVisitor(*this); }

View File

@@ -56,7 +56,6 @@ class Intersector : public osg::Referenced
_disabledCount(0),
_precisionHint(USE_DOUBLE_CALCULATIONS) {}
void setCoordinateFrame(CoordinateFrame cf) { _coordinateFrame = cf; }
CoordinateFrame getCoordinateFrame() const { return _coordinateFrame; }
@@ -168,8 +167,16 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
META_NodeVisitor(osgUtil, IntersectionVisitor)
virtual void reset();
/** Convert 'this' into a osgUtil::IntersectionVisitor pointer if Object is a IntersectionVisitor, otherwise return 0.
* Equivalent to dynamic_cast<osgUtil::IntersectionVisitor*>(this).*/
virtual osgUtil::IntersectionVisitor* asIntersectionVisitor() { return this; }
/** convert 'const this' into a const osgUtil::IntersectionVisitor pointer if Object is a IntersectionVisitor, otherwise return 0.
* Equivalent to dynamic_cast<const osgUtil::IntersectionVisitor*>(this).*/
virtual const osgUtil::IntersectionVisitor* asIntersectionVisitor() const { return this; }
virtual void reset();
/** Set the intersector that will be used to intersect with the scene, and to store any hits that occur.*/
void setIntersector(Intersector* intersector);

View File

@@ -43,6 +43,14 @@ class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor
META_NodeVisitor(osgUtil, UpdateVisitor)
/** Convert 'this' into a osgUtil::UpdateVisitor pointer if Object is a osgUtil::UpdateVisitor, otherwise return 0.
* Equivalent to dynamic_cast<osgUtil::UpdateVisitor*>(this).*/
virtual osgUtil::UpdateVisitor* asUpdateVisitor() { return this; }
/** convert 'const this' into a const osgUtil::UpdateVisitor pointer if Object is a osgUtil::UpdateVisitor, otherwise return 0.
* Equivalent to dynamic_cast<const osgUtil::UpdateVisitor*>(this).*/
virtual const osgUtil::UpdateVisitor* asUpdateVisitor() const { return this; }
virtual void reset();
/** During traversal each type of node calls its callbacks and its children traversed. */

View File

@@ -38,7 +38,7 @@ class Logos: public osg::Drawable
virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable, osg::State*) const
{
Logos *logos = dynamic_cast <Logos *>(drawable);
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(visitor);
osgUtil::CullVisitor *cv = visitor->asCullVisitor();
if (!cv) return true;
unsigned int contextID = cv->getState()!=0 ? cv->getState()->getContextID() : 0;

View File

@@ -107,7 +107,7 @@ void TXPNode::traverse(osg::NodeVisitor& nv)
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
osgUtil::CullVisitor* cv = nv.asCullVisitor();
if (cv)
{
//#define PRINT_TILEMAPP_TIMEINFO