Add helper function and timer to trigger idle behavior (#1898)

* Format property infos in orbital navigator more consistently

* Add helper function to trigger an idle behavior (issue #1833)

* Add timer to start idle behavior when camera is idle (issue #1730)
This commit is contained in:
Emma Broman
2022-03-15 10:06:24 +01:00
committed by GitHub
parent c8753faee1
commit 4e45f6634d
4 changed files with 201 additions and 66 deletions
+26 -15
View File
@@ -57,6 +57,26 @@ class KeyboardInputState;
class OrbitalNavigator : public properties::PropertyOwner {
public:
struct IdleBehavior : public properties::PropertyOwner {
enum class Behavior {
Orbit = 0,
OrbitAtConstantLat,
OrbitAroundUp
};
IdleBehavior();
properties::BoolProperty apply;
properties::BoolProperty shouldTriggerWhenIdle;
properties::FloatProperty idleWaitTime;
properties::BoolProperty abortOnCameraInteraction;
properties::FloatProperty speedScale;
properties::FloatProperty dampenInterpolationTime;
properties::OptionProperty defaultBehavior;
std::optional<Behavior> chosenBehavior = std::nullopt;
};
OrbitalNavigator();
void updateStatesFromInput(const MouseInputState& mouseInputState,
@@ -72,6 +92,9 @@ public:
*/
void updateOnCameraInteraction();
void tickIdleBehaviorTimer(double deltaTime);
void triggerIdleBehavior(std::string_view choice = "");
Camera* camera() const;
void setCamera(Camera* camera);
void clearPreviousState();
@@ -191,22 +214,8 @@ private:
Interpolator<double> _idleBehaviorDampenInterpolator;
bool _invertIdleBehaviorInterpolation = false;
struct IdleBehavior : public properties::PropertyOwner {
enum Behavior {
Orbit = 0,
OrbitAtConstantLat,
OrbitAroundUp
};
IdleBehavior();
properties::BoolProperty apply;
properties::OptionProperty chosenBehavior;
properties::FloatProperty speedScale;
properties::BoolProperty abortOnCameraInteraction;
properties::FloatProperty dampenInterpolationTime;
};
IdleBehavior _idleBehavior;
float _idleBehaviorTriggerTimer = 0.f;
/**
* Decomposes the camera's rotation in to a global and a local rotation defined by
@@ -344,6 +353,8 @@ private:
SurfacePositionHandle calculateSurfacePositionHandle(const SceneGraphNode& node,
const glm::dvec3 cameraPositionWorldSpace);
void resetIdleBehavior();
/**
* Apply the currently selected idle behavior to the position and rotations
*/