[osg-users] DatabasePager - how to modify data during loading

Mike Connell michael.connell at gmail.com
Thu May 28 01:05:52 PDT 2015

Thanks Sebastian!

The ReadFileCallback is how I'm doing it now: we take an observer_ptr of
nodes loaded in the RFC, then in the main thread before rendering we can
see if the node is still valid and if is inserted in the scenegraph. If we
can find it, then we can perform the edit.

The problem is that since the node is already inserted, we either have to
block rendering whilst we do the edit (which can take hundreds of ms per
node), or edit in the background whilst rendering either the unedited node
(which looks wrong), or no node at all (looks just as wrong! :-)

There also a problem in that the pager compiles objects before insertion -
but this operation is a waste for objects which we will immediately edit.

The more I think about it the more sure I am that the DatabaseThread is the
right place to do it, but exactly how to best insert ourselves into the
process is harder to know!

best wishes


On Thu, 28 May 2015 at 09:22 Sebastian Messerschmidt <
sebastian.messerschmidt at gmx.de> wrote:

>  Hi Mike,
> you can add an
>  osgDB::Registry::ReadFileCallback
> and implement the readImage member function.
> For registering it to the registry use:
> osgDB::Registry::instance()->setReadFileCallback(myCloneReadFileCallback);
> This will be triggered by the database-pager when loading the image.
> It won't help you with the destination-problem however.
> Cheers
> Sebastian
>   Hi all!
>  I am finishing up some work which involves modifying nodes as they are
> loaded via the database pager - I want to edit the data after it is loaded,
> but before it is added to the scenegraph. I also need to know the
> destination (future parent) node in the scenegraph where the edited node
> will be located.
>  It looks to me like a suitable location for this work is pretty much in
> the middle of DatabaseThread::run - after the node is loaded via readNode
> (), but before it is added to the file cache. All the data I need appears
> to be held in the DatabaseRequest object.
>  Is there another (simpler?) way of inserting my code into the loading
> process?
>  If the middle of the run method is the best location, would a patch to
> allow a optional callback function to be called be considered?
>  best wishes
>  Mike
> _______________________________________________
> osg-users mailing listosg-users at lists.openscenegraph.orghttp://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150528/0847ebf0/attachment-0003.htm>

More information about the osg-users mailing list