From 5c1946d4f285f7f3c2e72440ea537fb8162a1bd4 Mon Sep 17 00:00:00 2001 From: Joakim Kilby Date: Fri, 2 Feb 2024 10:23:16 +0100 Subject: [PATCH] make follow-rotation mode an absolute value instead of proportional to interaction sphere of anchor node. can be overridden by a node if one so wishes. --- include/openspace/scene/scenegraphnode.h | 3 +++ src/navigation/orbitalnavigator.cpp | 2 +- src/scene/scenegraphnode.cpp | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 7e35625d82..1d08472670 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -136,6 +136,8 @@ public: double reachFactor() const; double approachFactor() const; + double followRotationDistance() const; + bool supportsDirectInteraction() const; SceneGraphNode* childNode(const std::string& id); @@ -212,6 +214,7 @@ private: properties::DoubleProperty _screenSizeRadius; properties::FloatProperty _visibilityDistance; properties::BoolProperty _supportsDirectInteraction; + properties::DoubleProperty _followRotationDistance; // This variable is used for the rate-limiting of the screenspace positions (if they // are calculated when _computeScreenSpaceValues is true) diff --git a/src/navigation/orbitalnavigator.cpp b/src/navigation/orbitalnavigator.cpp index fb729b8485..f632643edc 100644 --- a/src/navigation/orbitalnavigator.cpp +++ b/src/navigation/orbitalnavigator.cpp @@ -497,7 +497,7 @@ OrbitalNavigator::OrbitalNavigator() , _retargetAnchor(RetargetAnchorInfo) , _retargetAim(RetargetAimInfo) , _followAnchorNodeRotation(FollowAnchorNodeInfo, true) - , _followAnchorNodeRotationDistance(FollowAnchorNodeDistanceInfo, 5.f, 0.f, 20.f) + , _followAnchorNodeRotationDistance(FollowAnchorNodeDistanceInfo, 5.f, 0.f, 20000.f) , _disableZoom(DisableZoomInfo, false) , _disableRoll(DisableRollInfo, false) , _mouseSensitivity(MouseSensitivityInfo, 15.f, 1.f, 50.f) diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index e74ea97172..2c17d9a1e9 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -217,6 +217,16 @@ namespace { openspace::properties::Property::Visibility::AdvancedUser }; + constexpr openspace::properties::Property::PropertyInfo FollowRotationDistanceInfo = + { + "FollowRotationDistance", + "Follow Rotation Distance", + "Distance within which the orbital navigator will follow along this nodes" + "rotation. A value less than zero means that the navigator will never follow" + "along with the nodes rotation.", + openspace::properties::Property::Visibility::AdvancedUser + }; + struct [[codegen::Dictionary(SceneGraphNode)]] Parameters { // The identifier of this scene graph node. This name must be unique among all // scene graph nodes that are loaded in a specific scene. If a duplicate is @@ -246,6 +256,9 @@ namespace { // [[codegen::verbatim(SupportsDirectInteractionInfo.description)]] std::optional supportsDirectInteraction; + // [[codegen::verbatim(FollowRotationDistanceInfo.description)]] + std::optional followRotationDistance; + struct Transform { // This node describes a translation that is applied to the scene graph node // and all its children. Depending on the 'Type' of the translation, this can @@ -401,6 +414,8 @@ ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( result->_approachFactor = p.approachFactor.value_or(result->_approachFactor); result->_reachFactor = p.reachFactor.value_or(result->_reachFactor); + result->_followRotationDistance = p.followRotationDistance.value_or(result->_followRotationDistance); + if (p.transform.has_value()) { ZoneScopedN("Transform"); @@ -564,6 +579,7 @@ SceneGraphNode::SceneGraphNode() , _visibilityDistance(VisibilityDistanceInfo, 6e10f) , _supportsDirectInteraction(SupportsDirectInteractionInfo, false) , _showDebugSphere(ShowDebugSphereInfo, false) + , _followRotationDistance(FollowRotationDistanceInfo, -1.0, -1.0) { addProperty(_computeScreenSpaceValues); addProperty(_screenSpacePosition); @@ -1293,6 +1309,11 @@ double SceneGraphNode::approachFactor() const { return _approachFactor; } +double SceneGraphNode::followRotationDistance() const +{ + return _followRotationDistance; +} + bool SceneGraphNode::supportsDirectInteraction() const { return _supportsDirectInteraction; }