diff --git a/include/osg/ScriptEngine b/include/osg/ScriptEngine index 85e5b97f5..3fa81a954 100644 --- a/include/osg/ScriptEngine +++ b/include/osg/ScriptEngine @@ -84,6 +84,27 @@ inline CallbackObject* getCallbackObject(osg::Object* object, const std::string& return udc ? dynamic_cast(udc->getUserObject(name)) : 0; } +/** Call run(..) on named CallbackObjects attached to specified Object. Return true if at least one CallbackObject has been successfully invoked.*/ +inline bool runNamedCallbackObjects(osg::Object* object, const std::string& name, osg::Parameters& inputParameters, osg::Parameters& outputParameters) +{ + bool result = false; + osg::UserDataContainer* udc = object->getUserDataContainer(); + if (udc) + { + for(unsigned int i = 0; igetNumUserObjects(); ++i) + { + osg::Object* obj = udc->getUserObject(i); + if (obj && obj->getName()==name) + { + osg::CallbackObject* co = dynamic_cast(obj); + if (co) result = co->run(object, inputParameters, outputParameters) | result; + } + } + } + + return result; +} + /** NodeCallback for attaching a script to a NodeCallback so that it can be called as an update or event callback.*/ class OSG_EXPORT ScriptNodeCallback : public osg::NodeCallback {