HI Valary,

The update and event traversals both have use a mechanism that stops
traversal when no children of a node contain
any nodes that requiring traversing.   This feature is key to maintain
good performance on very large databases, without
it the update/event traversals would take dozens of milliseconds for
big databases and totally kill performance.

To enable traversal of only subgraphs that actually need it the scene
graph keeps an index of number of children requiring traversal - as
you've already spotted.  In the case of setting a update callback this
index will be automatically updated, along with all the parents in the
parent path - making sure that the node with the callback will be
called.  If you have a node that implements its own custom traverse
method then you'll need to set the index directly in the constructor.
For an example of this have a look at the implementation of the Switch
node - src/osg/Switch.cpp.

Robert.

On Mon, May 19, 2008 at 10:00 AM, Валерий Быков <[EMAIL PROTECTED]> wrote:
> Hi all.
>
> I have a question why Node::traverse(NodeVisitor&) doesn't called with
> NodeVisitor of type UPDATE_VISITOR?
> I have a class derived from Geode and I remoulded function
> traverse(NodeVisitor&) for some update operations:
>
> void MyClass::traverse(osg::NodeVisitor& nv)
> {
> if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
> {
> // Do smth
> }
> Geode::traverse(nv);
> }
>
> And I use osgViewer::Viewer for showing scene. But this function traverse is
> never called with updateVisitor, because in
> osgUtil::UpdateVisitor::apply(Geode&) only callbacks is proceeded, but not
> traverse.
>
> And what about deriving from other classes and using traverse for update
> operations then we can see that in osgUtil::UpdateVisitor::apply(Node&)
> calls function void handle_callbacks_and_traverse(osg::Node& node) which
> calls callback if presented and check
> node.getNumChildrenRequiringUpdateTraversal()>0 and calls traverse(node) in
> this case. But as I can see in osg/src/Node.cpp,
> _numChildrenRequiringUpdateTraversal changes in two cases: when update
> callback is attached and when void
> Node::setNumChildrenRequiringUpdateTraversal(unsigned int num) is called.
> But I want to not use update callback, so, I must call
> setNumChildrenRequiringUpdateTraversal for it. I would like to remould
> function addParent for it, but this function is not virtual, so, I really
> confused how to use traverse for update operations.
>
> Best regards,
> Valery
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to