Added asUpdate/Cull/EventVisitor and asCamera/asDrawable to osg::Object and usage of these within the code base to avoid dynamic_cast<> usage.

This commit is contained in:
Robert Osfield
2016-01-20 17:49:10 +00:00
parent 2e7cfe7efa
commit 8fc287c1b7
37 changed files with 118 additions and 63 deletions

View File

@@ -118,7 +118,7 @@ struct KeystoneUpdateCallback : public osg::DrawableUpdateCallback
/** do customized update code.*/
virtual void update(osg::NodeVisitor*, osg::Drawable* drawable)
{
update(dynamic_cast<osg::Geometry*>(drawable));
update(drawable->asGeometry());
}
void update(osg::Geometry* geometry)
@@ -418,8 +418,8 @@ osg::Vec2d KeystoneHandler::incrementScale(const osgGA::GUIEventAdapter& ea) con
bool KeystoneHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /*aa*/, osg::Object* obj, osg::NodeVisitor* /*nv*/)
{
osg::Camera* camera = dynamic_cast<osg::Camera*>(obj);
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
osg::Camera* camera = obj ? obj->asCamera() : 0;
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (!viewport) return false;