OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

osgUtil::RayIntersector(osgUtil::Intersector::WINDOW, x, y) gives wrong sequence of intersections

Open marcobeninca71 opened this issue 5 years ago • 0 comments

Hello evrybody I found a strage behavior of osgUtil::RayIntersector(osgUtil::Intersector::WINDOW, x, y) with some models using shared geometries among geodes. This method seems to return a wrong sequence of intersections, or better the sequence is not ordered in the rigth way. To reproduce the issue follow the steps:

  • unzip the attached zip archive: inside you can find osgviewer.cpp, 8.osg, orientation.png
  • use the file osgviewer.cpp as the source file for the application osgviewer (it's distributed together with the OSG package). I modified it to have a custom manipulator which performs the ray intersection on the click on the window
  • compile and run the modified osgviewer with filename parameter 8.osg
  • orient the model as showed in the picture orientation.png
  • place a breakpoint at line 52 of osgviewer.cpp
  • click exactly in the center of the red shpere
  • now you can see that the intersetcions returned by osgUtil::RayIntersector(osgUtil::Intersector::WINDOW, x, y) are 4 and they should be ordered by distance; but looking inside the sequence the first is on the small sphere, the second on the big sphere, then on the small shpere again and the last on the big sphere
  • then from line 73 of osgviewer .cpp I perform a ray intersection using real world coordinates (note that the spheres are alinged along the X axis with the small one in the negative part of the X half plane) and in this case the sequence is correct with 4 intersections small, small, big, big

This behavior is very strange and in my applications leads sometimes to wrong selection of the nodes.

Thanks in advance Marco osgBug.zip

marcobeninca71 avatar Jan 21 '21 13:01 marcobeninca71