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:
@@ -18,7 +18,7 @@ using namespace osgGA;
|
||||
|
||||
void EventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
osgGA::EventVisitor* ev = nv->asEventVisitor();
|
||||
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
|
||||
{
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
@@ -33,7 +33,7 @@ void EventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
|
||||
void EventHandler::event(osg::NodeVisitor* nv, osg::Drawable* drawable)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
osgGA::EventVisitor* ev = nv->asEventVisitor();
|
||||
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
|
||||
{
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
|
||||
@@ -26,7 +26,7 @@ GUIEventHandler::~GUIEventHandler()
|
||||
// adapt EventHandler usage to old style GUIEventHandler usage
|
||||
bool GUIEventHandler::handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
osgGA::EventVisitor* ev = nv->asEventVisitor();
|
||||
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
|
||||
if (ea && ev && ev->getActionAdapter())
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ void Widget::setExtents(const osg::BoundingBoxf& bb)
|
||||
|
||||
void Widget::updateFocus(osg::NodeVisitor& nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
osgGA::GUIActionAdapter* aa = ev ? ev->getActionAdapter() : 0;
|
||||
if (ev && aa)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
if (!_graphicsInitialized && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR) createGraphics();
|
||||
|
||||
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
if (ev)
|
||||
{
|
||||
updateFocus(nv);
|
||||
|
||||
Reference in New Issue
Block a user