[osg-users] Threadsafe IntersectionVisitor and LineSegmentIntersector?

Matthias Sattler osgforum at tevs.eu
Mon Aug 3 07:54:38 PDT 2015


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








More information about the osg-users mailing list