diff --git a/include/osgViewer/View b/include/osgViewer/View index e9b41b2c2..24eff3e35 100644 --- a/include/osgViewer/View +++ b/include/osgViewer/View @@ -98,8 +98,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /* Get the const View's EventQueue.*/ const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); } - /** Set the CameraManipulator that moves the View's master Camera position in response to events.*/ - void setCameraManipulator(osgGA::MatrixManipulator* manipulator); + /** Set the CameraManipulator that moves the View's master Camera position in response to events. + * The parameter resetPosition determines whether manipulator is set to its home position.*/ + void setCameraManipulator(osgGA::MatrixManipulator* manipulator, bool resetPosition = true); /** Get the View's CameraManipulator.*/ osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); } diff --git a/src/osgViewer/View.cpp b/src/osgViewer/View.cpp index a547e232f..bdc0ded7b 100644 --- a/src/osgViewer/View.cpp +++ b/src/osgViewer/View.cpp @@ -338,7 +338,7 @@ const osgDB::ImagePager* View::getImagePager() const } -void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator) +void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator, bool resetPosition) { _cameraManipulator = manipulator; @@ -348,9 +348,11 @@ void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator) if (getSceneData()) _cameraManipulator->setNode(getSceneData()); - osg::ref_ptr dummyEvent = _eventQueue->createEvent(); - - _cameraManipulator->home(*dummyEvent, *this); + if (resetPosition) + { + osg::ref_ptr dummyEvent = _eventQueue->createEvent(); + _cameraManipulator->home(*dummyEvent, *this); + } } }