Hi John,

Original Node callbacks didn't support multiple callbacks, but I
worked out that I could add the functionality relatively
non-intrusively by nesting callbacks. The key advantage with nesting
is that it enables a callback retain data on the stack within the
local scope of the callback - which makes things easy to implement and
gives you thread safety for free, and enables the callback to take
complete controlling traversal.

Providing similar support for Camera::DrawCallbacks would be possible,
there isn't the same imperative for controlling traversal, but it'd
keep the public Camera API simple - it's complicated enough as it is
so am reluctant to add further API to it.  The alternative would be to
add a list of callbacks, but as you said this would break
compatibility.

Robert.

On 9 April 2014 14:10, PCJohn <[email protected]> wrote:
> Hi,
>
> I very like the capability of osg::Node to register any number of update,
> event and cull callbacks. This allows for a nice modular approach with each
> module registering callbacks for anything they wish without disturbing others.
>
> I came to a problem that Camera can register just one Initial-,Pre-,Post-, and
> Final-DrawCallback. Surely, I can register my own "callback container" that
> would call all my registered callback. But that is not compatible with OSG-
> registered Callbacks, for instance OcclusionQueryNode would overwrite my
> callback container. Could we possibly make the similar approach for the camera
> as for osg::Node? I can volunteer to make the first iteration for osg-
> submissions, if the community and Robert thinks that it is a good idea.
>
>
> My idea for implementation would be to append
> ref_ptr<DrawCallback> _nestedCallback into the Camera::DrawCallback structure,
> append Camera::add*Callback() and Camera::remove*Callback()
> and make Camera::callCallbacks(DrawCallback *cb) with a parameter giving
> pointer to the first DrawCallback of Initial-,Pre-,Post-, and Final-
> DrawCallback list.
> An alternative would be to let the user call nested callbacks from
> DrawCallback::operator(), but as we would always want (probably) to call all
> the callbacks and never stop in the middle of the work, I personally like the
> first approach more and it is more compatibility-friendly, as users will not
> need to modify their existing callbacks to get the new multi-callback
> capability. But I am ok with any approach.
>
>
> Do you think it is a good idea?
> John
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to