From 045e4fcaa376e80456c9016a5094f1b944a20f3f Mon Sep 17 00:00:00 2001 From: Ylva Selling Date: Wed, 14 Jun 2023 18:23:43 -0400 Subject: [PATCH] =?UTF-8?q?Add=20property=20to=20make=20it=20possible=20to?= =?UTF-8?q?=20set=20if=20the=20browser=20display=20copies=E2=80=A6=20(#277?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add property to make it possible to set if the browser display copies should animate while the target is moving * Update modules/skybrowser/src/targetbrowserpair.cpp Co-authored-by: Alexander Bock --------- Co-authored-by: Alexander Bock --- .../include/screenspaceskybrowser.h | 2 ++ .../skybrowser/src/screenspaceskybrowser.cpp | 20 +++++++++++++++++++ modules/skybrowser/src/targetbrowserpair.cpp | 5 ++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/skybrowser/include/screenspaceskybrowser.h b/modules/skybrowser/include/screenspaceskybrowser.h index a4b1e91620..13d41db2a8 100644 --- a/modules/skybrowser/include/screenspaceskybrowser.h +++ b/modules/skybrowser/include/screenspaceskybrowser.h @@ -50,6 +50,7 @@ public: glm::dvec2 fineTuneVector(const glm::dvec2& drag); bool isInitialized() const; bool isPointingSpacecraft() const; + bool shouldUpdateWhileTargetAnimates() const; double setVerticalFovWithScroll(float scroll); void setIdInBrowser() const; @@ -71,6 +72,7 @@ private: properties::FloatProperty _textureQuality; properties::BoolProperty _isHidden; properties::BoolProperty _isPointingSpacecraft; + properties::BoolProperty _updateDuringTargetAnimation; std::vector> _displayCopies; std::vector> _showDisplayCopies; diff --git a/modules/skybrowser/src/screenspaceskybrowser.cpp b/modules/skybrowser/src/screenspaceskybrowser.cpp index 21b11fb99e..b004c5cb79 100644 --- a/modules/skybrowser/src/screenspaceskybrowser.cpp +++ b/modules/skybrowser/src/screenspaceskybrowser.cpp @@ -82,6 +82,14 @@ namespace { openspace::properties::Property::Visibility::User }; + constexpr openspace::properties::Property::PropertyInfo UpdateDuringAnimationInfo = { + "UpdateDuringTargetAnimation", + "Update During Target Animation", + "If checked, the sky browser display copy will update its coordinates while " + "the target is animating.", + openspace::properties::Property::Visibility::User + }; + struct [[codegen::Dictionary(ScreenSpaceSkyBrowser)]] Parameters { // [[codegen::verbatim(TextureQualityInfo.description)]] std::optional textureQuality; @@ -91,6 +99,9 @@ namespace { // [[codegen::verbatim(PointSpacecraftInfo.description)]] std::optional pointSpacecraft; + + // [[codegen::verbatim(UpdateDuringAnimationInfo.description)]] + std::optional updateDuringTargetAnimation; }; #include "screenspaceskybrowser_codegen.cpp" @@ -123,6 +134,7 @@ ScreenSpaceSkyBrowser::ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary , _textureQuality(TextureQualityInfo, 1.f, 0.25f, 1.f) , _isHidden(IsHiddenInfo, true) , _isPointingSpacecraft(PointSpacecraftInfo, false) + , _updateDuringTargetAnimation(UpdateDuringAnimationInfo, false) { _identifier = makeUniqueIdentifier(_identifier); @@ -131,6 +143,9 @@ ScreenSpaceSkyBrowser::ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary _textureQuality = p.textureQuality.value_or(_textureQuality); _isHidden = p.isHidden.value_or(_isHidden); _isPointingSpacecraft = p.pointSpacecraft.value_or(_isPointingSpacecraft); + _updateDuringTargetAnimation = p.updateDuringTargetAnimation.value_or( + _updateDuringTargetAnimation + ); addProperty(_isHidden); addProperty(_url); @@ -139,6 +154,7 @@ ScreenSpaceSkyBrowser::ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary addProperty(_textureQuality); addProperty(_verticalFov); addProperty(_isPointingSpacecraft); + addProperty(_updateDuringTargetAnimation); _textureQuality.onChange([this]() { _isDimensionsDirty = true; }); @@ -199,6 +215,10 @@ bool ScreenSpaceSkyBrowser::isPointingSpacecraft() const { return _isPointingSpacecraft; } +bool ScreenSpaceSkyBrowser::shouldUpdateWhileTargetAnimates() const { + return _updateDuringTargetAnimation; +} + void ScreenSpaceSkyBrowser::setIdInBrowser() const { int currentNode = global::windowDelegate->currentNode(); WwtCommunicator::setIdInBrowser(fmt::format("{}_{}", identifier(), currentNode)); diff --git a/modules/skybrowser/src/targetbrowserpair.cpp b/modules/skybrowser/src/targetbrowserpair.cpp index 90672f5856..57e4e86d48 100644 --- a/modules/skybrowser/src/targetbrowserpair.cpp +++ b/modules/skybrowser/src/targetbrowserpair.cpp @@ -91,7 +91,10 @@ void TargetBrowserPair::fineTuneTarget(const glm::vec2& translation) { } void TargetBrowserPair::synchronizeAim() { - if (!_targetAnimation.isAnimating() && _browser->isInitialized()) { + bool shouldUpdate = + _browser->shouldUpdateWhileTargetAnimates() || + !_targetAnimation.isAnimating(); + if (shouldUpdate && _browser->isInitialized()) { _browser->setEquatorialAim(targetDirectionEquatorial()); _browser->setTargetRoll(targetRoll()); _targetRenderable->setVerticalFov(_browser->verticalFov());