Re: [osg-users] intersection and threading problem
Hello Markus, Yes, this does make sense. I am using the delta3d game engine as well so maybe what I'm asking is if there is any general way the check if osg is currently in a state where it is unsafe to act upon the scene? For instance, Is there any mutex that belongs to osg that I can wait on ? Not in OSG itself, but I don't know about Delta3D. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] intersection and threading problem
[quote="Skylark"]Hello Markus, > > You're in control of your application's main loop, so you can > synchronize things the way you want. You can set a mutex that will make > it safe to run intersections at given times, and then unlock the mutex > to let the viewer run its update and cull phases safely. Yes, this does make sense. I am using the delta3d game engine as well so maybe what I'm asking is if there is any general way the check if osg is currently in a state where it is unsafe to act upon the scene? For instance, Is there any mutex that belongs to osg that I can wait on ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30707#30707 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] intersection and threading problem
Hello Markus, Thanks for addressing this Skylark. Yes, the application crashes due to what I think you described (accessing the scene graph while it is being modified) I am using osgEarth and running threads concurrently that need to intersect with the surface of the earth model. Is there any thread-safe way to achieve this without running everything on the main thread? More generally, is there a way to ensure that you only traverse the scene graph's nodes when you're supposed to? You're in control of your application's main loop, so you can synchronize things the way you want. You can set a mutex that will make it safe to run intersections at given times, and then unlock the mutex to let the viewer run its update and cull phases safely. That's just an example. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] intersection and threading problem
Skylark wrote: > Hi Markus, > > > > I'm using osg 2.9.8 and trying to do intersection tests in a thread. The > > code is real straightforwards and works well when not threaded: > > > > [...] > > > > Is this a known issue? > > > > Err, you say what you want to do, that it works when not threaded, but > not what happens when you try to do it in a thread. Do you get crashes? > Do you get error messages? Do you get erroneous results? > > Without this info it's hard to help you out... > > I don't see why it wouldn't work /a priori/, unless your thread is > running while some other part of your app is modifying the scene graph. > That might invalidate iterators that the IntersectionVisitor is using or > things like that, which might lead to crashes. > > J-S > -- > __ > Jean-Sebastien Guay > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > ___ > osg-users mailing list > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- > Post generated by Mail2Forum Thanks for addressing this Skylark. Yes, the application crashes due to what I think you described (accessing the scene graph while it is being modified) I am using osgEarth and running threads concurrently that need to intersect with the surface of the earth model. Is there any thread-safe way to achieve this without running everything on the main thread? More generally, is there a way to ensure that you only traverse the scene graph's nodes when you're supposed to? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30698#30698 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] intersection and threading problem
Hi Markus, I'm using osg 2.9.8 and trying to do intersection tests in a thread. The code is real straightforwards and works well when not threaded: [...] Is this a known issue? Err, you say what you want to do, that it works when not threaded, but not what happens when you try to do it in a thread. Do you get crashes? Do you get error messages? Do you get erroneous results? Without this info it's hard to help you out... I don't see why it wouldn't work /a priori/, unless your thread is running while some other part of your app is modifying the scene graph. That might invalidate iterators that the IntersectionVisitor is using or things like that, which might lead to crashes. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] intersection and threading problem
Hey all, I'm using osg 2.9.8 and trying to do intersection tests in a thread. The code is real straightforwards and works well when not threaded: Code: osg::ref_ptr intersector = new osgUtil::LineSegmentIntersector(start, end); osgUtil::IntersectionVisitor visitor(intersector); visitor.setLODSelectionMode(osgUtil::IntersectionVisitor::LODSelectionMode::USE_HIGHEST_LEVEL_OF_DETAIL ); osgEarthNode->accept(visitor); if(intersector->containsIntersections()) { osgUtil::LineSegmentIntersector::Intersections::const_iterator firstHit = intersector->getIntersections().begin(); worldIntersectionPosition = firstHit->getWorldIntersectPoint(); worldIntersectionNormal = firstHit->getWorldIntersectNormal(); return true; } Is this a known issue? -Markus -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30183#30183 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org