From 61cb27806fb2b0f901c668bc3132dd6f0a82ea85 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 11 Feb 2004 10:19:52 +0000 Subject: [PATCH] From Brad Christiansen, fix to enable AutoTransform to keep track of window size/perspective changes --- include/osg/AutoTransform | 5 ++++- src/osg/AutoTransform.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/osg/AutoTransform b/include/osg/AutoTransform index 64960d3ae..6e15d9715 100644 --- a/include/osg/AutoTransform +++ b/include/osg/AutoTransform @@ -89,13 +89,16 @@ class SG_EXPORT AutoTransform : public Transform mutable bool _firstTimeToInitEyePoint; mutable osg::Vec3 _previousEyePoint; mutable int _previousWidth; - mutable int _previousHeight; + mutable int _previousHeight; + mutable osg::Matrix _previousProjection; void computeMatrix() const; mutable bool _matrixDirty; mutable osg::Matrix _cachedMatrix; + + }; } diff --git a/src/osg/AutoTransform.cpp b/src/osg/AutoTransform.cpp index f5d6870a8..8bc5b313f 100644 --- a/src/osg/AutoTransform.cpp +++ b/src/osg/AutoTransform.cpp @@ -107,7 +107,9 @@ void AutoTransform::accept(NodeVisitor& nv) height = viewport->height(); } - osg::Vec3 eyePoint = cs->getEyeLocal(); + const osg::Vec3& eyePoint = cs->getEyeLocal(); + + const osg::Matrix& projection = cs->getProjectionMatrix(); bool doUpdate = _firstTimeToInitEyePoint; if (!_firstTimeToInitEyePoint) @@ -120,7 +122,11 @@ void AutoTransform::accept(NodeVisitor& nv) else if (width!=_previousWidth || height!=_previousHeight) { doUpdate = true; - } + } + else if (projection != _previousProjection) + { + doUpdate = true; + } } _firstTimeToInitEyePoint = false; @@ -143,6 +149,7 @@ void AutoTransform::accept(NodeVisitor& nv) _previousEyePoint = eyePoint; _previousWidth = width; _previousHeight = height; + _previousProjection = projection; _matrixDirty = true; }