Added more accurate computation of local height above sea level in the plane intersections routines

This commit is contained in:
Robert Osfield
2006-12-05 12:58:29 +00:00
parent ba3fe2844f
commit afa96fff0e
5 changed files with 130 additions and 26 deletions

View File

@@ -163,7 +163,7 @@ class OSG_EXPORT Plane
_fv[3];
}
inline float distance(const osg::Vec3d& v) const
inline double distance(const osg::Vec3d& v) const
{
return _fv[0]*v.x()+
_fv[1]*v.y()+
@@ -180,7 +180,7 @@ class OSG_EXPORT Plane
}
/** calculate the dot product of the plane normal and a point.*/
inline float dotProductNormal(const osg::Vec3d& v) const
inline double dotProductNormal(const osg::Vec3d& v) const
{
return _fv[0]*v.x()+
_fv[1]*v.y()+

View File

@@ -16,6 +16,8 @@
#include <osgUtil/IntersectionVisitor>
#include <osg/CoordinateSystemNode>
namespace osgUtil
{
@@ -47,11 +49,13 @@ class OSGUTIL_EXPORT PlaneIntersector : public Intersector
}
typedef std::vector<osg::Vec3d> Polyline;
typedef std::vector<double> Attributes;
osg::NodePath nodePath;
osg::ref_ptr<osg::RefMatrix> matrix;
osg::ref_ptr<osg::Drawable> drawable;
Polyline polyline;
Attributes attributes;
};
@@ -61,6 +65,15 @@ class OSGUTIL_EXPORT PlaneIntersector : public Intersector
inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
void setRecordHeightsAsAttributes(bool flag) { _recordHeightsAsAttributes = flag; }
bool getRecordHeightsAsAttributes() const { return _recordHeightsAsAttributes; }
void setEllipsoidModel(osg::EllipsoidModel* em) { _em = em; }
const osg::EllipsoidModel* getEllipsoidModel() const { return _em.get(); }
public:
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv);
@@ -77,12 +90,15 @@ class OSGUTIL_EXPORT PlaneIntersector : public Intersector
protected:
PlaneIntersector* _parent;
osg::Plane _plane;
osg::Polytope _polytope;
PlaneIntersector* _parent;
Intersections _intersections;
bool _recordHeightsAsAttributes;
osg::ref_ptr<osg::EllipsoidModel> _em;
osg::Plane _plane;
osg::Polytope _polytope;
Intersections _intersections;
};