[osg-users] Threadsafe IntersectionVisitor and LineSegmentIntersector?

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Mon Aug 3 08:03:27 PDT 2015


Hello Matthias,

What do you mean by threadsafe in this context?
By locking the mutex you achive nothing but subtle changes in timings, 
if you don't lock it somewhere else.
Are you maybe refering to multiple threaded intersectors?

Indeed the intersection should be safe if done after the viewers event 
traversal. At least this is working fine for me.

Cheers
Sebastian
> Hi folks,
>
> should the IntersectionVisitor and LineSegmentIntersector be threadsafe?
>
> With the multithreaded pseudocode below everything works fine with the ScopedLock. If I disable the ScopedLock I get wrong results.
>
> Thank you!
>
> Cheers,
> Matthias
>
>
> Code:
>
> osg::Vec3d dummy;
> osg::ref_ptr<osgUtil::LineSegmentIntersector> lineSegmentIntersector = new osgUtil::LineSegmentIntersector(dummy, dummy);
> osg::ref_ptr<osgUtil::IntersectionVisitor> visitor = new osgUtil::IntersectionVisitor(lineSegmentIntersector);
>
> ...
> osg::Vec3d P1, P2;
>
> lineSegmentIntersector->setStart(P1);
> lineSegmentIntersector->setEnd(P2);
>
> ...
> osg::Node* searchroot;
> OpenThreads::Mutex mutex;
>
> ...
> {
> OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex); // Works when enabled. Doesn't work when disabled!
> lineSegmentIntersector->reset();
> searchroot->accept(*visitor);
> }
>
> if (lineSegmentIntersector->containsIntersections())
> {
> ...
>
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64590#64590
>
>
>
>
>
> _______________________________________________
> 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