Add property to make it possible to set if the browser display copies… (#2774)

* 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 <alexander.bock@liu.se>

---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Ylva Selling
2023-06-14 18:23:43 -04:00
committed by GitHub
parent 475f3c63c2
commit 045e4fcaa3
3 changed files with 26 additions and 1 deletions
@@ -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<std::unique_ptr<properties::Vec3Property>> _displayCopies;
std::vector<std::unique_ptr<properties::BoolProperty>> _showDisplayCopies;
@@ -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<float> textureQuality;
@@ -91,6 +99,9 @@ namespace {
// [[codegen::verbatim(PointSpacecraftInfo.description)]]
std::optional<bool> pointSpacecraft;
// [[codegen::verbatim(UpdateDuringAnimationInfo.description)]]
std::optional<bool> 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));
+4 -1
View File
@@ -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());