Introduced typedef vec_type and value_type into LineSemgment class to allow easier

switching between double and float versions.
This commit is contained in:
Robert Osfield
2008-02-18 14:51:05 +00:00
parent 8b77cc4dac
commit a97dc84228
6 changed files with 45 additions and 40 deletions

View File

@@ -25,19 +25,22 @@ class OSG_EXPORT LineSegment : public Referenced
{
public:
typedef Vec3d vec_type;
typedef vec_type::value_type value_type;
LineSegment() {};
LineSegment(const LineSegment& seg) : Referenced(),_s(seg._s),_e(seg._e) {}
LineSegment(const Vec3& s,const Vec3& e) : _s(s),_e(e) {}
LineSegment(const vec_type& s,const vec_type& e) : _s(s),_e(e) {}
LineSegment& operator = (const LineSegment& seg) { _s = seg._s; _e = seg._e; return *this; }
inline void set(const Vec3& s,const Vec3& e) { _s=s; _e=e; }
inline void set(const vec_type& s,const vec_type& e) { _s=s; _e=e; }
inline Vec3& start() { return _s; }
inline const Vec3& start() const { return _s; }
inline vec_type& start() { return _s; }
inline const vec_type& start() const { return _s; }
inline Vec3& end() { return _e; }
inline const Vec3& end() const { return _e; }
inline vec_type& end() { return _e; }
inline const vec_type& end() const { return _e; }
inline bool valid() const { return _s.valid() && _e.valid() && _s!=_e; }
@@ -71,10 +74,10 @@ class OSG_EXPORT LineSegment : public Referenced
virtual ~LineSegment();
static bool intersectAndClip(Vec3& s,Vec3& e,const BoundingBox& bb);
static bool intersectAndClip(vec_type& s,vec_type& e,const BoundingBox& bb);
Vec3 _s;
Vec3 _e;
vec_type _s;
vec_type _e;
};
}

View File

@@ -127,15 +127,15 @@ class OSGMANIPULATOR_EXPORT TranslateInLineCommand : public MotionCommand
TranslateInLineCommand();
TranslateInLineCommand(const osg::Vec3& s, const osg::Vec3& e);
TranslateInLineCommand(const osg::LineSegment::vec_type& s, const osg::LineSegment::vec_type& e);
virtual bool execute();
virtual bool unexecute();
virtual void applyConstraint(const Constraint*);
inline void setLine(const osg::Vec3& s, const osg::Vec3& e) { _line->start() = s; _line->end() = e; }
inline const osg::Vec3& getLineStart() const { return _line->start(); }
inline const osg::Vec3& getLineEnd() const { return _line->end(); }
inline void setLine(const osg::LineSegment::vec_type& s, const osg::LineSegment::vec_type& e) { _line->start() = s; _line->end() = e; }
inline const osg::LineSegment::vec_type& getLineStart() const { return _line->start(); }
inline const osg::LineSegment::vec_type& getLineEnd() const { return _line->end(); }
inline void setTranslation(const osg::Vec3& t) { _translation = t; }
inline const osg::Vec3& getTranslation() const { return _translation; }

View File

@@ -92,13 +92,15 @@ class OSGMANIPULATOR_EXPORT LineProjector : public Projector
LineProjector();
LineProjector(const osg::Vec3& s, const osg::Vec3& e);
LineProjector(const osg::LineSegment::vec_type& s, const osg::LineSegment::vec_type& e);
inline void setLine(const osg::Vec3& s, const osg::Vec3& e) { _line->start() = s; _line->end() = e; }
inline const osg::Vec3& getLineStart() const { return _line->start(); }
inline osg::Vec3& getLineStart() { return _line->start(); }
inline const osg::Vec3& getLineEnd() const { return _line->end(); }
inline osg::Vec3& getLineEnd() { return _line->end(); }
inline void setLine(const osg::LineSegment::vec_type& s, const osg::LineSegment::vec_type& e) { _line->start() = s; _line->end() = e; }
inline const osg::LineSegment::vec_type& getLineStart() const { return _line->start(); }
inline osg::LineSegment::vec_type& getLineStart() { return _line->start(); }
inline const osg::LineSegment::vec_type& getLineEnd() const { return _line->end(); }
inline osg::LineSegment::vec_type& getLineEnd() { return _line->end(); }
/**
* Calculates the object coordinates (projectedPoint) of a window