diff --git a/include/osg/AutoTransform b/include/osg/AutoTransform index 7dc15086b..29129747e 100644 --- a/include/osg/AutoTransform +++ b/include/osg/AutoTransform @@ -119,6 +119,7 @@ class SG_EXPORT AutoTransform : public Transform mutable Vec3 _scale; mutable bool _firstTimeToInitEyePoint; mutable osg::Vec3 _previousEyePoint; + mutable osg::Vec3 _previousLocalUp; mutable int _previousWidth; mutable int _previousHeight; mutable osg::Matrix _previousProjection; @@ -129,9 +130,6 @@ class SG_EXPORT AutoTransform : public Transform mutable bool _matrixDirty; mutable osg::Matrix _cachedMatrix; - - - }; } diff --git a/src/osg/AutoTransform.cpp b/src/osg/AutoTransform.cpp index c98d9ec68..cba4c86fe 100644 --- a/src/osg/AutoTransform.cpp +++ b/src/osg/AutoTransform.cpp @@ -113,6 +113,7 @@ void AutoTransform::accept(NodeVisitor& nv) } osg::Vec3 eyePoint = cs->getEyeLocal(); + osg::Vec3 localUp = cs->getUpLocal(); osg::Vec3 position = getPosition(); const osg::Matrix& projection = cs->getProjectionMatrix(); @@ -125,6 +126,13 @@ void AutoTransform::accept(NodeVisitor& nv) { doUpdate = true; } + osg::Vec3 dupv = _previousLocalUp-localUp; + // rotating the camera only affects ROTATE_TO_* + if (_autoRotateMode && + dupv.length2()>getAutoUpdateEyeMovementTolerance()) + { + doUpdate = true; + } else if (width!=_previousWidth || height!=_previousHeight) { doUpdate = true; @@ -159,13 +167,14 @@ void AutoTransform::accept(NodeVisitor& nv) { osg::Vec3 PosToEye = _position - eyePoint; osg::Matrix lookto = osg::Matrix::lookAt( - osg::Vec3(0,0,0), PosToEye, cs->getUpLocal()); + osg::Vec3(0,0,0), PosToEye, localUp); Quat q; q.set(osg::Matrix::inverse(lookto)); setRotation(q); } _previousEyePoint = eyePoint; + _previousLocalUp = localUp; _previousWidth = width; _previousHeight = height; _previousProjection = projection;