Merge remote-tracking branch 'origin/master' into thesis/2021/skybrowser

# Conflicts:
#	data/assets/util/webgui.asset
This commit is contained in:
sylvass
2022-03-02 16:41:11 -05:00
63 changed files with 1005 additions and 623 deletions

View File

@@ -107,6 +107,12 @@ public:
bool setMode(Mode newMode);
void resetMode();
using CallbackHandle = int;
using ModeChangeCallback = std::function<void()>;
CallbackHandle addModeChangeCallback(ModeChangeCallback cb);
void removeModeChangeCallback(CallbackHandle handle);
// Guaranteed to return a valid pointer
AssetManager& assetManager();
LoadingScreen* loadingScreen();
@@ -151,6 +157,10 @@ private:
bool _isRenderingFirstFrame = true;
Mode _currentMode = Mode::UserControl;
Mode _modeLastFrame = Mode::UserControl;
int _nextCallbackHandle = 0;
std::vector<std::pair<CallbackHandle, ModeChangeCallback>> _modeChangeCallbacks;
};
/**

View File

@@ -671,7 +671,6 @@ protected:
bool isPropertyAllowedForBaseline(const std::string& propString);
unsigned int findIndexOfLastCameraKeyframeInTimeline();
bool doesTimelineEntryContainCamera(unsigned int index) const;
std::vector<std::pair<CallbackHandle, StateChangeCallback>> _stateChangeCallbacks;
bool doesStartWithSubstring(const std::string& s, const std::string& matchSubstr);
void trimCommandsFromScriptIfFound(std::string& script);
void replaceCommandsFromScriptIfFound(std::string& script);
@@ -800,6 +799,7 @@ protected:
double _cameraFirstInTimeline_timestamp = 0;
int _nextCallbackHandle = 0;
std::vector<std::pair<CallbackHandle, StateChangeCallback>> _stateChangeCallbacks;
DataMode _conversionDataMode = DataMode::Binary;
int _conversionLineNum = 1;

View File

@@ -155,16 +155,6 @@ private:
properties::FloatProperty _followAnchorNodeRotationDistance;
properties::FloatProperty _minimumAllowedDistance;
struct LinearFlight : public properties::PropertyOwner {
LinearFlight();
properties::BoolProperty apply;
properties::FloatProperty destinationDistance;
properties::DoubleProperty destinationFactor;
properties::FloatProperty velocitySensitivity;
};
LinearFlight _linearFlight;
properties::FloatProperty _mouseSensitivity;
properties::FloatProperty _joystickSensitivity;
properties::FloatProperty _websocketSensitivity;
@@ -291,20 +281,6 @@ private:
const glm::dvec3& objectPosition, const glm::dquat& globalCameraRotation,
const SurfacePositionHandle& positionHandle) const;
/**
* Moves the camera along a vector, camPosToCenterPosDiff, until it reaches the
* focusLimit. The velocity of the zooming depend on distFromCameraToFocus and the
* final frame where the camera stops moving depends on the distance set in the
* variable focusLimit. The bool determines whether to move/fly towards the focus node
* or away from it.
*
* \return a new position of the camera, closer to the focusLimit than the previous
* position
*/
glm::dvec3 moveCameraAlongVector(const glm::dvec3& camPos,
double distFromCameraToFocus, const glm::dvec3& camPosToCenterPosDiff,
double destination, double deltaTime) const;
/*
* Adds rotation to the camera position so that it follows the rotation of the anchor
* node defined by the differential anchorNodeRotationDiff.

View File

@@ -92,24 +92,50 @@ public:
*/
CameraPose interpolatedPose(double distance) const;
/**
* Reset variables used to play back path
*/
void resetPlaybackVariables();
private:
/**
* Interpolate between the paths start and end rotation using the approach that
* corresponds to the path's curve type. The interpolation parameter \p t is the
* same as for the position interpolation, i.e. the relative traveled in distance
* same as for the position interpolation, i.e. the relative traveled distance
* along the path, in [0, 1]
*
* \param t The interpolation parameter, given as the relative traveled distance
along the path, in [0, 1]
*/
glm::dquat interpolateRotation(double t) const;
/**
* Compute the interpolated rotation quaternion using an eased SLERP approach
*
* \param t The interpolation variable for the rotatation interpolation.
* Should be the relative traveled distance, in [0, 1]
*/
glm::dquat easedSlerpRotation(double t) const;
/**
* Compute the interpolated rotation quaternion using a method that is customized
* for linear paths. The camera will first interpoalte to look at the targetted
* node, and keep doing so for most of the path. At the end, when within a certain
* distance from the target, the rotation is interpolated so that the camera ends up
* in the target pose at the end of the path.
*
* \param t The interpolation variable for the rotatation interpolation.
* Should be the relative traveled distance, in [0, 1]
*/
glm::dquat linearPathRotation(double t) const;
/**
* Compute the interpolated rotation quaternion using an approach that first
* interpolates to look at the start node, and then the end node, before
* interpolating to the end rotation
*
* \param t The interpolation variable for the rotatation interpolation.
* Should be the relative traveled distance, in [0, 1]
*/
glm::dquat lookAtTargetsRotation(double t) const;
@@ -117,6 +143,8 @@ private:
* Evaluate the current traversal speed along the path, based on the currently
* traveled distance. The final speed will be scaled to match the desired duration
* for the path (which might have been specified by the user)
*
* \param traveledDistance The current distance traveled along the path, in meters
*/
double speedAlongPath(double traveledDistance) const;
@@ -129,15 +157,23 @@ private:
double _speedFactorFromDuration = 1.0;
// Playback variables
double _traveledDistance = 0.0;
double _progressedTime = 0.0; // Time since playback started
double _traveledDistance = 0.0; // Meters
double _progressedTime = 0.0; // Time since playback started (seconds)
bool _shouldQuit = false;
CameraPose _prevPose;
};
// Create a path of the given type based on an instruction given as a dictionary.
// See top of cpp file for documentation on keys and values for the dictionary.
// Returns the created path.
Path createPathFromDictionary(const ghoul::Dictionary& dictionary, Path::Type type);
/**
* Create a path based on an instruction given as a dictionary. (See top of cpp file
* for documentation on keys and values for the dictionary.)
* If /p forceType is specified, that type will primarily be used as the type for the
* created path. Secondly, the type will be read from the dictionary, and lastly it will
* use the default from PathNavigator.
*
* \return the created path
*/
Path createPathFromDictionary(const ghoul::Dictionary& dictionary,
std::optional<Path::Type> forceType = std::nullopt);
} // namespace openspace::interaction

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___PATHCURVE___H__
#include <ghoul/glm.h>
#include <ghoul/misc/exception.h>
#include <vector>
namespace openspace::interaction {
@@ -34,21 +35,38 @@ class Waypoint;
class PathCurve {
public:
struct InsufficientPrecisionError : public ghoul::RuntimeError {
explicit InsufficientPrecisionError(std::string msg);
};
struct TooShortPathError : public ghoul::RuntimeError {
explicit TooShortPathError(std::string msg);
};
virtual ~PathCurve() = 0;
/**
* Return the length of the curve, in meters
*/
double length() const;
/**
* Compute and return the position along the path at the specified relative
* distance. The input parameter should be in range [0, 1], where 1 correspond to
* the full length of the path
* the full length of the path.
*
* Can be overridden by subclasses that want more control over the position
* interpolation
*/
glm::dvec3 positionAt(double relativeDistance) const;
virtual glm::dvec3 positionAt(double relativeDistance) const;
/**
* Get the intorlatied position along the spline, based on the given curve parameter
* u in range [0, 1]. A curve parameter of 0 returns the start position and 1 the end
* position. Note that u does not correspond to the relatively traveled distance.
*
* Can be overridden by subclasses that want more control over the position
* interpolation
*/
virtual glm::dvec3 interpolate(double u) const;
@@ -59,16 +77,16 @@ public:
protected:
/**
* Precompute information related to the spline parameters, that are
* Precompute information related to the spline parameters that are
* needed for arc length reparameterization. Must be called after
* control point creation
* control point creation.
*/
void initializeParameterData();
/**
* Compute curve parameter u that matches the input arc length s.
* Input s is a length value, in the range [0, _totalLength]. The returned curve
* parameter u is in range [0, 1]
* Input s is a length value in meters, in the range [0, _totalLength].
* The returned curve parameter u is in range [0, 1].
*/
double curveParameter(double s) const;
@@ -81,7 +99,7 @@ protected:
std::vector<double> _curveParameterSteps; // per segment
std::vector<double> _lengthSums; // per segment
double _totalLength = 0.0;
double _totalLength = 0.0; // meters
struct ParameterPair {
double u; // curve parameter
@@ -94,6 +112,9 @@ protected:
class LinearCurve : public PathCurve {
public:
LinearCurve(const Waypoint& start, const Waypoint& end);
glm::dvec3 positionAt(double relativeDistance) const override;
glm::dvec3 interpolate(double u) const override;
};
} // namespace openspace::interaction

View File

@@ -58,6 +58,7 @@ public:
const SceneGraphNode* anchor() const;
const Path* currentPath() const;
double speedScale() const;
double arrivalDistanceFactor() const;
bool hasCurrentPath() const;
bool hasFinished() const;
@@ -71,7 +72,10 @@ public:
void pausePath();
void continuePath();
Path::Type defaultPathType() const;
double minValidBoundingSphere() const;
double findValidBoundingSphere(const SceneGraphNode* node) const;
const std::vector<SceneGraphNode*>& relevantNodes();
/**
@@ -98,6 +102,7 @@ private:
properties::BoolProperty _includeRoll;
properties::FloatProperty _speedScale;
properties::BoolProperty _applyIdleBehaviorOnFinish;
properties::DoubleProperty _arrivalDistanceFactor;
properties::DoubleProperty _minValidBoundingSphere;
properties::StringListProperty _relevantNodeTags;

View File

@@ -41,8 +41,6 @@ public:
Waypoint(const glm::dvec3& pos, const glm::dquat& rot, const std::string& ref);
explicit Waypoint(const NavigationState& ns);
static double findValidBoundingSphere(const SceneGraphNode* node);
CameraPose pose() const;
glm::dvec3 position() const;
glm::dquat rotation() const;

View File

@@ -56,6 +56,8 @@ public:
void enqueue(std::function<void()> f);
void clearTasks();
bool hasOutstandingTasks() const;
private:
friend class Worker;