[osg-users] Threadsafe IntersectionVisitor and LineSegmentIntersector?

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Mon Aug 3 09:16:02 PDT 2015


Hi Matthias,
> Hi Sebastian,
>
> the sample code is called asynchronously from several compute threads.
> When I make sure that only one thread at a time calls accept() everything is rock solid (millions of calls).  But it's running slowly and doesn't scale well with the number of cores.
>
> Without the lock the calls to accept() are asynchronous too and I get wrong results every few hundred calls.
If the scenegraph isn't static I'd expect data races or even crashes if 
elements are added/removed.
You can traverse the graph after update/traversal safely.
Take a look at osg::Operation. You can use it to add threaded operations 
to the update phase and synchronize against the frame only instead of 
interlocking your intersection traversal.
I'm using it to populate the scene with instanced vegetation by querying 
the terrain height/color etc. and it is working fine.
I don't think the problem is asynchronously call accept on the visitor 
but calling it when draw/update of the scenegraph are running. You could 
grep the intersection code for non-reentrant code (use of static objects 
for instance) to be sure.

Cheers
Sebastian
>
> The compute threads themselves run independetly from the main thread with the viewer. In fact this even happens in batch mode too without any visual representation at all.
>
> Thank you!
>
> Cheers,
> Matthias
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64596#64596
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




More information about the osg-users mailing list