diff --git a/include/osgGA/TrackballManipulator b/include/osgGA/TrackballManipulator index 024c18da5..32202e273 100644 --- a/include/osgGA/TrackballManipulator +++ b/include/osgGA/TrackballManipulator @@ -108,6 +108,12 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator /** Get the size of the trackball. */ float getTrackballSize() const { return _trackballSize; } + + /** Set the 'allow throw' flag. Releasing the mouse button while moving the camera results in a throw. */ + void setAllowThrow(bool allowThrow) { _allowThrow = allowThrow; } + + /** Returns true if the camera can be thrown, false otherwise. This defaults to true. */ + bool getAllowThrow() const { return _allowThrow; } protected: virtual ~TrackballManipulator(); @@ -140,6 +146,7 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator double _modelScale; double _minimumZoomScale; + bool _allowThrow; bool _thrown; osg::Vec3d _center; diff --git a/src/osgGA/TrackballManipulator.cpp b/src/osgGA/TrackballManipulator.cpp index d5532bb9b..8ca46ad00 100644 --- a/src/osgGA/TrackballManipulator.cpp +++ b/src/osgGA/TrackballManipulator.cpp @@ -10,6 +10,7 @@ TrackballManipulator::TrackballManipulator() { _modelScale = 0.01f; _minimumZoomScale = 0.05f; + _allowThrow = true; _thrown = false; _distance = 1.0f; @@ -80,7 +81,7 @@ bool TrackballManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us switch(ea.getEventType()) { case(GUIEventAdapter::FRAME): - if (_thrown) + if (_thrown && _allowThrow) { if (calcMovement()) us.requestRedraw(); } @@ -117,7 +118,7 @@ bool TrackballManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us { us.requestRedraw(); us.requestContinuousUpdate(true); - _thrown = true; + _thrown = _allowThrow; } } else