[osg-users] CompositeNodeCallback : useful addition?

Robert Osfield robert.osfield at gmail.com
Fri Oct 26 07:46:54 PDT 2007

Hi J-S,

All present NodeCallbacks are effectively traversal callbacks - all
require you to call traverse.

On thing I've considered in the past is to have a CompositeCallback
and a callback type within this that passes an custom callback
iterator that either calls the next callback in the chain or if none
are left do the traverse.

The alternative is to have a CompositeCallback that has pre/post callbacks.


On 10/26/07, Jean-Sébastien Guay <jean-sebastien.guay at polymtl.ca> wrote:
> Hello Robert,
> > You can nested callbacks within each other right now.  It's a bit
> > awkward but does work for doing multiple callbacks.
> Yes, as I said I find the current nested callback mechanism less
> intuitive. It would be better if it were transparent to users of the
> class, which is what I tried to do with CompositeNodeCallback's static
> methods.
> > The issued you have with your approach is that you call the callbacks
> > in series and don't provide a mechanism for traversal - rather it
> > assumes that each callback would call the traverse on subgraph or not
> > at all.  This might be OK for some callbacks types that fall into a
> > pre or post callback style, but not ones that are in effect traversal
> > callbacks.
> OK, I'm totally open to improving the design and implementation... I
> haven't used traversal callbacks so I didn't know that was a widely
> used case. What is it that should be happening? Would it be something
> like this?
> void CompositeNodeCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
> {
>      for (CallbackVector::iterator it = _callbacks.begin();
>           it != _callbacks.end();
>           ++it)
>      {
>          // Call (*it)->operator()(node, nv) on each callback.
>          (**it)(node, nv);
>          (*it)->traverse(node, nv);    // added
>      }
>      traverse(node, nv);    // added
> }
> Or is there more that is needed? As I see it, currently each class
> derived from NodeCallback is responsible for calling traverse() in its
> operator() anyways, if it needs to, so why do I need to call it in the
> composite? There must be something I don't understand.
> As I said, my goal was to hide the complexity of managing multiple
> callbacks on one node, so if some tweaks are required to the
> implementation I'm totally open to doing them.
> Thanks,
> J-S
> --
> ______________________________________________________
> Jean-Sebastien Guay     jean-sebastien.guay at polymtl.ca
>                          http://whitestar02.webhop.org/
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list