I made a little testfile with all the permutations of nodes/drawables and
updatecallbacks could come up with. The last two would never come up in old
code and maybe only by accident in new code.
It adds 7 update callbacks.
For me only 4 are called and the parent group says that only 3 children require
update traversal.
Hope this helps.
Cheers,
Pjotr
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59506#59506
#include <osgViewer/Viewer>
#include <osg/Group>
#include <osg/Drawable>
struct DrawableUpdateCallback : public osg::Drawable::UpdateCallback
{
DrawableUpdateCallback(const std::string &message): _message(message) {}
virtual void update(osg::NodeVisitor*, osg::Drawable* drw) {
printf("%s\n", _message.c_str());
}
std::string _message;
};
struct NodeUpdateCallback : public osg::NodeCallback
{
NodeUpdateCallback(const std::string &message): _message(message) {}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) {
printf("%s\n", _message.c_str());
}
std::string _message;
};
void main(){
osg::Group *root = new osg::Group();
osg::Node *test1 = new osg::Node();
test1->setUpdateCallback(new NodeUpdateCallback("test1"));
root->addChild(test1);
osg::Drawable *test2 = new osg::Drawable();
test2->osg::Node::setUpdateCallback(new NodeUpdateCallback("test2"));
root->addChild(test2);
osg::Drawable *test3 = new osg::Drawable();
test3->setUpdateCallback(new DrawableUpdateCallback("test3"));
root->addChild(test3);
osg::Geode *test4 = new osg::Geode();
osg::Drawable *drawable1 = new osg::Drawable();
drawable1->osg::Node::setUpdateCallback(new NodeUpdateCallback("test4"));
test4->addDrawable(drawable1);
root->addChild(test4);
osg::Geode *test5 = new osg::Geode();
osg::Drawable *drawable2 = new osg::Drawable();
drawable2->setUpdateCallback(new DrawableUpdateCallback("test5"));
test5->addDrawable(drawable2);
root->addChild(test5);
osg::Geode *test6 = new osg::Geode();
osg::Drawable *drawable3 = new osg::Drawable();
drawable3->setUpdateCallback(new DrawableUpdateCallback("test6"));
test6->addChild(drawable3);
root->addChild(test6);
osg::Geode *test7 = new osg::Geode();
osg::Drawable *drawable4 = new osg::Drawable();
drawable4->osg::Node::setUpdateCallback(new NodeUpdateCallback("test7"));
test7->addChild(drawable4);
root->addChild(test7);
printf("Numchildren with updates %u\n",
root->getNumChildrenRequiringUpdateTraversal());
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
viewer->setSceneData(root);
viewer->run();
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org