Added more osg::Object::as*() methods and usage of these through the code base to avoid use of dynamic_cast<> when using UpdateVisitor/CullVisitor/EventVIisitor etc.

This commit is contained in:
Robert Osfield
2016-01-20 15:13:19 +00:00
parent 2e7cfe7efa
commit 1219a6d3bf
38 changed files with 148 additions and 60 deletions

View File

@@ -31,6 +31,8 @@ class Node;
class NodeVisitor;
class StateAttribute;
class Uniform;
class Drawable;
class Camera;
class Callback;
class CallbackObject;
@@ -136,6 +138,14 @@ class OSG_EXPORT Object : public Referenced
* Equivalent to dynamic_cast<const Uniform*>(this).*/
virtual const Uniform* asUniform() 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 Drawable pointer if Object is a Drawable, otherwise return 0.
* Equivalent to dynamic_cast<Drawable*>(this).*/
virtual Drawable* asDrawable() { return 0; }