[osg-users] osg::LineSegment intersect with Box and Sphere inconsistency

Robert Osfield robert.osfield at gmail.com
Mon Apr 27 09:06:15 PDT 2015

Hi Wojtek,

On 27 April 2015 at 13:16, Wojciech Lewandowski
<w.p.lewandowski at gmail.com> wrote:
> I am one of those users now ;-). However, I adopt easily. Others may not
> notice the change, though. Perhaps better solution would be to leave the
> functionality as is and clearly rename and/or comment the r1,r2 params to
> (rFromStart rFromEnd ?) so that inconsistency is clear and does not surprise
> future users ?

My current feeling is that the intersect methods should be consistent,
the sphere one uses ratio between start and end for both the first and
second intersections points, while the bounding box version provides
the ratio between start and end, and end and start respectively.
Other intersect code in the OSG uses the same convention as the sphere

I have fixed the LineSegment::intersect(const BoundingBox& bb,float&
r1,float& r2) const and double variant so they are now consistent with
other parts of the OSG.  I'm undecided what to do about breaking user
code that relies upon the old behaviour.  One option would be to have
CMake option to toggle the behaviour, another would be to rename the
problem method to force a build break so users have to investigate and
have a better chance of spotting the change in behaviour.

A Cmake option would just add complexity to the build system and
source code for something that might not affect any end users.


More information about the osg-users mailing list