From dede1718868be15c94fad52672c892000bcec9bb Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Fri, 25 Mar 2016 21:35:34 -0400 Subject: [PATCH] Fix the secondary navigation method for OrbitCameraController. --- apps/opencs/view/render/cameracontroller.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/render/cameracontroller.cpp b/apps/opencs/view/render/cameracontroller.cpp index 5941cfb1e..518db2076 100644 --- a/apps/opencs/view/render/cameracontroller.cpp +++ b/apps/opencs/view/render/cameracontroller.cpp @@ -520,8 +520,14 @@ namespace CSVRender void OrbitCameraController::translate(const osg::Vec3d& offset) { - mCenter += offset; - getCamera()->getViewMatrix() *= osg::Matrixd::translate(offset); + osg::Vec3d eye, center, up; + getCamera()->getViewMatrixAsLookAt(eye, center, up); + + osg::Vec3d newOffset = getCamera()->getViewMatrix().getRotate().inverse() * offset; + mCenter += newOffset; + eye += newOffset; + + getCamera()->setViewMatrixAsLookAt(eye, mCenter, up); } void OrbitCameraController::zoom(double value)