From fd007dcfd6689e69f2df53fd8bb89091729023de Mon Sep 17 00:00:00 2001 From: Rexbas Date: Sun, 22 Oct 2023 18:27:19 +0200 Subject: [PATCH] Gui: Set exact orientation when animation is finished --- src/Gui/NavigationAnimation.cpp | 20 ++++++++++++++++++++ src/Gui/NavigationAnimation.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/Gui/NavigationAnimation.cpp b/src/Gui/NavigationAnimation.cpp index e6f898d374..646d063829 100644 --- a/src/Gui/NavigationAnimation.cpp +++ b/src/Gui/NavigationAnimation.cpp @@ -97,6 +97,23 @@ void FixedTimeAnimation::update(const QVariant& value) prevTranslation = translation; } +/** + * @param finished True when the animation is finished, false when interrupted + */ +void FixedTimeAnimation::onStop(bool finished) +{ + if (finished) { + SoCamera* camera = navigation->getCamera(); + if (!camera) { + return; + } + + // Set exact target orientation + camera->orientation = targetOrientation; + camera->position = camera->position.getValue() + targetTranslation - prevTranslation; + } +} + /** * @param navigation The navigation style * @param axis The rotation axis in screen coordinates @@ -137,6 +154,9 @@ void SpinningAnimation::update(const QVariant& value) prevAngle = value.toFloat(); } +/** + * @param finished True when the animation is finished, false when interrupted + */ void SpinningAnimation::onStop(bool finished) { if (navigation->getViewingMode() != NavigationStyle::SPINNING) { diff --git a/src/Gui/NavigationAnimation.h b/src/Gui/NavigationAnimation.h index 3eddf2b90b..ce98e000af 100644 --- a/src/Gui/NavigationAnimation.h +++ b/src/Gui/NavigationAnimation.h @@ -77,6 +77,7 @@ private: void initialize() override; void update(const QVariant& value) override; + void onStop(bool finished) override; }; class GuiExport SpinningAnimation : public NavigationAnimation