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

Robert Osfield robert.osfield at gmail.com
Thu May 28 01:43:10 PDT 2015


Hi Mike,

The ReadFileCallback is an ideal place to modify the loaded scene
graph as it's called from the database thread so won't impact the
rendering performance.  The only problem is that you are wanting to
know where the loaded subgraph will be attached to the scene graph.

The only info available about this in the ReadFileCallback is the
Terrain pointer that the DatabasePager passes into the read call via
the Options object.  This Terrain pointer isn't the exact position the
subgraph will be inserted, but for the purpose of osgTerrain it's
sufficient for finding neighbouring tiles etc. to help with the
tessellation process.

Providing the NodePath for the insertion point from the DatabasePager
to the Options object to read operation is something I looked at
previous, but this wasn't thread safe as the NodePath itself can
become invalidated by other threads - sometimes the DatabasePager has
to deal with the node it intends to add the new subgraph to have been
already deleted, so has to discard to the new subgraph.

One option open to you could be to subclass from DatabasePager and
override the updateSceneGraph(..) method.  Unfortunately this would be
an operation done in the main thread so you'd need to be careful about
the costs involved.

Robert.



More information about the osg-users mailing list