Looks like my guess was wrong. It looks like the bounding sphere does take
into account the scale. I looked into the intersection test in
LineSegmentIntersector and found that the line segment is in fact intersecting
the sphere at two points but one of the final tests is failing.
Here is the intersects function in LineSegmentIntersector. I added line
numbers to ease my explanation.
Code:
1:bool LineSegmentIntersector::intersects(const osg::BoundingSphere& bs )
2:{
3: if ( !bs.valid() ) return true;
4: osg::Vec3d sm = _start - bs._center;
5: double c = sm.length2()-bs._radius*bs._radius;
6: if (c<0.0) return true;
7: osg::Vec3d se = _end-_start;
8: double a = se.length2();
9: double b = (sm*se)*2.0;
10: double d = b*b-4.0*a*c;
11: if (d<0.0) return false;
12: double div = 1.0/(2.0*a);
13: double r1 = (-b-d)*div;
14: double r2 = (-b+d)*div;
15: if (r1<=0.0 && r2<=0.0) return false;
16: if (r1>=1.0 && r2>=1.0) return false;
17: return true;
18:}
The last test ( line 16 ) is failing. From reading the web I understand that
if the test on line 11 fails then there is no intersection but if it passes
then the line segment intersects the sphere at two points. I don't understand
what the last two tests ( lines 15 and 16 ) are testing for. Could someone
explain it to me?
Thanks in advance for any help.
Cheers,
Greg
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=28832#28832
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org