diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index b6ace82be8..1329158e79 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -97,6 +97,7 @@ private: glm::dvec3 _previousFocusNodePosition; glm::dquat _previousFocusNodeRotation; double _currentCameraToSurfaceDistance; + bool _directlySetStereoDistance = false; Interpolator _rotateToFocusNodeInterpolator; Interpolator _cameraToSurfaceDistanceInterpolator; diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index f95c9fb7b7..607d51980d 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -324,10 +324,15 @@ void OrbitalNavigator::updateCameraStateFromMouseStates(Camera& camera, double d double targetCameraToSurfaceDistance = glm::length( cameraToSurfaceVector(camPos, centerPos, posHandle) ); - _currentCameraToSurfaceDistance = interpolateCameraToSurfaceDistance( - deltaTime, - _currentCameraToSurfaceDistance, - targetCameraToSurfaceDistance); + if (_directlySetStereoDistance) { + _currentCameraToSurfaceDistance = targetCameraToSurfaceDistance; + _directlySetStereoDistance = false; + } else { + _currentCameraToSurfaceDistance = interpolateCameraToSurfaceDistance( + deltaTime, + _currentCameraToSurfaceDistance, + targetCameraToSurfaceDistance); + } camera.setScaling( _stereoscopicDepthOfFocusSurface / @@ -357,11 +362,15 @@ glm::dvec3 OrbitalNavigator::cameraToSurfaceVector( } void OrbitalNavigator::setFocusNode(SceneGraphNode* focusNode) { + if (!_focusNode) { + _directlySetStereoDistance = true; + } + _focusNode = focusNode; - if (_focusNode != nullptr) { - _previousFocusNodePosition = _focusNode->worldPosition(); - _previousFocusNodeRotation = glm::quat_cast(_focusNode->worldRotationMatrix()); + if (focusNode != nullptr) { + _previousFocusNodePosition = focusNode->worldPosition(); + _previousFocusNodeRotation = glm::quat_cast(focusNode->worldRotationMatrix()); } }