From 4f72be65dcf83488eaddfd2fac7a1202718d6510 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 9 Apr 2009 14:31:15 +0000 Subject: [PATCH] From Cory Riddell, "I added an _allowThrow bool and get / set accessors to TrackballManipulator. The purpose of this is to disable throwing when you release the mouse button while moving the mouse. The default settings is true (ie, allow throw). The two source files are attached. " --- include/osgGA/TrackballManipulator | 7 +++++++ src/osgGA/TrackballManipulator.cpp | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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