diff --git a/include/openspace/navigation/orbitalnavigator.h b/include/openspace/navigation/orbitalnavigator.h index 00e083d55b..de6807c294 100644 --- a/include/openspace/navigation/orbitalnavigator.h +++ b/include/openspace/navigation/orbitalnavigator.h @@ -70,11 +70,12 @@ public: properties::BoolProperty shouldTriggerWhenIdle; properties::FloatProperty idleWaitTime; properties::BoolProperty abortOnCameraInteraction; - properties::FloatProperty speedScale; + properties::BoolProperty invert; + properties::FloatProperty speedScaleFactor; properties::FloatProperty dampenInterpolationTime; properties::OptionProperty defaultBehavior; - std::optional chosenBehavior = std::nullopt; + std::optional chosenBehavior; }; OrbitalNavigator(); diff --git a/src/navigation/orbitalnavigator.cpp b/src/navigation/orbitalnavigator.cpp index 308faab6a6..bda7db9093 100644 --- a/src/navigation/orbitalnavigator.cpp +++ b/src/navigation/orbitalnavigator.cpp @@ -248,7 +248,16 @@ namespace { "SpeedFactor", "Speed Factor", "A factor that can be used to increase or slow down the speed of an applied " - "idle behavior" + "idle behavior. A negative value will invert the direction. Note that a speed " + "of exactly 0 leads to no movement at all" + }; + + constexpr openspace::properties::Property::PropertyInfo InvertIdleBehaviorInfo = { + "Invert", + "Invert", + "If true, the direction of the idle behavior motion will be inverted compared " + "to the default. For example, the 'Orbit' option rotates to the right per " + "default, and will rotate to the left when inverted" }; constexpr openspace::properties::Property::PropertyInfo AbortOnCameraInteractionInfo = @@ -296,7 +305,8 @@ OrbitalNavigator::IdleBehavior::IdleBehavior() , shouldTriggerWhenIdle(ShouldTriggerIdleBehaviorWhenIdleInfo, false) , idleWaitTime(IdleWaitTimeInfo, 5.f, 0.f, 3600.f) , abortOnCameraInteraction(AbortOnCameraInteractionInfo, true) - , speedScale(IdleBehaviorSpeedInfo, 1.f, 0.01f, 5.f) + , invert(InvertIdleBehaviorInfo, false) + , speedScaleFactor(IdleBehaviorSpeedInfo, 1.f, -5.f, 5.f) , dampenInterpolationTime(IdleBehaviorDampenInterpolationTimeInfo, 0.5f, 0.f, 10.f) , defaultBehavior(IdleBehaviorInfo) { @@ -320,7 +330,8 @@ OrbitalNavigator::IdleBehavior::IdleBehavior() addProperty(shouldTriggerWhenIdle); addProperty(idleWaitTime); idleWaitTime.setExponent(2.2f); - addProperty(speedScale); + addProperty(invert); + addProperty(speedScaleFactor); addProperty(abortOnCameraInteraction); addProperty(dampenInterpolationTime); } @@ -1650,9 +1661,13 @@ void OrbitalNavigator::applyIdleBehavior(double deltaTime, glm::dvec3& position, glm::clamp(distFromSurfaceToCamera / distFromCenterToSurface, 0.0, 1.0) : 1.0; // same as horizontal translation - speedScale *= _idleBehavior.speedScale; + speedScale *= _idleBehavior.speedScaleFactor; speedScale *= 0.05; // without this scaling, the motion is way too fast + if (_idleBehavior.invert) { + speedScale *= -1.0; + } + // Interpolate so that the start and end are smooth double s = _idleBehaviorDampenInterpolator.value(); speedScale *= _invertIdleBehaviorInterpolation ? (1.0 - s) : s;