[osg-users] DataBasePager expired removal question

2 views
Skip to first unread message

Sebastian Messerschmidt

unread,
Mar 5, 2012, 4:01:30 AM3/5/12
to OpenSceneGraph Users
Hello,

I have a fairly big database which needs to be handled via PagedLOD.
This works fine up to a certain point.
In my project I've installed a load callback in order to clone certain
nodes and do my own caching.
Now, in order to cache the nodes correctly I've put a reference to the
node in to a map (std::map<std::string, osg::ref_ptr<Node>>). I need to
use the ref_ptr to be sure the node is still valid.
It works well, up to the point where the DataBasePager removes expired
PagedLODs, as I don't found any way to set a callback to the
DataBasePager that tells me, which node is going to be removed.

Is there any way to get this information (preferably via a callback)? Or
do I have to set an observer to the node and don't manage the nodes as
ref_ptr at this point?

cheers
Sebastian


_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Mar 5, 2012, 4:29:11 AM3/5/12
to OpenSceneGraph Users
HI Sebaastian,

I you want to keep track of internals of DatabasePager it is probably
best to simply subclass from DatabasePager.

Robert.

On 5 March 2012 09:01, Sebastian Messerschmidt

Sebastian Messerschmidt

unread,
Mar 5, 2012, 6:29:59 AM3/5/12
to OpenSceneGraph Users
Thanks Robert,

I was expecting this answer ;-)

cheers
Sebastian

Ulrich Hertlein

unread,
Mar 5, 2012, 7:31:39 PM3/5/12
to OpenSceneGraph Users
Hi Sebastian,

On 5/03/12 20:01 , Sebastian Messerschmidt wrote:
> Now, in order to cache the nodes correctly I've put a reference to the node in to a map
> (std::map<std::string, osg::ref_ptr<Node>>). I need to use the ref_ptr to be sure the node
> is still valid.
> It works well, up to the point where the DataBasePager removes expired PagedLODs, as I
> don't found any way to set a callback to the DataBasePager that tells me, which node is
> going to be removed.

If you only need to detect that nodes have been expired by the DatabasePager (and not
necessarily the exact moment) you could use an observer_ptr in your map rather than a ref_ptr.

But you would need to 'lock()' every access and run a map cleanup periodically to remove
stale nodes. Still, depending on your needs it might be cleaner than to subclass DBP.

Cheers,
/ulrich

Ulrich Hertlein

unread,
Mar 5, 2012, 9:13:15 PM3/5/12
to OpenSceneGraph Users
I need a coffee, you've already figured that out. Sorry for the noise :-}

Sebastian Messerschmidt

unread,
Mar 6, 2012, 5:44:59 AM3/6/12
to OpenSceneGraph Users
Hi Ulrich,

Don't worry, thanks for the advice anyways.

Reply all
Reply to author
Forward
0 new messages