diff --git a/include/osgManipulator/AntiSquish b/include/osgManipulator/AntiSquish index a87ed77d7..2f6fb6e50 100644 --- a/include/osgManipulator/AntiSquish +++ b/include/osgManipulator/AntiSquish @@ -34,8 +34,8 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform { public : AntiSquish(); - AntiSquish(const osg::Vec3& pivot); - AntiSquish(const osg::Vec3& pivot, const osg::Vec3& position); + AntiSquish(const osg::Vec3d& pivot); + AntiSquish(const osg::Vec3d& pivot, const osg::Vec3d& position); AntiSquish(const AntiSquish& pat, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); virtual osg::Object* cloneType() const { return new AntiSquish(); } @@ -44,23 +44,23 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } - void setPivot(const osg::Vec3& pvt) + void setPivot(const osg::Vec3d& pvt) { _pivot = pvt; _usePivot = true; _dirty = true; } - const osg::Vec3& getPivot() { return _pivot; } + const osg::Vec3d& getPivot() { return _pivot; } - void setPosition(const osg::Vec3& pos) + void setPosition(const osg::Vec3d& pos) { _position = pos; _usePosition = true; _dirty = true; } - const osg::Vec3& getPosition() { return _position; } + const osg::Vec3d& getPosition() { return _position; } virtual ~AntiSquish(); @@ -70,10 +70,10 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform osg::NodeCallback* _asqCallback; - osg::Vec3 _pivot; + osg::Vec3d _pivot; bool _usePivot; - osg::Vec3 _position; + osg::Vec3d _position; bool _usePosition; bool _dirty; diff --git a/include/osgManipulator/Command b/include/osgManipulator/Command index 919c55ca0..ea7d28cc5 100644 --- a/include/osgManipulator/Command +++ b/include/osgManipulator/Command @@ -138,7 +138,7 @@ class OSGMANIPULATOR_EXPORT TranslateInLineCommand : public MotionCommand 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; } + inline const osg::Vec3d& getTranslation() const { return _translation; } virtual osg::Matrix getMotionMatrix() const { @@ -151,7 +151,7 @@ class OSGMANIPULATOR_EXPORT TranslateInLineCommand : public MotionCommand private: osg::ref_ptr _line; - osg::Vec3 _translation; + osg::Vec3d _translation; }; /** @@ -172,12 +172,12 @@ class OSGMANIPULATOR_EXPORT TranslateInPlaneCommand : public MotionCommand inline void setPlane(const osg::Plane& plane) { _plane = plane; } inline const osg::Plane& getPlane() const { return _plane; } - inline void setTranslation(const osg::Vec3& t) { _translation = t; } - inline const osg::Vec3& getTranslation() const { return _translation; } + inline void setTranslation(const osg::Vec3d& t) { _translation = t; } + inline const osg::Vec3d& getTranslation() const { return _translation; } /** ReferencePoint is used only for snapping. */ - inline void setReferencePoint(const osg::Vec3& rp) { _referencePoint = rp; } - inline const osg::Vec3& getReferencePoint() const { return _referencePoint; } + inline void setReferencePoint(const osg::Vec3d& rp) { _referencePoint = rp; } + inline const osg::Vec3d& getReferencePoint() const { return _referencePoint; } virtual osg::Matrix getMotionMatrix() const { @@ -190,8 +190,8 @@ class OSGMANIPULATOR_EXPORT TranslateInPlaneCommand : public MotionCommand private: osg::Plane _plane; - osg::Vec3 _translation; - osg::Vec3 _referencePoint; + osg::Vec3d _translation; + osg::Vec3d _referencePoint; }; /** @@ -207,18 +207,18 @@ class OSGMANIPULATOR_EXPORT Scale1DCommand : public MotionCommand virtual bool unexecute(); virtual void applyConstraint(const Constraint*); - inline void setScale(float s) { _scale = s; } - inline float getScale() const { return _scale; } + inline void setScale(double s) { _scale = s; } + inline double getScale() const { return _scale; } - inline void setScaleCenter(float center) { _scaleCenter = center; } - inline float getScaleCenter() const { return _scaleCenter; } + inline void setScaleCenter(double center) { _scaleCenter = center; } + inline double getScaleCenter() const { return _scaleCenter; } /** ReferencePoint is used only for snapping. */ - inline void setReferencePoint(float rp) { _referencePoint = rp; } - inline float getReferencePoint() const { return _referencePoint; } + inline void setReferencePoint(double rp) { _referencePoint = rp; } + inline double getReferencePoint() const { return _referencePoint; } - inline void setMinScale(float min) { _minScale = min; } - inline float getMinScale() const { return _minScale; } + inline void setMinScale(double min) { _minScale = min; } + inline double getMinScale() const { return _minScale; } virtual osg::Matrix getMotionMatrix() const { @@ -232,10 +232,10 @@ class OSGMANIPULATOR_EXPORT Scale1DCommand : public MotionCommand virtual ~Scale1DCommand(); private: - float _scale; - float _scaleCenter; - float _referencePoint; - float _minScale; + double _scale; + double _scaleCenter; + double _referencePoint; + double _minScale; }; /** @@ -251,18 +251,18 @@ class OSGMANIPULATOR_EXPORT Scale2DCommand : public MotionCommand virtual bool unexecute(); virtual void applyConstraint(const Constraint*); - inline void setScale(const osg::Vec2& s) { _scale = s; } - inline const osg::Vec2& getScale() const { return _scale; } + inline void setScale(const osg::Vec2d& s) { _scale = s; } + inline const osg::Vec2d& getScale() const { return _scale; } - inline void setScaleCenter(const osg::Vec2& center) { _scaleCenter = center; } - inline const osg::Vec2& getScaleCenter() const { return _scaleCenter; } + inline void setScaleCenter(const osg::Vec2d& center) { _scaleCenter = center; } + inline const osg::Vec2d& getScaleCenter() const { return _scaleCenter; } /** ReferencePoint is used only for snapping. */ - inline void setReferencePoint(const osg::Vec2& rp) { _referencePoint = rp; } - inline const osg::Vec2& getReferencePoint() const { return _referencePoint; } + inline void setReferencePoint(const osg::Vec2d& rp) { _referencePoint = rp; } + inline const osg::Vec2d& getReferencePoint() const { return _referencePoint; } - inline void setMinScale(const osg::Vec2& min) { _minScale = min; } - inline const osg::Vec2& getMinScale() const { return _minScale; } + inline void setMinScale(const osg::Vec2d& min) { _minScale = min; } + inline const osg::Vec2d& getMinScale() const { return _minScale; } virtual osg::Matrix getMotionMatrix() const { @@ -276,10 +276,10 @@ class OSGMANIPULATOR_EXPORT Scale2DCommand : public MotionCommand virtual ~Scale2DCommand(); private: - osg::Vec2 _scale; - osg::Vec2 _scaleCenter; - osg::Vec2 _referencePoint; - osg::Vec2 _minScale; + osg::Vec2d _scale; + osg::Vec2d _scaleCenter; + osg::Vec2d _referencePoint; + osg::Vec2d _minScale; }; /** @@ -295,11 +295,11 @@ class OSGMANIPULATOR_EXPORT ScaleUniformCommand : public MotionCommand virtual bool unexecute(); virtual void applyConstraint(const Constraint*); - inline void setScale(float s) { _scale = s; } - inline float getScale() const { return _scale; } + inline void setScale(double s) { _scale = s; } + inline double getScale() const { return _scale; } - inline void setScaleCenter(const osg::Vec3& center) { _scaleCenter = center; } - inline const osg::Vec3& getScaleCenter() const { return _scaleCenter; } + inline void setScaleCenter(const osg::Vec3d& center) { _scaleCenter = center; } + inline const osg::Vec3d& getScaleCenter() const { return _scaleCenter; } virtual osg::Matrix getMotionMatrix() const { @@ -313,8 +313,8 @@ class OSGMANIPULATOR_EXPORT ScaleUniformCommand : public MotionCommand virtual ~ScaleUniformCommand(); private: - float _scale; - osg::Vec3 _scaleCenter; + double _scale; + osg::Vec3d _scaleCenter; }; /** diff --git a/include/osgManipulator/Dragger b/include/osgManipulator/Dragger index e9d3d74c4..13f79751c 100644 --- a/include/osgManipulator/Dragger +++ b/include/osgManipulator/Dragger @@ -59,23 +59,23 @@ class OSGMANIPULATOR_EXPORT PointerInfo if (!completed()) ++_hitIter; } - typedef std::pair NodePathIntersectionPair; + typedef std::pair NodePathIntersectionPair; typedef std::list< NodePathIntersectionPair> IntersectionList; - osg::Vec3 getLocalIntersectPoint() const { return _hitIter->second; } + osg::Vec3d getLocalIntersectPoint() const { return _hitIter->second; } - void setNearFarPoints (osg::Vec3 nearPoint, osg::Vec3 farPoint) { + void setNearFarPoints (osg::Vec3d nearPoint, osg::Vec3d farPoint) { _nearPoint = nearPoint; _farPoint=farPoint; _eyeDir = farPoint - nearPoint; } - const osg::Vec3& getEyeDir() const {return _eyeDir;} + const osg::Vec3d& getEyeDir() const {return _eyeDir;} - void getNearFarPoints( osg::Vec3& nearPoint, osg::Vec3& farPoint) const { + void getNearFarPoints( osg::Vec3d& nearPoint, osg::Vec3d& farPoint) const { nearPoint = _nearPoint; farPoint = _farPoint; } @@ -90,7 +90,7 @@ class OSGMANIPULATOR_EXPORT PointerInfo _MVPW = camera->getViewMatrix() * camera->getProjectionMatrix(); if (camera->getViewport()) _MVPW.postMult(camera->getViewport()->computeWindowMatrix()); _inverseMVPW.invert(_MVPW); - osg::Vec3 eye, center, up; + osg::Vec3d eye, center, up; camera->getViewMatrix().getLookAt(eye, center, up); _eyeDir = eye - center; @@ -99,12 +99,12 @@ class OSGMANIPULATOR_EXPORT PointerInfo { _MVPW.makeIdentity(); _inverseMVPW.makeIdentity(); - _eyeDir = osg::Vec3(0,0,1); + _eyeDir = osg::Vec3d(0,0,1); } } - void addIntersection(const osg::NodePath& nodePath, const osg::Vec3& intersectionPoint) + void addIntersection(const osg::NodePath& nodePath, const osg::Vec3d& intersectionPoint) { bool needToResetHitIter = _hitList.empty(); _hitList.push_back(NodePathIntersectionPair(nodePath, intersectionPoint)); @@ -113,10 +113,10 @@ class OSGMANIPULATOR_EXPORT PointerInfo void setMousePosition(float pixel_x, float pixel_y) { - projectWindowXYIntoObject(osg::Vec2(pixel_x, pixel_y), _nearPoint, _farPoint); + projectWindowXYIntoObject(osg::Vec2d(pixel_x, pixel_y), _nearPoint, _farPoint); } protected: - bool projectWindowXYIntoObject(const osg::Vec2& windowCoord, osg::Vec3& nearPoint, osg::Vec3& farPoint) const; + bool projectWindowXYIntoObject(const osg::Vec2d& windowCoord, osg::Vec3d& nearPoint, osg::Vec3d& farPoint) const; public: IntersectionList _hitList; @@ -124,8 +124,8 @@ class OSGMANIPULATOR_EXPORT PointerInfo protected: - osg::Vec3 _nearPoint,_farPoint; - osg::Vec3 _eyeDir; + osg::Vec3d _nearPoint,_farPoint; + osg::Vec3d _eyeDir; osg::Matrix _MVPW; osg::Matrix _inverseMVPW; diff --git a/include/osgManipulator/Projector b/include/osgManipulator/Projector index 084e65d9b..68963b65e 100644 --- a/include/osgManipulator/Projector +++ b/include/osgManipulator/Projector @@ -40,7 +40,7 @@ class OSGMANIPULATOR_EXPORT Projector : public osg::Referenced * projecting window coordinates into object coordinates and vice versa. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const = 0; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const = 0; /** * Sets the matrix for transforming the projector's local coordinate @@ -107,7 +107,7 @@ class OSGMANIPULATOR_EXPORT LineProjector : public Projector * coordinate (pointToProject) when projected onto the given line. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const; protected: @@ -135,7 +135,7 @@ class OSGMANIPULATOR_EXPORT PlaneProjector : public Projector * coordinate (pointToProject) when projected onto the given plane. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const; protected: @@ -163,7 +163,7 @@ class OSGMANIPULATOR_EXPORT SphereProjector : public Projector * coordinate (pointToProject) when projected onto the given sphere. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const; /** * Returns true is the point is in front of the cylinder given the eye @@ -198,7 +198,7 @@ class OSGMANIPULATOR_EXPORT SpherePlaneProjector : public SphereProjector * coordinate (pointToProject) when projected onto the given sphere. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const; /** * Returns true if the previous projection was on the sphere and false @@ -206,8 +206,8 @@ class OSGMANIPULATOR_EXPORT SpherePlaneProjector : public SphereProjector */ bool isProjectionOnSphere() const { return _onSphere; } - osg::Quat getRotation(const osg::Vec3& p1, bool p1OnSphere, - const osg::Vec3& p2, bool p2OnSphere, + osg::Quat getRotation(const osg::Vec3d& p1, bool p1OnSphere, + const osg::Vec3d& p2, bool p2OnSphere, float radialFactor = 0.0f) const; protected: @@ -232,7 +232,7 @@ class OSGMANIPULATOR_EXPORT CylinderProjector : public Projector inline void setCylinder(osg::Cylinder* cylinder) { _cylinder = cylinder; - _cylinderAxis = osg::Vec3(0.0,0.0,1.0) * osg::Matrix(cylinder->getRotation()); + _cylinderAxis = osg::Vec3d(0.0,0.0,1.0) * osg::Matrix(cylinder->getRotation()); _cylinderAxis.normalize(); } inline const osg::Cylinder* getCylinder() const { return _cylinder.get(); } @@ -242,7 +242,7 @@ class OSGMANIPULATOR_EXPORT CylinderProjector : public Projector * coordinate (pointToProject) when projected onto the given plane. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const; /** @@ -258,7 +258,7 @@ class OSGMANIPULATOR_EXPORT CylinderProjector : public Projector virtual ~CylinderProjector(); osg::ref_ptr _cylinder; - osg::Vec3 _cylinderAxis; + osg::Vec3d _cylinderAxis; bool _front; }; @@ -278,7 +278,7 @@ class OSGMANIPULATOR_EXPORT CylinderPlaneProjector : public CylinderProjector * coordinate (pointToProject) when projected onto the given plane. * Returns true on successful projection. */ - virtual bool project(const PointerInfo& pi, osg::Vec3& projectedPoint) const; + virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const; /** * Returns true if the previous projection was on the cylinder and @@ -286,7 +286,7 @@ class OSGMANIPULATOR_EXPORT CylinderPlaneProjector : public CylinderProjector */ bool isProjectionOnCylinder() const { return _onCylinder; } - osg::Quat getRotation(const osg::Vec3& p1, bool p1OnCyl, const osg::Vec3& p2, bool p2OnCyl) const; + osg::Quat getRotation(const osg::Vec3d& p1, bool p1OnCyl, const osg::Vec3d& p2, bool p2OnCyl) const; protected: @@ -294,7 +294,7 @@ class OSGMANIPULATOR_EXPORT CylinderPlaneProjector : public CylinderProjector mutable osg::Plane _plane; mutable bool _onCylinder; - mutable osg::Vec3 _planeLineStart, _planeLineEnd; + mutable osg::Vec3d _planeLineStart, _planeLineEnd; }; } diff --git a/include/osgManipulator/RotateCylinderDragger b/include/osgManipulator/RotateCylinderDragger index bfe1a071d..73e6f1899 100644 --- a/include/osgManipulator/RotateCylinderDragger +++ b/include/osgManipulator/RotateCylinderDragger @@ -56,7 +56,7 @@ class OSGMANIPULATOR_EXPORT RotateCylinderDragger : public Dragger osg::ref_ptr _projector; - osg::Vec3 _prevWorldProjPt; + osg::Vec3d _prevWorldProjPt; bool _prevPtOnCylinder; osg::Matrix _startLocalToWorld, _startWorldToLocal; osg::Quat _prevRotation; diff --git a/include/osgManipulator/RotateSphereDragger b/include/osgManipulator/RotateSphereDragger index d6c3bb198..3770317e5 100644 --- a/include/osgManipulator/RotateSphereDragger +++ b/include/osgManipulator/RotateSphereDragger @@ -55,7 +55,7 @@ class OSGMANIPULATOR_EXPORT RotateSphereDragger : public Dragger osg::ref_ptr _projector; - osg::Vec3 _prevWorldProjPt; + osg::Vec3d _prevWorldProjPt; bool _prevPtOnSphere; osg::Matrix _startLocalToWorld, _startWorldToLocal; osg::Quat _prevRotation; diff --git a/include/osgManipulator/Scale1DDragger b/include/osgManipulator/Scale1DDragger index e80a36c71..e1d35f93d 100644 --- a/include/osgManipulator/Scale1DDragger +++ b/include/osgManipulator/Scale1DDragger @@ -44,8 +44,8 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger void setupDefaultGeometry(); /** Set/Get min scale for dragger. */ - inline void setMinScale(float min) { _minScale = min; } - inline float getMinScale() const { return _minScale; } + inline void setMinScale(double min) { _minScale = min; } + inline double getMinScale() const { return _minScale; } /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } @@ -66,19 +66,19 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger inline osg::Node* getRightHandleNode() { return _rightHandleNode.get(); } /** Set left/right handle position. */ - inline void setLeftHandlePosition(float pos) { _projector->getLineStart() = osg::Vec3(pos,0.0,0.0); } - inline float getLeftHandlePosition() const { return _projector->getLineStart()[0]; } - inline void setRightHandlePosition(float pos) { _projector->getLineEnd() = osg::Vec3(pos,0.0,0.0); } - inline float getRightHandlePosition() { return _projector->getLineEnd()[0]; } + inline void setLeftHandlePosition(double pos) { _projector->getLineStart() = osg::Vec3d(pos,0.0,0.0); } + inline double getLeftHandlePosition() const { return _projector->getLineStart()[0]; } + inline void setRightHandlePosition(double pos) { _projector->getLineEnd() = osg::Vec3d(pos,0.0,0.0); } + inline double getRightHandlePosition() { return _projector->getLineEnd()[0]; } protected: virtual ~Scale1DDragger(); osg::ref_ptr< LineProjector > _projector; - osg::Vec3 _startProjectedPoint; - float _scaleCenter; - float _minScale; + osg::Vec3d _startProjectedPoint; + double _scaleCenter; + double _minScale; osg::ref_ptr< osg::Node > _leftHandleNode; osg::ref_ptr< osg::Node > _rightHandleNode; diff --git a/include/osgManipulator/Scale2DDragger b/include/osgManipulator/Scale2DDragger index 93a89cbb1..5d726128d 100644 --- a/include/osgManipulator/Scale2DDragger +++ b/include/osgManipulator/Scale2DDragger @@ -44,8 +44,8 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger void setupDefaultGeometry(); /** Set/Get min scale for dragger. */ - inline void setMinScale(const osg::Vec2& min) { _minScale = min; } - inline const osg::Vec2& getMinScale() const { return _minScale; } + inline void setMinScale(const osg::Vec2d& min) { _minScale = min; } + inline const osg::Vec2d& getMinScale() const { return _minScale; } /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } @@ -70,34 +70,34 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger inline osg::Node* getBottomRightHandleNode() { return _bottomRightHandleNode.get(); } /** Set/Get the handle nodes postion for dragger. */ - inline void setTopLeftHandlePosition(const osg::Vec2& pos) { _topLeftHandlePosition = pos; } - const osg::Vec2& getTopLeftHandlePosition() { return _topLeftHandlePosition; } - inline void setBottomLeftHandlePosition(const osg::Vec2& pos) { _bottomLeftHandlePosition = pos; } - const osg::Vec2& getBottomLeftHandlePosition() { return _bottomLeftHandlePosition; } - inline void setTopRightHandlePosition(const osg::Vec2& pos) { _topRightHandlePosition = pos; } - const osg::Vec2& getTopRightHandlePosition() { return _topRightHandlePosition; } - inline void setBottomRightHandlePosition(const osg::Vec2& pos){ _bottomRightHandlePosition = pos; } - const osg::Vec2& getBottomRightHandlePosition() { return _bottomRightHandlePosition; } + inline void setTopLeftHandlePosition(const osg::Vec2d& pos) { _topLeftHandlePosition = pos; } + const osg::Vec2d& getTopLeftHandlePosition() { return _topLeftHandlePosition; } + inline void setBottomLeftHandlePosition(const osg::Vec2d& pos) { _bottomLeftHandlePosition = pos; } + const osg::Vec2d& getBottomLeftHandlePosition() { return _bottomLeftHandlePosition; } + inline void setTopRightHandlePosition(const osg::Vec2d& pos) { _topRightHandlePosition = pos; } + const osg::Vec2d& getTopRightHandlePosition() { return _topRightHandlePosition; } + inline void setBottomRightHandlePosition(const osg::Vec2d& pos){ _bottomRightHandlePosition = pos; } + const osg::Vec2d& getBottomRightHandlePosition() { return _bottomRightHandlePosition; } protected: virtual ~Scale2DDragger(); osg::ref_ptr< PlaneProjector > _projector; - osg::Vec3 _startProjectedPoint; - osg::Vec2 _scaleCenter; - osg::Vec2 _referencePoint; - osg::Vec2 _minScale; + osg::Vec3d _startProjectedPoint; + osg::Vec2d _scaleCenter; + osg::Vec2d _referencePoint; + osg::Vec2d _minScale; osg::ref_ptr< osg::Node > _topLeftHandleNode; osg::ref_ptr< osg::Node > _bottomLeftHandleNode; osg::ref_ptr< osg::Node > _topRightHandleNode; osg::ref_ptr< osg::Node > _bottomRightHandleNode; - osg::Vec2 _topLeftHandlePosition; - osg::Vec2 _bottomLeftHandlePosition; - osg::Vec2 _topRightHandlePosition; - osg::Vec2 _bottomRightHandlePosition; + osg::Vec2d _topLeftHandlePosition; + osg::Vec2d _bottomLeftHandlePosition; + osg::Vec2d _topRightHandlePosition; + osg::Vec2d _bottomRightHandlePosition; osg::Vec4 _color; osg::Vec4 _pickColor; diff --git a/include/osgManipulator/Translate1DDragger b/include/osgManipulator/Translate1DDragger index ce6ff3288..127e712fb 100644 --- a/include/osgManipulator/Translate1DDragger +++ b/include/osgManipulator/Translate1DDragger @@ -30,7 +30,7 @@ class OSGMANIPULATOR_EXPORT Translate1DDragger : public Dragger Translate1DDragger(); - Translate1DDragger(const osg::Vec3& s, const osg::Vec3& e); + Translate1DDragger(const osg::Vec3d& s, const osg::Vec3d& e); /** Handle pick events on dragger and generate TranslateInLine commands. */ virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us); @@ -54,7 +54,7 @@ class OSGMANIPULATOR_EXPORT Translate1DDragger : public Dragger virtual ~Translate1DDragger(); osg::ref_ptr< LineProjector > _projector; - osg::Vec3 _startProjectedPoint; + osg::Vec3d _startProjectedPoint; osg::Vec4 _color; osg::Vec4 _pickColor; diff --git a/include/osgManipulator/Translate2DDragger b/include/osgManipulator/Translate2DDragger index 83e2ca5c1..f20d8e3cd 100644 --- a/include/osgManipulator/Translate2DDragger +++ b/include/osgManipulator/Translate2DDragger @@ -53,7 +53,7 @@ class OSGMANIPULATOR_EXPORT Translate2DDragger : public Dragger virtual ~Translate2DDragger(); osg::ref_ptr< PlaneProjector > _projector; - osg::Vec3 _startProjectedPoint; + osg::Vec3d _startProjectedPoint; osg::Vec4 _color; osg::Vec4 _pickColor; diff --git a/src/osgManipulator/AntiSquish.cpp b/src/osgManipulator/AntiSquish.cpp index a3f9b465d..18112624b 100644 --- a/src/osgManipulator/AntiSquish.cpp +++ b/src/osgManipulator/AntiSquish.cpp @@ -54,13 +54,13 @@ AntiSquish::AntiSquish() : _usePivot(true), _usePosition(false) setUpdateCallback(_asqCallback); } -AntiSquish::AntiSquish(const osg::Vec3& pivot) : _pivot(pivot), _usePivot(true), _usePosition(false) +AntiSquish::AntiSquish(const osg::Vec3d& pivot) : _pivot(pivot), _usePivot(true), _usePosition(false) { _asqCallback = new AntiSquishCallback(this); setUpdateCallback(_asqCallback); } -AntiSquish::AntiSquish(const osg::Vec3& pivot, const osg::Vec3& pos) +AntiSquish::AntiSquish(const osg::Vec3d& pivot, const osg::Vec3d& pos) : _pivot(pivot), _usePivot(true), _position(pos), _usePosition(true) { _asqCallback = new AntiSquishCallback(this); diff --git a/src/osgManipulator/Command.cpp b/src/osgManipulator/Command.cpp index fc7923a6d..9daff1083 100644 --- a/src/osgManipulator/Command.cpp +++ b/src/osgManipulator/Command.cpp @@ -148,7 +148,7 @@ void TranslateInPlaneCommand::applyConstraint(const Constraint* constraint) // Scale 1D command. // -Scale1DCommand::Scale1DCommand() : _scale(1.0f) +Scale1DCommand::Scale1DCommand() : _scale(1.0) { } @@ -237,7 +237,7 @@ void Scale2DCommand::applyConstraint(const Constraint* constraint) // Scale uniform command. // -ScaleUniformCommand::ScaleUniformCommand() : _scale(1.0f) +ScaleUniformCommand::ScaleUniformCommand() : _scale(1.0) { } diff --git a/src/osgManipulator/Constraint.cpp b/src/osgManipulator/Constraint.cpp index 4ec9cc048..5467a8888 100644 --- a/src/osgManipulator/Constraint.cpp +++ b/src/osgManipulator/Constraint.cpp @@ -59,7 +59,7 @@ bool GridConstraint::constrain(TranslateInLineCommand& command) const else if (command.getStage() == osgManipulator::MotionCommand::FINISH) return true; - osg::Vec3 translatedPoint = command.getLineStart() + command.getTranslation(); + osg::Vec3d translatedPoint = command.getLineStart() + command.getTranslation(); osg::Vec3d localTranslatedPoint = (osg::Vec3d(translatedPoint) * command.getLocalToWorld() * getWorldToLocal()); osg::Vec3d newLocalTranslatedPoint = snap_point_to_grid(localTranslatedPoint, @@ -86,7 +86,7 @@ bool GridConstraint::constrain(TranslateInPlaneCommand& command) const osg::Vec3d snappedCmdRefPoint = snappedLocalRefPoint * constraintToCommand; // Snap the translated point to grid. - osg::Vec3 translatedPoint = snappedCmdRefPoint + command.getTranslation(); + osg::Vec3d translatedPoint = snappedCmdRefPoint + command.getTranslation(); osg::Vec3d localTranslatedPoint = osg::Vec3d(translatedPoint) * commandToConstraint; osg::Vec3d newLocalTranslatedPoint = snap_point_to_grid(localTranslatedPoint, _origin, _spacing); @@ -146,7 +146,7 @@ bool GridConstraint::constrain(Scale2DCommand& command) const commandSpacing[2]*spacingFactor[1])); osg::Vec2d denom = command.getReferencePoint() - command.getScaleCenter(); - osg::Vec2 snappedScale; + osg::Vec2d snappedScale; snappedScale[0] = denom[0] ? (snappedScaledPoint[0] - command.getScaleCenter()[0]) / denom[0] : 1.0; snappedScale[1] = denom[1] ? (snappedScaledPoint[1] - command.getScaleCenter()[1]) / denom[1] : 1.0; diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index 16a81c30e..a939d57d8 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -18,9 +18,9 @@ using namespace osgManipulator; PointerInfo::PointerInfo(): - _nearPoint(osg::Vec3()), - _farPoint(osg::Vec3()), - _eyeDir(osg::Vec3(0,0,1)) + _nearPoint(osg::Vec3d()), + _farPoint(osg::Vec3d()), + _eyeDir(osg::Vec3d(0,0,1)) { _hitIter = _hitList.begin(); } @@ -31,10 +31,10 @@ bool PointerInfo::contains(const osg::Node* node) const else return false; } -bool PointerInfo::projectWindowXYIntoObject(const osg::Vec2& windowCoord, osg::Vec3& nearPoint, osg::Vec3& farPoint) const +bool PointerInfo::projectWindowXYIntoObject(const osg::Vec2d& windowCoord, osg::Vec3d& nearPoint, osg::Vec3d& farPoint) const { - nearPoint = osg::Vec3(windowCoord.x(),windowCoord.y(),0.0f)*_inverseMVPW; - farPoint = osg::Vec3(windowCoord.x(),windowCoord.y(),1.0f)*_inverseMVPW; + nearPoint = osg::Vec3d(windowCoord.x(),windowCoord.y(),0.0)*_inverseMVPW; + farPoint = osg::Vec3d(windowCoord.x(),windowCoord.y(),1.0)*_inverseMVPW; return true; } diff --git a/src/osgManipulator/Projector.cpp b/src/osgManipulator/Projector.cpp index eabfe74c3..43a670f15 100644 --- a/src/osgManipulator/Projector.cpp +++ b/src/osgManipulator/Projector.cpp @@ -20,7 +20,7 @@ namespace { bool computeClosestPoints(const osg::LineSegment& l1, const osg::LineSegment& l2, - osg::Vec3& p1, osg::Vec3& p2) + osg::Vec3d& p1, osg::Vec3d& p2) { // Computes the closest points (p1 and p2 on line l1 and l2 respectively) between the two lines // An explanation of the algorithm can be found at @@ -31,19 +31,19 @@ bool computeClosestPoints(const osg::LineSegment& l1, const osg::LineSegment& l2 osg::LineSegment::vec_type w0 = l1.start() - l2.start(); - float a = u * u; - float b = u * v; - float c = v * v; - float d = u * w0; - float e = v * w0; + double a = u * u; + double b = u * v; + double c = v * v; + double d = u * w0; + double e = v * w0; - float denominator = a*c - b*b; + double denominator = a*c - b*b; // Test if lines are parallel if (denominator == 0.0) return false; - float sc = (b*e - c*d)/denominator; - float tc = (a*e - b*d)/denominator; + double sc = (b*e - c*d)/denominator; + double tc = (a*e - b*d)/denominator; p1 = l1.start() + u * sc; p2 = l2.start() + v * tc; @@ -51,27 +51,27 @@ bool computeClosestPoints(const osg::LineSegment& l1, const osg::LineSegment& l2 return true; } -bool computeClosestPointOnLine(const osg::Vec3& lineStart, const osg::Vec3& lineEnd, - const osg::Vec3& fromPoint, osg::Vec3& closestPoint) +bool computeClosestPointOnLine(const osg::Vec3d& lineStart, const osg::Vec3d& lineEnd, + const osg::Vec3d& fromPoint, osg::Vec3d& closestPoint) { - osg::Vec3 v = lineEnd - lineStart; - osg::Vec3 w = fromPoint - lineStart; + osg::Vec3d v = lineEnd - lineStart; + osg::Vec3d w = fromPoint - lineStart; - float c1 = w * v; - float c2 = v * v; + double c1 = w * v; + double c2 = v * v; - float almostZero = 0.000001; + double almostZero = 0.000001; if (c2 < almostZero) return false; - float b = c1 / c2; + double b = c1 / c2; closestPoint = lineStart + v * b; return true; } -bool getPlaneLineIntersection(const osg::Vec4& plane, - const osg::Vec3& lineStart, const osg::Vec3& lineEnd, - osg::Vec3& isect) +bool getPlaneLineIntersection(const osg::Vec4d& plane, + const osg::Vec3d& lineStart, const osg::Vec3d& lineEnd, + osg::Vec3d& isect) { const double deltaX = lineEnd.x() - lineStart.x(); const double deltaY = lineEnd.y() - lineStart.y(); @@ -90,46 +90,46 @@ bool getPlaneLineIntersection(const osg::Vec4& plane, } bool getSphereLineIntersection(const osg::Sphere& sphere, - const osg::Vec3& lineStart, const osg::Vec3& lineEnd, - osg::Vec3& frontISect, osg::Vec3& backISect) + const osg::Vec3d& lineStart, const osg::Vec3d& lineEnd, + osg::Vec3d& frontISect, osg::Vec3d& backISect) { - osg::Vec3 lineDirection = lineEnd - lineStart; + osg::Vec3d lineDirection = lineEnd - lineStart; lineDirection.normalize(); - osg::Vec3 v = lineStart - sphere.getCenter(); - float B = 2.0f * (lineDirection * v); - float C = v * v - sphere.getRadius() * sphere.getRadius(); + osg::Vec3d v = lineStart - sphere.getCenter(); + double B = 2.0f * (lineDirection * v); + double C = v * v - sphere.getRadius() * sphere.getRadius(); - float discriminant = B * B - 4.0f * C; + double discriminant = B * B - 4.0f * C; if (discriminant < 0.0f) // Line and sphere don't intersect. return false; - float discriminantSqroot = sqrtf(discriminant); - float t0 = (-B - discriminantSqroot) * 0.5f; + double discriminantSqroot = sqrtf(discriminant); + double t0 = (-B - discriminantSqroot) * 0.5f; frontISect = lineStart + lineDirection * t0; - float t1 = (-B + discriminantSqroot) * 0.5f; + double t1 = (-B + discriminantSqroot) * 0.5f; backISect = lineStart + lineDirection * t1; return true; } -bool getUnitCylinderLineIntersection(const osg::Vec3& lineStart, const osg::Vec3& lineEnd, - osg::Vec3& isectFront, osg::Vec3& isectBack) +bool getUnitCylinderLineIntersection(const osg::Vec3d& lineStart, const osg::Vec3d& lineEnd, + osg::Vec3d& isectFront, osg::Vec3d& isectBack) { - osg::Vec3 dir = lineEnd - lineStart; + osg::Vec3d dir = lineEnd - lineStart; dir.normalize(); - float a = dir[0] * dir[0] + dir[1] * dir[1]; - float b = 2.0f * (lineStart[0] * dir[0] + lineStart[1] * dir[1]); - float c = lineStart[0] * lineStart[0] + lineStart[1] * lineStart[1] - 1; + double a = dir[0] * dir[0] + dir[1] * dir[1]; + double b = 2.0f * (lineStart[0] * dir[0] + lineStart[1] * dir[1]); + double c = lineStart[0] * lineStart[0] + lineStart[1] * lineStart[1] - 1; - float d = b*b - 4*a*c; + double d = b*b - 4*a*c; if (d < 0.0f) return false; - float dSqroot = sqrtf(d); - float t0, t1; + double dSqroot = sqrtf(d); + double t0, t1; if (b > 0.0f) { t0 = -(2.0f * c) / (dSqroot + b); @@ -147,22 +147,22 @@ bool getUnitCylinderLineIntersection(const osg::Vec3& lineStart, const osg::Vec3 } bool getCylinderLineIntersection(const osg::Cylinder& cylinder, - const osg::Vec3& lineStart, const osg::Vec3& lineEnd, - osg::Vec3& isectFront, osg::Vec3& isectBack) + const osg::Vec3d& lineStart, const osg::Vec3d& lineEnd, + osg::Vec3d& isectFront, osg::Vec3d& isectBack) { // Compute matrix transformation that takes the cylinder to a unit cylinder with Z-axis as it's axis and // (0,0,0) as it's center. - float oneOverRadius = 1.0f / cylinder.getRadius(); + double oneOverRadius = 1.0f / cylinder.getRadius(); osg::Matrix toUnitCylInZ = osg::Matrix::translate(-cylinder.getCenter()) * osg::Matrix::scale(oneOverRadius, oneOverRadius, oneOverRadius) * osg::Matrix(cylinder.getRotation().inverse()); // Transform the lineStart and lineEnd into the unit cylinder space. - osg::Vec3 unitCylLineStart = lineStart * toUnitCylInZ; - osg::Vec3 unitCylLineEnd = lineEnd * toUnitCylInZ; + osg::Vec3d unitCylLineStart = lineStart * toUnitCylInZ; + osg::Vec3d unitCylLineEnd = lineEnd * toUnitCylInZ; // Intersect line with unit cylinder. - osg::Vec3 unitCylIsectFront, unitCylIsectBack; + osg::Vec3d unitCylIsectFront, unitCylIsectBack; if (! getUnitCylinderLineIntersection(unitCylLineStart, unitCylLineEnd, unitCylIsectFront, unitCylIsectBack)) return false; @@ -174,19 +174,19 @@ bool getCylinderLineIntersection(const osg::Cylinder& cylinder, return true; } -osg::Vec3 getLocalEyeDirection(const osg::Vec3& eyeDir, const osg::Matrix& localToWorld) +osg::Vec3d getLocalEyeDirection(const osg::Vec3d& eyeDir, const osg::Matrix& localToWorld) { // To take a normal from world to local you need to transform it by the transpose of the inverse of the // world to local matrix. Pre-multiplying is equivalent to doing a post-multiplication of the transpose. - osg::Vec3 localEyeDir = localToWorld * eyeDir; + osg::Vec3d localEyeDir = localToWorld * eyeDir; localEyeDir.normalize(); return localEyeDir; } -osg::Plane computePlaneThruPointAndOrientedToEye(const osg::Vec3& eyeDir, const osg::Matrix& localToWorld, - const osg::Vec3& point, bool front) +osg::Plane computePlaneThruPointAndOrientedToEye(const osg::Vec3d& eyeDir, const osg::Matrix& localToWorld, + const osg::Vec3d& point, bool front) { - osg::Vec3 planeNormal = getLocalEyeDirection(eyeDir, localToWorld); + osg::Vec3d planeNormal = getLocalEyeDirection(eyeDir, localToWorld); if (! front) planeNormal = -planeNormal; osg::Plane plane; @@ -194,18 +194,18 @@ osg::Plane computePlaneThruPointAndOrientedToEye(const osg::Vec3& eyeDir, const return plane; } -osg::Plane computePlaneParallelToAxisAndOrientedToEye(const osg::Vec3& eyeDir, const osg::Matrix& localToWorld, - const osg::Vec3& axisDir, float radius, - osg::Vec3& planeLineStart, osg::Vec3& planeLineEnd, +osg::Plane computePlaneParallelToAxisAndOrientedToEye(const osg::Vec3d& eyeDir, const osg::Matrix& localToWorld, + const osg::Vec3d& axisDir, double radius, + osg::Vec3d& planeLineStart, osg::Vec3d& planeLineEnd, bool front) { - osg::Vec3 perpDir = axisDir ^ getLocalEyeDirection(eyeDir, localToWorld); - osg::Vec3 planeDir = perpDir ^ axisDir; + osg::Vec3d perpDir = axisDir ^ getLocalEyeDirection(eyeDir, localToWorld); + osg::Vec3d planeDir = perpDir ^ axisDir; planeDir.normalize(); if (! front) planeDir = -planeDir; - osg::Vec3 planePoint = planeDir * radius + axisDir; + osg::Vec3d planePoint = planeDir * radius + axisDir; osg::Plane plane; plane.set(planeDir, planePoint); @@ -239,7 +239,7 @@ LineProjector::~LineProjector() { } -bool LineProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) const +bool LineProjector::project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const { if (!_line->valid()) { @@ -252,15 +252,15 @@ bool LineProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) co objectLine->mult(*_line, getLocalToWorld()); // Get the near and far points for the mouse point. - osg::Vec3 nearPoint, farPoint; + osg::Vec3d nearPoint, farPoint; pi.getNearFarPoints(nearPoint,farPoint); osg::ref_ptr pointerLine = new osg::LineSegment(nearPoint,farPoint); - osg::Vec3 closestPtLine, closestPtProjWorkingLine; + osg::Vec3d closestPtLine, closestPtProjWorkingLine; if (! computeClosestPoints(*objectLine, *pointerLine, closestPtLine, closestPtProjWorkingLine)) return false; - osg::Vec3 localClosestPtLine = closestPtLine * getWorldToLocal(); + osg::Vec3d localClosestPtLine = closestPtLine * getWorldToLocal(); projectedPoint = localClosestPtLine; @@ -281,7 +281,7 @@ PlaneProjector::~PlaneProjector() { } -bool PlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) const +bool PlaneProjector::project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const { if (!_plane.valid()) { @@ -290,11 +290,11 @@ bool PlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) c } // Get the near and far points for the mouse point. - osg::Vec3 nearPoint, farPoint; + osg::Vec3d nearPoint, farPoint; pi.getNearFarPoints(nearPoint,farPoint); // Transform these points into local coordinates. - osg::Vec3 objectNearPoint, objectFarPoint; + osg::Vec3d objectNearPoint, objectFarPoint; objectNearPoint = nearPoint * getWorldToLocal(); objectFarPoint = farPoint * getWorldToLocal(); @@ -316,7 +316,7 @@ SphereProjector::~SphereProjector() { } -bool SphereProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) const +bool SphereProjector::project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const { if (!_sphere->valid()) { @@ -325,16 +325,16 @@ bool SphereProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) } // Get the near and far points for the mouse point. - osg::Vec3 nearPoint, farPoint; + osg::Vec3d nearPoint, farPoint; pi.getNearFarPoints(nearPoint,farPoint); // Transform these points into local coordinates. - osg::Vec3 objectNearPoint, objectFarPoint; + osg::Vec3d objectNearPoint, objectFarPoint; objectNearPoint = nearPoint * getWorldToLocal(); objectFarPoint = farPoint * getWorldToLocal(); // Find the intersection of the sphere with the line. - osg::Vec3 dontCare; + osg::Vec3d dontCare; if (_front) return getSphereLineIntersection(*_sphere, objectNearPoint, objectFarPoint, projectedPoint, dontCare); return getSphereLineIntersection(*_sphere, objectNearPoint, objectFarPoint, dontCare, projectedPoint); @@ -342,7 +342,7 @@ bool SphereProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) bool SphereProjector::isPointInFront(const PointerInfo& pi, const osg::Matrix& localToWorld) const { - osg::Vec3 centerToPoint = getSphere()->getCenter() - pi.getLocalIntersectPoint(); + osg::Vec3d centerToPoint = getSphere()->getCenter() - pi.getLocalIntersectPoint(); if (centerToPoint * getLocalEyeDirection(pi.getEyeDir(), localToWorld) < 0.0) return false; return true; @@ -362,7 +362,7 @@ SpherePlaneProjector::~SpherePlaneProjector() { } -osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnSphere, const osg::Vec3& p2, bool p2OnSphere, +osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3d& p1, bool p1OnSphere, const osg::Vec3d& p2, bool p2OnSphere, float radialFactor) const { if (p1OnSphere && p2OnSphere) @@ -379,10 +379,10 @@ osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnSphere osg::Quat rotation; rotation.makeRotate(p1 - getSphere()->getCenter(), p2 - getSphere()->getCenter()); - osg::Vec3 axis; double angle; + osg::Vec3d axis; double angle; rotation.getRotate(angle, axis); - osg::Vec3 realAxis; + osg::Vec3d realAxis; if (axis * _plane.getNormal() > 0.0f) realAxis = _plane.getNormal(); else @@ -390,16 +390,16 @@ osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnSphere osg::Quat rollRotation(angle, realAxis); - osg::Vec3 diff1 = p1 - getSphere()->getCenter(); - osg::Vec3 diff2 = p2 - getSphere()->getCenter(); - float d = diff2.length() - diff1.length(); + osg::Vec3d diff1 = p1 - getSphere()->getCenter(); + osg::Vec3d diff2 = p2 - getSphere()->getCenter(); + double d = diff2.length() - diff1.length(); - float theta = d / getSphere()->getRadius(); + double theta = d / getSphere()->getRadius(); if (fabs(theta) < 0.000001 || fabs(theta) > 1.0) return rollRotation; diff1.normalize(); - osg::Vec3 pullAxis = diff1 ^ _plane.getNormal(); + osg::Vec3d pullAxis = diff1 ^ _plane.getNormal(); pullAxis.normalize(); osg::Quat pullRotation(radialFactor * theta, pullAxis); @@ -408,9 +408,9 @@ osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnSphere } else { - const osg::Vec3& planePoint = getSphere()->getCenter(); + const osg::Vec3d& planePoint = getSphere()->getCenter(); - osg::Vec3 intersection, dontCare; + osg::Vec3d intersection, dontCare; if (p1OnSphere) getSphereLineIntersection(*getSphere(), p2, planePoint, intersection, dontCare); else @@ -425,7 +425,7 @@ osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnSphere } } -bool SpherePlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) const +bool SpherePlaneProjector::project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const { if (!_sphere->valid()) { @@ -434,16 +434,16 @@ bool SpherePlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPo } // Get the near and far points for the mouse point. - osg::Vec3 nearPoint, farPoint; + osg::Vec3d nearPoint, farPoint; pi.getNearFarPoints(nearPoint,farPoint); // Transform these points into local coordinates. - osg::Vec3 objectNearPoint, objectFarPoint; + osg::Vec3d objectNearPoint, objectFarPoint; objectNearPoint = nearPoint * getWorldToLocal(); objectFarPoint = farPoint * getWorldToLocal(); // Find the intersection of the sphere with the line. - osg::Vec3 sphereIntersection, dontCare; + osg::Vec3d sphereIntersection, dontCare; bool hitSphere = false; if (_front) hitSphere = getSphereLineIntersection(*_sphere, objectNearPoint, objectFarPoint, sphereIntersection, dontCare); @@ -454,7 +454,7 @@ bool SpherePlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPo _plane = computePlaneThruPointAndOrientedToEye(pi.getEyeDir(), getLocalToWorld(), getSphere()->getCenter(), _front); // Find the intersection on the plane. - osg::Vec3 planeIntersection; + osg::Vec3d planeIntersection; if (hitSphere) { if (! getPlaneLineIntersection(_plane.asVec4(), sphereIntersection, sphereIntersection + _plane.getNormal(), planeIntersection)) @@ -467,7 +467,7 @@ bool SpherePlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPo } // Distance from the plane intersection point to the center of the sphere. - float dist = (planeIntersection - getSphere()->getCenter()).length(); + double dist = (planeIntersection - getSphere()->getCenter()).length(); // If the distance is less that the sphere radius choose the sphere intersection else choose // the plane intersection. @@ -498,7 +498,7 @@ CylinderProjector::~CylinderProjector() { } -bool CylinderProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) const +bool CylinderProjector::project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const { if (!_cylinder.valid()) { @@ -508,26 +508,26 @@ bool CylinderProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint } // Get the near and far points for the mouse point. - osg::Vec3 nearPoint, farPoint; + osg::Vec3d nearPoint, farPoint; pi.getNearFarPoints(nearPoint,farPoint); // Transform these points into local coordinates. - osg::Vec3 objectNearPoint, objectFarPoint; + osg::Vec3d objectNearPoint, objectFarPoint; objectNearPoint = nearPoint * getWorldToLocal(); objectFarPoint = farPoint * getWorldToLocal(); // Find the intersection of the sphere with the line. - osg::Vec3 dontCare; + osg::Vec3d dontCare; return getCylinderLineIntersection(*_cylinder, objectNearPoint, objectFarPoint, projectedPoint, dontCare); } bool CylinderProjector::isPointInFront(const PointerInfo& pi, const osg::Matrix& localToWorld) const { - osg::Vec3 closestPointOnAxis; + osg::Vec3d closestPointOnAxis; computeClosestPointOnLine(getCylinder()->getCenter(), getCylinder()->getCenter() + _cylinderAxis, pi.getLocalIntersectPoint(), closestPointOnAxis); - osg::Vec3 perpPoint = pi.getLocalIntersectPoint() - closestPointOnAxis; + osg::Vec3d perpPoint = pi.getLocalIntersectPoint() - closestPointOnAxis; if (perpPoint * getLocalEyeDirection(pi.getEyeDir(), localToWorld) < 0.0) return false; return true; @@ -545,7 +545,7 @@ CylinderPlaneProjector::~CylinderPlaneProjector() { } -bool CylinderPlaneProjector::project(const PointerInfo& pi, osg::Vec3& projectedPoint) const +bool CylinderPlaneProjector::project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const { if (!_cylinder.valid()) { @@ -555,25 +555,25 @@ bool CylinderPlaneProjector::project(const PointerInfo& pi, osg::Vec3& projected } // Get the near and far points for the mouse point. - osg::Vec3 nearPoint, farPoint; + osg::Vec3d nearPoint, farPoint; pi.getNearFarPoints(nearPoint,farPoint); // Transform these points into local coordinates. - osg::Vec3 objectNearPoint, objectFarPoint; + osg::Vec3d objectNearPoint, objectFarPoint; objectNearPoint = nearPoint * getWorldToLocal(); objectFarPoint = farPoint * getWorldToLocal(); // Find the intersection of the sphere with the line. - osg::Vec3 cylIntersection; + osg::Vec3d cylIntersection; bool hitCylinder = false; if (_front) { - osg::Vec3 dontCare; + osg::Vec3d dontCare; hitCylinder = getCylinderLineIntersection(*_cylinder, objectNearPoint, objectFarPoint, cylIntersection, dontCare); } else { - osg::Vec3 dontCare; + osg::Vec3d dontCare; hitCylinder = getCylinderLineIntersection(*_cylinder, objectNearPoint, objectFarPoint, dontCare, cylIntersection); } @@ -583,20 +583,20 @@ bool CylinderPlaneProjector::project(const PointerInfo& pi, osg::Vec3& projected _front); // Find the intersection on the plane. - osg::Vec3 planeIntersection; + osg::Vec3d planeIntersection; getPlaneLineIntersection(_plane.asVec4(), objectNearPoint, objectFarPoint, planeIntersection); if (hitCylinder) { - osg::Vec3 projectIntersection; + osg::Vec3d projectIntersection; getPlaneLineIntersection(_plane.asVec4(), cylIntersection, cylIntersection + _plane.getNormal(), projectIntersection); - osg::Vec3 closestPointToCylAxis; + osg::Vec3d closestPointToCylAxis; computeClosestPointOnLine(getCylinder()->getCenter(), getCylinder()->getCenter() + _cylinderAxis, projectIntersection, closestPointToCylAxis); // Distance from the plane intersection point to the closest point on the cylinder axis. - float dist = (projectIntersection - closestPointToCylAxis).length(); + double dist = (projectIntersection - closestPointToCylAxis).length(); if (dist < getCylinder()->getRadius()) { @@ -619,45 +619,45 @@ bool CylinderPlaneProjector::project(const PointerInfo& pi, osg::Vec3& projected return true; } -osg::Quat CylinderPlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnCyl, const osg::Vec3& p2, bool p2OnCyl) const +osg::Quat CylinderPlaneProjector::getRotation(const osg::Vec3d& p1, bool p1OnCyl, const osg::Vec3d& p2, bool p2OnCyl) const { if (p1OnCyl && p2OnCyl) { - osg::Vec3 closestPointToCylAxis1, closestPointToCylAxis2; + osg::Vec3d closestPointToCylAxis1, closestPointToCylAxis2; computeClosestPointOnLine(getCylinder()->getCenter(), getCylinder()->getCenter() + _cylinderAxis * getCylinder()->getHeight(), p1, closestPointToCylAxis1); computeClosestPointOnLine(getCylinder()->getCenter(), getCylinder()->getCenter() + _cylinderAxis * getCylinder()->getHeight(), p2, closestPointToCylAxis2); - osg::Vec3 v1 = p1 - closestPointToCylAxis1; - osg::Vec3 v2 = p2 - closestPointToCylAxis2; + osg::Vec3d v1 = p1 - closestPointToCylAxis1; + osg::Vec3d v2 = p2 - closestPointToCylAxis2; - float cosAngle = v1 * v2 / (v1.length() * v2.length()); + double cosAngle = v1 * v2 / (v1.length() * v2.length()); if (cosAngle > 1.0 || cosAngle < -1.0) return osg::Quat(); - float angle = acosf(cosAngle); - osg::Vec3 rotAxis = v1 ^ v2; + double angle = acosf(cosAngle); + osg::Vec3d rotAxis = v1 ^ v2; return osg::Quat(angle, rotAxis); } else if (!p1OnCyl && !p2OnCyl) { - osg::Vec3 closestPointToPlaneLine1, closestPointToPlaneLine2; + osg::Vec3d closestPointToPlaneLine1, closestPointToPlaneLine2; computeClosestPointOnLine(_planeLineStart, _planeLineEnd, p1, closestPointToPlaneLine1); computeClosestPointOnLine(_planeLineStart, _planeLineEnd, p2, closestPointToPlaneLine2); - osg::Vec3 v1 = p1 - closestPointToPlaneLine1; - osg::Vec3 v2 = p2 - closestPointToPlaneLine2; + osg::Vec3d v1 = p1 - closestPointToPlaneLine1; + osg::Vec3d v2 = p2 - closestPointToPlaneLine2; - osg::Vec3 diff = v2 - v1; - float d = diff.length(); + osg::Vec3d diff = v2 - v1; + double d = diff.length(); - float angle = (getCylinder()->getRadius() == 0.0) ? 0.0 : (d / getCylinder()->getRadius()); - osg::Vec3 rotAxis = _plane.getNormal() ^ v1; + double angle = (getCylinder()->getRadius() == 0.0) ? 0.0 : (d / getCylinder()->getRadius()); + osg::Vec3d rotAxis = _plane.getNormal() ^ v1; if (v2.length() > v1.length()) return osg::Quat(angle, rotAxis); @@ -667,15 +667,15 @@ osg::Quat CylinderPlaneProjector::getRotation(const osg::Vec3& p1, bool p1OnCyl, } else { - osg::Vec3 offCylinderPt = (p1OnCyl) ? p2 : p1; + osg::Vec3d offCylinderPt = (p1OnCyl) ? p2 : p1; - osg::Vec3 linePtNearest; + osg::Vec3d linePtNearest; computeClosestPointOnLine(_planeLineStart, _planeLineEnd, offCylinderPt, linePtNearest); - osg::Vec3 dirToOffCylinderPt = offCylinderPt - linePtNearest; + osg::Vec3d dirToOffCylinderPt = offCylinderPt - linePtNearest; dirToOffCylinderPt.normalize(); - osg::Vec3 ptOnCylinder = linePtNearest + dirToOffCylinderPt * getCylinder()->getRadius(); + osg::Vec3d ptOnCylinder = linePtNearest + dirToOffCylinderPt * getCylinder()->getRadius(); if (p1OnCyl) return (getRotation(p1, true, ptOnCylinder, true) * diff --git a/src/osgManipulator/RotateCylinderDragger.cpp b/src/osgManipulator/RotateCylinderDragger.cpp index 9c85e3274..0eeaa6141 100644 --- a/src/osgManipulator/RotateCylinderDragger.cpp +++ b/src/osgManipulator/RotateCylinderDragger.cpp @@ -58,7 +58,7 @@ bool RotateCylinderDragger::handle(const PointerInfo& pointer, const osgGA::GUIE else _projector->setFront(false); - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { // Generate the motion command. @@ -92,11 +92,11 @@ bool RotateCylinderDragger::handle(const PointerInfo& pointer, const osgGA::GUIE osg::Matrix localToWorld = osg::Matrix(_prevRotation) * _startLocalToWorld; _projector->setLocalToWorld(localToWorld); - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { - osg::Vec3 prevProjectedPoint = _prevWorldProjPt * _projector->getWorldToLocal(); - osg::Quat deltaRotation = _projector->getRotation(prevProjectedPoint, _prevPtOnCylinder, + osg::Vec3d prevProjectedPoint = _prevWorldProjPt * _projector->getWorldToLocal(); + osg::Quat deltaRotation = _projector->getRotation(prevProjectedPoint, _prevPtOnCylinder, projectedPoint, _projector->isProjectionOnCylinder()); osg::Quat rotation = deltaRotation * _prevRotation; diff --git a/src/osgManipulator/RotateSphereDragger.cpp b/src/osgManipulator/RotateSphereDragger.cpp index 381b852fc..7e65db8d5 100644 --- a/src/osgManipulator/RotateSphereDragger.cpp +++ b/src/osgManipulator/RotateSphereDragger.cpp @@ -59,7 +59,7 @@ bool RotateSphereDragger::handle(const PointerInfo& pointer, const osgGA::GUIEve else _projector->setFront(false); - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { // Generate the motion command. @@ -94,11 +94,11 @@ bool RotateSphereDragger::handle(const PointerInfo& pointer, const osgGA::GUIEve osg::Matrix localToWorld = osg::Matrix(_prevRotation) * _startLocalToWorld; _projector->setLocalToWorld(localToWorld); - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { - osg::Vec3 prevProjectedPoint = _prevWorldProjPt * _projector->getWorldToLocal(); - osg::Quat deltaRotation = _projector->getRotation(prevProjectedPoint, _prevPtOnSphere, + osg::Vec3d prevProjectedPoint = _prevWorldProjPt * _projector->getWorldToLocal(); + osg::Quat deltaRotation = _projector->getRotation(prevProjectedPoint, _prevPtOnSphere, projectedPoint, _projector->isProjectionOnSphere(),1.0f); osg::Quat rotation = deltaRotation * _prevRotation; diff --git a/src/osgManipulator/Scale1DDragger.cpp b/src/osgManipulator/Scale1DDragger.cpp index 716161cab..118c47706 100644 --- a/src/osgManipulator/Scale1DDragger.cpp +++ b/src/osgManipulator/Scale1DDragger.cpp @@ -26,11 +26,11 @@ using namespace osgManipulator; namespace { -float computeScale(const osg::Vec3& startProjectedPoint, - const osg::Vec3& projectedPoint, float scaleCenter) +double computeScale(const osg::Vec3d& startProjectedPoint, + const osg::Vec3d& projectedPoint, double scaleCenter) { - float denom = startProjectedPoint[0] - scaleCenter; - float scale = denom ? (projectedPoint[0] - scaleCenter)/denom : 1.0; + double denom = startProjectedPoint[0] - scaleCenter; + double scale = denom ? (projectedPoint[0] - scaleCenter)/denom : 1.0; return scale; } @@ -38,7 +38,7 @@ float computeScale(const osg::Vec3& startProjectedPoint, Scale1DDragger::Scale1DDragger(ScaleMode scaleMode) : Dragger(), _minScale(0.001), _scaleMode(scaleMode) { - _projector = new LineProjector(osg::Vec3(-0.5f,0.0f,0.0f),osg::Vec3(0.5f,0.0f,0.0f)); + _projector = new LineProjector(osg::Vec3d(-0.5,0.0,0.0),osg::Vec3d(0.5,0.0,0.0)); setColor(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)); setPickColor(osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f)); } @@ -65,7 +65,7 @@ bool Scale1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda if (_projector->project(pointer, _startProjectedPoint)) { - _scaleCenter = 0.0f; + _scaleCenter = 0.0; if (_scaleMode == SCALE_WITH_OPPOSITE_HANDLE_AS_PIVOT) { if ( pointer.contains(_leftHandleNode.get()) ) @@ -97,18 +97,18 @@ bool Scale1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda // Pick move. case (osgGA::GUIEventAdapter::DRAG): { - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { // Generate the motion command. osg::ref_ptr cmd = new Scale1DCommand(); // Compute scale. - float scale = computeScale(_startProjectedPoint,projectedPoint,_scaleCenter); + double scale = computeScale(_startProjectedPoint,projectedPoint,_scaleCenter); if (scale < getMinScale()) scale = getMinScale(); // Snap the referencePoint to the line start or line end depending on which is closer. - float referencePoint = _startProjectedPoint[0]; + double referencePoint = _startProjectedPoint[0]; if (fabs(_projector->getLineStart()[0] - referencePoint) < fabs(_projector->getLineEnd()[0] - referencePoint)) referencePoint = _projector->getLineStart()[0]; diff --git a/src/osgManipulator/Scale2DDragger.cpp b/src/osgManipulator/Scale2DDragger.cpp index 4f64be872..56c6cd3a0 100644 --- a/src/osgManipulator/Scale2DDragger.cpp +++ b/src/osgManipulator/Scale2DDragger.cpp @@ -26,11 +26,11 @@ using namespace osgManipulator; namespace { -osg::Vec2 computeScale(const osg::Vec3& startProjectedPoint, - const osg::Vec3& projectedPoint, - const osg::Vec2& scaleCenter) +osg::Vec2d computeScale(const osg::Vec3d& startProjectedPoint, + const osg::Vec3d& projectedPoint, + const osg::Vec2d& scaleCenter) { - osg::Vec2 scale(1.0,1.0); + osg::Vec2d scale(1.0,1.0); if ((startProjectedPoint[0] - scaleCenter[0]) != 0.0) scale[0] = (projectedPoint[0] - scaleCenter[0])/(startProjectedPoint[0] - scaleCenter[0]); if ((startProjectedPoint[2] - scaleCenter[1]) != 0.0) @@ -126,11 +126,11 @@ bool Scale2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda // Pick move. case (osgGA::GUIEventAdapter::DRAG): { - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { // Compute scale. - osg::Vec2 scale = computeScale(_startProjectedPoint,projectedPoint,_scaleCenter); + osg::Vec2d scale = computeScale(_startProjectedPoint,projectedPoint,_scaleCenter); if (scale[0] < getMinScale()[0]) scale[0] = getMinScale()[0]; if (scale[1] < getMinScale()[1]) scale[1] = getMinScale()[1]; diff --git a/src/osgManipulator/Translate1DDragger.cpp b/src/osgManipulator/Translate1DDragger.cpp index 2681cf932..f777214b0 100644 --- a/src/osgManipulator/Translate1DDragger.cpp +++ b/src/osgManipulator/Translate1DDragger.cpp @@ -30,7 +30,7 @@ Translate1DDragger::Translate1DDragger() : Dragger(), _checkForNodeInNodePath(tr setPickColor(osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f)); } -Translate1DDragger::Translate1DDragger(const osg::Vec3& s, const osg::Vec3& e) : Dragger(), _checkForNodeInNodePath(true) +Translate1DDragger::Translate1DDragger(const osg::Vec3d& s, const osg::Vec3d& e) : Dragger(), _checkForNodeInNodePath(true) { _projector = new LineProjector(s,e); setColor(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)); @@ -86,7 +86,7 @@ bool Translate1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven // Pick move. case (osgGA::GUIEventAdapter::DRAG): { - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { // Generate the motion command. @@ -111,7 +111,7 @@ bool Translate1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven // Pick finish. case (osgGA::GUIEventAdapter::RELEASE): { - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { osg::ref_ptr cmd = new TranslateInLineCommand(_projector->getLineStart(), diff --git a/src/osgManipulator/Translate2DDragger.cpp b/src/osgManipulator/Translate2DDragger.cpp index 28137bd71..2d1163b1e 100644 --- a/src/osgManipulator/Translate2DDragger.cpp +++ b/src/osgManipulator/Translate2DDragger.cpp @@ -87,7 +87,7 @@ bool Translate2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven // Pick move. case (osgGA::GUIEventAdapter::DRAG): { - osg::Vec3 projectedPoint; + osg::Vec3d projectedPoint; if (_projector->project(pointer, projectedPoint)) { // Generate the motion command.