Renamed LineSegment::intersect(BoundingSphere/Box, double/float&, double/float&) methods to LineSegment::intersectAndComputeRations(..) to avoid confusion with the change in convention for
the old intersect(BoundingBox&, float/double&, float/double&) method as it was inconsitent with the rest of the OSG including the intersect(BoundingSphere) method in how the ratio for the second intersection was measure from - original from the end point, but now made consistent with other places in the OSG so be based on ration from start to end of segment. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14859 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
5be2e05b18
commit
e52b95e084
@ -44,45 +44,48 @@ class OSG_EXPORT LineSegment : public Referenced
|
|||||||
|
|
||||||
inline bool valid() const { return _s.valid() && _e.valid() && _s!=_e; }
|
inline bool valid() const { return _s.valid() && _e.valid() && _s!=_e; }
|
||||||
|
|
||||||
|
|
||||||
/** return true if segment intersects BoundingBox. */
|
/** return true if segment intersects BoundingBox. */
|
||||||
bool intersect(const BoundingBox& bb) const;
|
bool intersect(const BoundingBox& bb) const;
|
||||||
|
|
||||||
/** return true if segment intersects BoundingBox
|
/** return true if segment intersects BoundingBox and
|
||||||
* and return the intersection ratios.
|
* set float ratios for the first and second intersections, where the ratio is 0.0 at the segment start point, and 1.0 at the segment end point.
|
||||||
*/
|
*/
|
||||||
bool intersect(const BoundingBox& bb,float& r1,float& r2) const;
|
bool intersectAndComputeRatios(const BoundingBox& bb, float& ratioFromStartToEnd1, float& ratioFromStartToEnd2) const;
|
||||||
|
|
||||||
/** return true if segment intersects BoundingBox
|
/** return true if segment intersects BoundingBox and
|
||||||
* and return the intersection ratios.
|
* set double ratios for the first and second intersections, where the ratio is 0.0 at the segment start point, and 1.0 at the segment end point.
|
||||||
*/
|
*/
|
||||||
bool intersect(const BoundingBox& bb,double& r1,double& r2) const;
|
bool intersectAndComputeRatios(const BoundingBox& bb, double& ratioFromStartToEnd1, double& ratioFromStartToEnd2) const;
|
||||||
|
|
||||||
|
|
||||||
/** return true if segment intersects BoundingSphere. */
|
/** return true if segment intersects BoundingSphere. */
|
||||||
bool intersect(const BoundingSphere& bs) const;
|
bool intersect(const BoundingSphere& bs) const;
|
||||||
|
|
||||||
/** return true if segment intersects BoundingSphere and return the
|
/** return true if segment intersects BoundingSphere and
|
||||||
* intersection ratio.
|
* set float ratios for the first and second intersections, where the ratio is 0.0 at the segment start point, and 1.0 at the segment end point.
|
||||||
*/
|
*/
|
||||||
bool intersect(const BoundingSphere& bs,float& r1,float& r2) const;
|
bool intersectAndComputeRatios(const BoundingSphere& bs, float& ratioFromStartToEnd1, float& ratioFromStartToEnd2) const;
|
||||||
|
|
||||||
/** return true if segment intersects BoundingSphere and return the
|
/** return true if segment intersects BoundingSphere and
|
||||||
* intersection ratio.
|
* set double ratios for the first and second intersections, where the ratio is 0.0 at the segment start point, and 1.0 at the segment end point.
|
||||||
*/
|
*/
|
||||||
bool intersect(const BoundingSphere& bs,double& r1,double& r2) const;
|
bool intersectAndComputeRatios(const BoundingSphere& bs,double& ratioFromStartToEnd1, double& ratioFromStartToEnd2) const;
|
||||||
|
|
||||||
/** return true if segment intersects triangle
|
/** return true if segment intersects triangle and
|
||||||
* and set ratio long segment.
|
* set float ratios where the ratio is 0.0 at the segment start point, and 1.0 at the segment end point.
|
||||||
*/
|
*/
|
||||||
bool intersect(const Vec3f& v1,const Vec3f& v2,const Vec3f& v3,float& r);
|
bool intersect(const Vec3f& v1,const Vec3f& v2,const Vec3f& v3,float& ratioFromStartToEnd);
|
||||||
|
|
||||||
/** return true if segment intersects triangle
|
/** return true if segment intersects triangle and
|
||||||
* and set ratio long segment.
|
* set double ratios where the ratio is 0.0 at the segment start point, and 1.0 at the segment end point.
|
||||||
*/
|
*/
|
||||||
bool intersect(const Vec3d& v1,const Vec3d& v2,const Vec3d& v3,double& r);
|
bool intersect(const Vec3d& v1,const Vec3d& v2,const Vec3d& v3,double& ratioFromStartToEnd);
|
||||||
|
|
||||||
|
|
||||||
/** post multiply a segment by matrix.*/
|
/** post multiply a segment by matrix.*/
|
||||||
inline void mult(const LineSegment& seg,const Matrix& m) { _s = seg._s*m; _e = seg._e*m; }
|
inline void mult(const LineSegment& seg,const Matrix& m) { _s = seg._s*m; _e = seg._e*m; }
|
||||||
|
|
||||||
/** pre multiply a segment by matrix.*/
|
/** pre multiply a segment by matrix.*/
|
||||||
inline void mult(const Matrix& m,const LineSegment& seg) { _s = m*seg._s; _e = m*seg._e; }
|
inline void mult(const Matrix& m,const LineSegment& seg) { _s = m*seg._s; _e = m*seg._e; }
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
* OpenSceneGraph Public License for more details.
|
* OpenSceneGraph Public License for more details.
|
||||||
*/
|
*/
|
||||||
#include <osg/LineSegment>
|
#include <osg/LineSegment>
|
||||||
|
#include <osg/Notify>
|
||||||
|
#include <osg/io_utils>
|
||||||
|
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
@ -137,7 +139,6 @@ bool LineSegment::intersectAndClip(vec_type& s,vec_type& e,const BoundingBox& bb
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LineSegment::intersect(const BoundingBox& bb) const
|
bool LineSegment::intersect(const BoundingBox& bb) const
|
||||||
{
|
{
|
||||||
if (!bb.valid()) return false;
|
if (!bb.valid()) return false;
|
||||||
@ -147,7 +148,7 @@ bool LineSegment::intersect(const BoundingBox& bb) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LineSegment::intersect(const BoundingBox& bb,float& r1,float& r2) const
|
bool LineSegment::intersectAndComputeRatios(const BoundingBox& bb,float& r1,float& r2) const
|
||||||
{
|
{
|
||||||
if (!bb.valid()) return false;
|
if (!bb.valid()) return false;
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ bool LineSegment::intersect(const BoundingBox& bb,float& r1,float& r2) const
|
|||||||
{
|
{
|
||||||
value_type inv_len = 1.0f/len;
|
value_type inv_len = 1.0f/len;
|
||||||
r1 = (float)((s-_s).length()*inv_len);
|
r1 = (float)((s-_s).length()*inv_len);
|
||||||
r2 = (float)((e-_e).length()*inv_len);
|
r2 = (float)((e-_s).length()*inv_len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -171,7 +172,7 @@ bool LineSegment::intersect(const BoundingBox& bb,float& r1,float& r2) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LineSegment::intersect(const BoundingBox& bb,double& r1,double& r2) const
|
bool LineSegment::intersectAndComputeRatios(const BoundingBox& bb,double& r1,double& r2) const
|
||||||
{
|
{
|
||||||
if (!bb.valid()) return false;
|
if (!bb.valid()) return false;
|
||||||
|
|
||||||
@ -184,7 +185,10 @@ bool LineSegment::intersect(const BoundingBox& bb,double& r1,double& r2) const
|
|||||||
{
|
{
|
||||||
double inv_len = 1.0/len;
|
double inv_len = 1.0/len;
|
||||||
r1 = ((s-_s).length()*inv_len);
|
r1 = ((s-_s).length()*inv_len);
|
||||||
r2 = ((e-_e).length()*inv_len);
|
r2 = ((e-_s).length()*inv_len);
|
||||||
|
|
||||||
|
OSG_NOTICE<<"s = ("<<s<<"), e = ("<<e<<")"<<std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -196,7 +200,7 @@ bool LineSegment::intersect(const BoundingBox& bb,double& r1,double& r2) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LineSegment::intersect(const BoundingSphere& bs,float& r1,float& r2) const
|
bool LineSegment::intersectAndComputeRatios(const BoundingSphere& bs,float& r1,float& r2) const
|
||||||
{
|
{
|
||||||
vec_type sm = _s-bs._center;
|
vec_type sm = _s-bs._center;
|
||||||
value_type c = sm.length2()-bs._radius*bs._radius;
|
value_type c = sm.length2()-bs._radius*bs._radius;
|
||||||
@ -242,7 +246,7 @@ bool LineSegment::intersect(const BoundingSphere& bs,float& r1,float& r2) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool LineSegment::intersect(const BoundingSphere& bs,double& r1,double& r2) const
|
bool LineSegment::intersectAndComputeRatios(const BoundingSphere& bs,double& r1,double& r2) const
|
||||||
{
|
{
|
||||||
vec_type sm = _s-bs._center;
|
vec_type sm = _s-bs._center;
|
||||||
value_type c = sm.length2()-bs._radius*bs._radius;
|
value_type c = sm.length2()-bs._radius*bs._radius;
|
||||||
@ -286,7 +290,6 @@ bool LineSegment::intersect(const BoundingSphere& bs,double& r1,double& r2) cons
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LineSegment::intersect(const BoundingSphere& bs) const
|
bool LineSegment::intersect(const BoundingSphere& bs) const
|
||||||
{
|
{
|
||||||
vec_type sm = _s-bs._center;
|
vec_type sm = _s-bs._center;
|
||||||
@ -316,7 +319,6 @@ bool LineSegment::intersect(const BoundingSphere& bs) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LineSegment::intersect(const Vec3f& v1,const Vec3f& v2,const Vec3f& v3,float& r)
|
bool LineSegment::intersect(const Vec3f& v1,const Vec3f& v2,const Vec3f& v3,float& r)
|
||||||
{
|
{
|
||||||
if (v1==v2 || v2==v3 || v1==v3) return false;
|
if (v1==v2 || v2==v3 || v1==v3) return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user