From c59b28ac3f91cbee41bcdcce61d80b037e72cc06 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 7 Mar 2005 14:16:15 +0000 Subject: [PATCH] Added support for event callbacks --- src/osgPlugins/osg/Drawable.cpp | 5 +++++ src/osgPlugins/osg/Node.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/osgPlugins/osg/Drawable.cpp b/src/osgPlugins/osg/Drawable.cpp index ad2b8eb5c..531788dac 100644 --- a/src/osgPlugins/osg/Drawable.cpp +++ b/src/osgPlugins/osg/Drawable.cpp @@ -130,6 +130,11 @@ bool Drawable_writeLocalData(const Object& obj, Output& fw) fw.writeObject(*drawable.getUpdateCallback()); } + if (drawable.getEventCallback()) + { + fw.writeObject(*drawable.getEventCallback()); + } + if (drawable.getCullCallback()) { fw.writeObject(*drawable.getCullCallback()); diff --git a/src/osgPlugins/osg/Node.cpp b/src/osgPlugins/osg/Node.cpp index ef15f16a9..3e2d020b0 100644 --- a/src/osgPlugins/osg/Node.cpp +++ b/src/osgPlugins/osg/Node.cpp @@ -110,6 +110,27 @@ bool Node_readLocalData(Object& obj, Input& fr) } + while (fr.matchSequence("EventCallback {")) + { + int entry = fr[0].getNoNestedBrackets(); + fr += 2; + + while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) + { + NodeCallback* nodecallback = dynamic_cast(fr.readObjectOfType(*s_nodecallback)); + if (nodecallback) { + if (node.getEventCallback() == NULL) { + node.setEventCallback(nodecallback); + } else { + node.getEventCallback()->addNestedCallback(nodecallback); + } + } + else ++fr; + } + iteratorAdvanced = true; + + } + while (fr.matchSequence("CullCallbacks {")) { int entry = fr[0].getNoNestedBrackets(); @@ -183,6 +204,15 @@ bool Node_writeLocalData(const Object& obj, Output& fw) fw.indent() << "}" << std::endl; } + if (node.getEventCallback()) + { + fw.indent() << "EventCallbacks {" << std::endl; + fw.moveIn(); + fw.writeObject(*node.getEventCallback()); + fw.moveOut(); + fw.indent() << "}" << std::endl; + } + if (node.getCullCallback()) { fw.indent() << "CullCallbacks {" << std::endl;