From David Fries, "I added code to also check the local up vector, but
only if one of the rotation modes is selected, because autoscale isn't affected by the camera rotations. "
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user