mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 13:08:49 -05:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user