diff --git a/src/Gui/Inventor/SoAutoZoomTranslation.cpp b/src/Gui/Inventor/SoAutoZoomTranslation.cpp index 4b61003c11..9363bd224c 100644 --- a/src/Gui/Inventor/SoAutoZoomTranslation.cpp +++ b/src/Gui/Inventor/SoAutoZoomTranslation.cpp @@ -100,8 +100,15 @@ void SoAutoZoomTranslation::GLRender(SoGLRenderAction * action) void SoAutoZoomTranslation::doAction(SoAction * action) { float sf = this->getScaleFactor(action); - SoModelMatrixElement::scaleBy(action->getState(), this, - SbVec3f(sf,sf,sf)); + auto state = action->getState(); + SbRotation r,so; + SbVec3f s,t; + SbMatrix matrix = SoModelMatrixElement::get(action->getState()); + matrix.getTransform(t,r,s,so); + matrix.multVecMatrix(SbVec3f(0,0,0),t); + // reset current model scale factor + matrix.setTransform(t,r,SbVec3f(sf,sf,sf)); + SoModelMatrixElement::set(state,this,matrix); } // set the auto scale factor. @@ -119,14 +126,15 @@ void SoAutoZoomTranslation::getMatrix(SoGetMatrixAction * action) { float sf = this->getScaleFactor(action); - SbVec3f scalevec = SbVec3f(sf,sf,sf); - SbMatrix m; + SbMatrix &m = action->getMatrix(); - m.setScale(scalevec); - action->getMatrix().multLeft(m); + SbRotation r,so; + SbVec3f s,t; + m.getTransform(t,r,s,so); + m.multVecMatrix(SbVec3f(0,0,0),t); + m.setTransform(t,r,SbVec3f(sf,sf,sf)); - m.setScale(SbVec3f(1.0f / scalevec[0], 1.0f / scalevec[1], 1.0f / scalevec[2])); - action->getInverse().multRight(m); + action->getInverse() = m.inverse(); } void SoAutoZoomTranslation::callback(SoCallbackAction * action)