[osg-users] Is this a too dirty hack?

Viggo Løvli vigigio at hotmail.com
Wed Jul 23 05:44:03 PDT 2008

Hi Robert,
Oh, I would probably be willing to go through fire to ensure that nobody can break the system :-)
I am a great fan of writing modules that is as independent of other modules as possible. This also means that I do not want to make future modules dependent on current modules either (unless they have to be). 
So if I can find a way for my module to automatically ensure that node-masks holds a perfect format throughout the node-tree, then I will be happy. Adding a pre-processing function will cause a few problems:
    - Future modules will have to set up their node-tree at module init so that my module can run the pre-processing on them once.
    - Future modules will have to call my module to pre-process any nodes it want to add later on.
    - Adding some 3rd party software will thus require interface coding as it won't be able to use OSG directly.
I want to make life less painful in the future by doing some painful things now :-)
Currently I am quite unable to find a good and easy way to automatically detect when nodes are added to the tree.
There is one call osg::Group::childInserted(). It does not do anything:
    virtual void childInserted( unsigned int /*pos*/) {}
That would have been a great place for me to add code to call all parents's childInserted, and thus end up with a call to that function on the root node. I could override it in the root node to do my formatting thing.
Adding code there is not something everyone wants, so it would have to be a modification I have to do to OSG every time we upgrade OSG. That would however be less painful than having to ensure future modules that we create or get from somewhere else stays true to our node mask regime. I am still willing to put in a few more hours to avoid having to do that.
> Date: Wed, 23 Jul 2008 13:02:08 +0100> From: robert.osfield at gmail.com> To: osg-users at lists.openscenegraph.org> Subject: Re: [osg-users] Is this a too dirty hack?> > Hi Viggo,> > Do you really have to go through all this hassle? Can't you just> catch changes to the scene graph as they are being made by your app?> The only part of the OSG which which would add nodes to the scene> graph is the DatabasePager, and you can catch all loads from this via> a Registry::ReadFileCallback.> > Robert.> > On Wed, Jul 23, 2008 at 11:35 AM, Viggo Løvli <vigigio at hotmail.com> wrote:> > Hi,> >> > I am on the quest to figure out when the node-tree is dirty.> >> > I have found a way... But I do not know if this way is a too dirty hack to> > actually use.> >> > I have a class that inherit osg::Group.> > I use this as the root of my scene-graph.> >> > Each time someone add a node to the world, then the dirtyBound function will> > be called for all parents. This function is not virtual so I can not> > override it in my specialization of the osg::Group class.> > I can however set up a callback that is called when we calculate the> > bounding sphere.> > This callback is only executed if someone call getBound when the> > bounding-sphere is set to dirty.> >> > So, if the callback to calculate a bounding sphere is called on my root-node> > then I know that the node tree has been changed.> > I can thus check if the node-tree is 'dirty' by calling getBound() on my own> > class. If that results in a callback then it was dirty.> >> > So the question is: Is this a too dirty hack to use, or is it okish?> >> > Regards,> > Viggo> >> >> >> >> > ________________________________> > Windows Live Hotmail på mobilen. Ha alltid e-posten din tilgjengelig.> > _______________________________________________> > osg-users mailing list> > osg-users at lists.openscenegraph.org> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org> >> >> _______________________________________________> osg-users mailing list> osg-users at lists.openscenegraph.org> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Windows Live Messenger - også på mobilen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/a55f0005/attachment-0003.htm>

More information about the osg-users mailing list