Merge branch 'master' into thesis/2020/radiation

This commit is contained in:
ElonOlsson
2021-09-13 18:23:33 -04:00
214 changed files with 9042 additions and 5664 deletions
+39
View File
@@ -0,0 +1,39 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___CAMERAPOSE___H__
#define __OPENSPACE_CORE___CAMERAPOSE___H__
#include <ghoul/glm.h>
namespace openspace {
struct CameraPose {
glm::dvec3 position = glm::dvec3(0.0);
glm::dquat rotation = glm::dquat(1.0, 0.0, 0.0, 0.0);
};
} // namespace openspace
#endif // __OPENSPACE_CORE___CAMERAPOSE___H__
+2
View File
@@ -54,6 +54,7 @@ namespace configuration { struct Configuration; }
namespace interaction {
struct JoystickInputStates;
struct WebsocketInputStates;
class ActionManager;
class InteractionMonitor;
class KeybindingManager;
class NavigationHandler;
@@ -88,6 +89,7 @@ inline VersionChecker* versionChecker;
inline VirtualPropertyManager* virtualPropertyManager;
inline WindowDelegate* windowDelegate;
inline configuration::Configuration* configuration;
inline interaction::ActionManager* actionManager;
inline interaction::InteractionMonitor* interactionMonitor;
inline interaction::JoystickInputStates* joystickInputStates;
inline interaction::WebsocketInputStates* websocketInputStates;
+70
View File
@@ -0,0 +1,70 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___ACTION___H__
#define __OPENSPACE_CORE___ACTION___H__
#include <ghoul/misc/boolean.h>
#include <string>
namespace openspace::interaction {
struct Action {
BooleanType(IsSynchronized);
/// Unique identifier that identifies this action. There is no special naming scheme
/// that we enforce, we are trying to stick to the same . separated structure that
/// hopefully provides some protection against accidentally reusing identifiers
std::string identifier;
/// The Lua script that gets executed whenever this action is triggered. Optional
/// parameters can be passed to actions which are accessible through an `args`
/// variable that contains all of the arguments passed into the action. This means
/// that the provided script must not use this variable name itself or the script will
/// not successfully execute
std::string command;
/// The human-readable name of this action. This name must not be unique, but it is
/// recommended that the combination of GuiPath + name should be unique to prevent
/// user confusion
std::string name;
/// A user-facing description of what the action does when it gets triggered. If the
/// action uses optional arguments, they should be described in here, too
std::string documentation;
/// This variable defines a subdivision of where this action is placed in a user
/// interface. The individual path components are separated by '/' with a leading '/'
/// for the root path
std::string guiPath;
/// If this value is set to `Yes`, the execution of this action is synchronized to
/// other OpenSpace instances, for example other nodes in a cluster environment, or
/// to other OpenSpace instances using a parallel connection
IsSynchronized synchronization = IsSynchronized::Yes;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___ACTION___H__
@@ -22,39 +22,34 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___SHORTCUTMANAGER___H__
#define __OPENSPACE_CORE___SHORTCUTMANAGER___H__
#ifndef __OPENSPACE_CORE___ACTIONMANAGER___H__
#define __OPENSPACE_CORE___ACTIONMANAGER___H__
#include <ghoul/misc/boolean.h>
#include <string>
#include <vector>
#include <openspace/interaction/action.h>
#include <unordered_map>
namespace ghoul { class Dictionary; }
namespace openspace::scripting { struct LuaLibrary; }
namespace openspace::interaction {
class ShortcutManager {
class ActionManager {
public:
BooleanType(IsSynchronized);
bool hasAction(const std::string& identifier) const;
void registerAction(Action action);
void removeAction(const std::string& identifier);
const Action& action(const std::string& identifier) const;
std::vector<Action> actions() const;
struct ShortcutInformation {
std::string name;
std::string script;
IsSynchronized synchronization;
std::string documentation;
std::string guiPath;
};
void resetShortcuts();
void addShortcut(ShortcutInformation info);
const std::vector<ShortcutInformation>& shortcuts() const;
void triggerAction(const std::string& identifier,
const ghoul::Dictionary& arguments) const;
static scripting::LuaLibrary luaLibrary();
private:
std::vector<ShortcutInformation> _shortcuts;
std::unordered_map<unsigned int, Action> _actions;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___SHORTCUTMANAGER___H__
#endif // __OPENSPACE_CORE___ACTIONMANAGER___H__
@@ -58,6 +58,12 @@ public:
void resetVelocities();
/*
* Returns true if any of the velocities are larger than zero,
* i.e. wether an interaction happened
*/
bool hasNonZeroVelocities();
protected:
struct InteractionState {
InteractionState(double scaleFactor);
@@ -28,6 +28,7 @@
#include <ghoul/misc/assert.h>
#include <ghoul/misc/exception.h>
#include <ghoul/misc/stringconversion.h>
#include <ghoul/fmt.h>
#include <array>
#include <memory>
#include <string>
@@ -126,18 +127,18 @@ inline std::string to_string(const openspace::interaction::JoystickAction& value
case openspace::interaction::JoystickAction::Press: return "Press";
case openspace::interaction::JoystickAction::Repeat: return "Repeat";
case openspace::interaction::JoystickAction::Release: return "Release";
default: throw MissingCaseException();
default: throw MissingCaseException();
}
}
template <>
constexpr openspace::interaction::JoystickAction from_string(std::string_view string) {
if (string == "Idle") { return openspace::interaction::JoystickAction::Idle; }
if (string == "Press") { return openspace::interaction::JoystickAction::Press; }
if (string == "Repeat") { return openspace::interaction::JoystickAction::Repeat; }
if (string == "Idle") { return openspace::interaction::JoystickAction::Idle; }
if (string == "Press") { return openspace::interaction::JoystickAction::Press; }
if (string == "Repeat") { return openspace::interaction::JoystickAction::Repeat; }
if (string == "Release") { return openspace::interaction::JoystickAction::Release; }
throw RuntimeError("Unknown action '" + std::string(string) + "'");
throw RuntimeError(fmt::format("Unknown action '{}'", string));
}
} // namespace ghoul
@@ -28,7 +28,6 @@
#include <openspace/documentation/documentationgenerator.h>
#include <openspace/util/keys.h>
#include <ghoul/misc/boolean.h>
namespace openspace {
class Camera;
@@ -41,33 +40,15 @@ namespace openspace::interaction {
class KeybindingManager : public DocumentationGenerator {
public:
BooleanType(IsSynchronized);
struct KeyInformation {
std::string command;
IsSynchronized synchronization;
std::string documentation;
std::string name;
std::string guiPath;
};
KeybindingManager();
void resetKeyBindings();
void bindKeyLocal(Key key, KeyModifier modifier, std::string luaCommand,
std::string documentation = "", std::string name = "", std::string guiPath = "");
void bindKey(Key key, KeyModifier modifier, std::string action);
void bindKey(Key key, KeyModifier modifier, std::string luaCommand,
std::string documentation = "", std::string name = "", std::string guiPath = "");
void removeKeyBinding(const std::string& key);
void removeKeyBinding(const KeyWithModifier& key);
std::vector<std::pair<KeyWithModifier, KeyInformation>> keyBinding(
const std::string& key) const;
std::vector<std::pair<KeyWithModifier, KeyInformation>> keyBinding(
std::vector<std::pair<KeyWithModifier, std::string>> keyBinding(
const KeyWithModifier& key) const;
static scripting::LuaLibrary luaLibrary();
@@ -76,10 +57,10 @@ public:
std::string generateJson() const override;
const std::multimap<KeyWithModifier, KeyInformation>& keyBindings() const;
const std::multimap<KeyWithModifier, std::string>& keyBindings() const;
private:
std::multimap<KeyWithModifier, KeyInformation> _keyLua;
std::multimap<KeyWithModifier, std::string> _keyLua;
};
} // namespace openspace::interaction
@@ -26,7 +26,7 @@
#define __OPENSPACE_CORE___SESSIONRECORDING___H__
#include <openspace/interaction/externinteraction.h>
#include <openspace/interaction/keyframenavigator.h>
#include <openspace/navigation/keyframenavigator.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/scripting/lualibrary.h>
#include <vector>
@@ -25,8 +25,8 @@
#ifndef __OPENSPACE_CORE___KEYFRAMENAVIGATOR___H__
#define __OPENSPACE_CORE___KEYFRAMENAVIGATOR___H__
#include <openspace/util/timeline.h>
#include <openspace/network/messagestructures.h>
#include <openspace/util/timeline.h>
#include <ghoul/glm.h>
#include <ghoul/misc/boolean.h>
#include <glm/gtx/quaternion.hpp>
@@ -28,10 +28,12 @@
#include <openspace/documentation/documentation.h>
#include <openspace/interaction/inputstate.h>
#include <openspace/interaction/joystickcamerastates.h>
#include <openspace/interaction/orbitalnavigator.h>
#include <openspace/interaction/keyframenavigator.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/interaction/websocketcamerastates.h>
#include <openspace/navigation/keyframenavigator.h>
#include <openspace/navigation/navigationstate.h>
#include <openspace/navigation/orbitalnavigator.h>
#include <openspace/navigation/pathnavigator.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/util/mouse.h>
@@ -48,31 +50,14 @@ namespace openspace::scripting { struct LuaLibrary; }
namespace openspace::interaction {
struct JoystickInputStates;
struct NavigationState;
struct WebsocketInputStates;
class KeyframeNavigator;
class OrbitalNavigator;
class PathNavigator;
class NavigationHandler : public properties::PropertyOwner {
public:
struct NavigationState {
NavigationState() = default;
NavigationState(const ghoul::Dictionary& dictionary);
NavigationState(std::string anchor, std::string aim, std::string referenceFrame,
glm::dvec3 position, std::optional<glm::dvec3> up = std::nullopt,
double yaw = 0.0, double pitch = 0.0);
ghoul::Dictionary dictionary() const;
static documentation::Documentation Documentation();
std::string anchor;
std::string aim;
std::string referenceFrame;
glm::dvec3 position = glm::dvec3(0.0);
std::optional<glm::dvec3> up;
double yaw = 0.0;
double pitch = 0.0;
};
NavigationHandler();
~NavigationHandler();
@@ -80,11 +65,9 @@ public:
void deinitialize();
// Mutators
void setFocusNode(SceneGraphNode* node);
void resetCameraDirection();
void setNavigationStateNextFame(NavigationState state);
void setCamera(Camera* camera);
void setInterpolationTime(float durationInSeconds);
@@ -101,6 +84,7 @@ public:
const OrbitalNavigator& orbitalNavigator() const;
OrbitalNavigator& orbitalNavigator();
KeyframeNavigator& keyframeNavigator();
PathNavigator& pathNavigator();
bool isKeyFrameInteractionEnabled() const;
float interpolationTime() const;
@@ -154,7 +138,7 @@ public:
static scripting::LuaLibrary luaLibrary();
private:
void applyNavigationState(const NavigationHandler::NavigationState& ns);
void applyNavigationState(const NavigationState& ns);
bool _playbackModeEnabled = false;
@@ -164,6 +148,7 @@ private:
OrbitalNavigator _orbitalNavigator;
KeyframeNavigator _keyframeNavigator;
PathNavigator _pathNavigator;
std::optional<NavigationState> _pendingNavigationState;
@@ -0,0 +1,59 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___NAVIGATIONSTATE___H__
#define __OPENSPACE_CORE___NAVIGATIONSTATE___H__
#include <openspace/documentation/documentation.h>
#include <optional>
namespace openspace {
struct CameraPose;
} // namespace openspace
namespace openspace::interaction {
struct NavigationState {
NavigationState() = default;
explicit NavigationState(const ghoul::Dictionary& dictionary);
NavigationState(std::string anchor, std::string aim, std::string referenceFrame,
glm::dvec3 position, std::optional<glm::dvec3> up = std::nullopt,
double yaw = 0.0, double pitch = 0.0);
CameraPose cameraPose() const;
ghoul::Dictionary dictionary() const;
static documentation::Documentation Documentation();
std::string anchor;
std::string aim;
std::string referenceFrame;
glm::dvec3 position = glm::dvec3(0.0);
std::optional<glm::dvec3> up;
double yaw = 0.0;
double pitch = 0.0;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___NAVIGATIONSTATE___H__
@@ -33,6 +33,7 @@
#include <openspace/interaction/mousecamerastates.h>
#include <openspace/interaction/scriptcamerastates.h>
#include <openspace/interaction/websocketcamerastates.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
@@ -46,6 +47,7 @@
namespace openspace {
class SceneGraphNode;
class Camera;
struct CameraPose;
struct SurfacePositionHandle;
} // namespace
@@ -59,8 +61,16 @@ public:
void updateStatesFromInput(const InputState& inputState, double deltaTime);
void updateCameraStateFromStates(double deltaTime);
void updateCameraScalingFromAnchor(double deltaTime);
void resetVelocities();
/*
* This function should be called on every camera interaction: for example when
* navigating using an input device, changing the focus node or starting a path or
* a session recording playback
*/
void updateOnCameraInteraction();
Camera* camera() const;
void setCamera(Camera* camera);
void clearPreviousState();
@@ -104,11 +114,6 @@ private:
glm::dquat globalRotation = glm::dquat(1.0, 0.0, 0.0, 0.0);
};
struct CameraPose {
glm::dvec3 position = glm::dvec3(0.0);
glm::dquat rotation = glm::dquat(1.0, 0.0, 0.0, 0.0);
};
using Displacement = std::pair<glm::dvec3, glm::dvec3>;
struct Friction : public properties::PropertyOwner {
@@ -129,12 +134,12 @@ private:
Friction _friction;
// Anchor: Node to follow and orbit.
// Anchor: Node to follow and orbit
properties::StringProperty _anchor;
// Aim: Node to look at (when camera direction is reset),
// Empty string means same as anchor.
// If these are the same node we call it the `focus` node.
// If these are the same node we call it the `focus` node
properties::StringProperty _aim;
// Reset camera direction to the anchor node.
@@ -144,11 +149,17 @@ private:
properties::FloatProperty _followAnchorNodeRotationDistance;
properties::FloatProperty _minimumAllowedDistance;
properties::FloatProperty _flightDestinationDistance;
properties::DoubleProperty _flightDestinationFactor;
properties::BoolProperty _applyLinearFlight;
properties::FloatProperty _velocitySensitivity;
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;
@@ -182,6 +193,25 @@ private:
Interpolator<double> _retargetAnchorInterpolator;
Interpolator<double> _cameraToSurfaceDistanceInterpolator;
Interpolator<double> _followRotationInterpolator;
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;
/**
* Decomposes the camera's rotation in to a global and a local rotation defined by
@@ -197,7 +227,7 @@ private:
/**
* Decomposes the camera's rotation in to a global and a local rotation defined by
* CameraRotationDecomposition. The global rotation defines the rotation so that the
* camera points towards the reference node's origin.
* camera points towards the reference position.
* The local rotation defines the differential from the global to the current total
* rotation so that <code>cameraRotation = globalRotation * localRotation</code>.
*/
@@ -318,7 +348,7 @@ private:
/**
* Interpolates between rotationDiff and a 0 rotation.
*/
glm::dquat interpolateRotationDifferential(double deltaTime, double interpolationTime,
glm::dquat interpolateRotationDifferential(double deltaTime,
const glm::dvec3 cameraPosition, const glm::dquat& rotationDiff);
/**
@@ -332,6 +362,45 @@ private:
*/
SurfacePositionHandle calculateSurfacePositionHandle(const SceneGraphNode& node,
const glm::dvec3 cameraPositionWorldSpace);
/**
* Apply the currently selected idle behavior to the position and rotations
*/
void applyIdleBehavior(double deltaTime, glm::dvec3& position,
glm::dquat& localRotation, glm::dquat& globalRotation);
/**
* Orbit the current anchor node, in a right-bound orbit, by updating the position
* and global rotation of the camera.
*
* Used for IdleBehavior::Behavior::Orbit
*
* \param deltaTime The time step to use for the motion. Controls the rotation angle
* \param position The position of the camera. Will be changed by the function
* \param globalRotation The camera's global rotation. Will be changed by the function
* \param speedScale A speed scale that controls the speed of the motion
*/
void orbitAnchor(double deltaTime, glm::dvec3& position,
glm::dquat& globalRotation, double speedScale);
/**
* Orbit the current anchor node, by adding a rotation around the given axis. For
* example, when the axis is the north vector, the camera will stay on the current
* latitude band. Note that this creates a rolling motion if the camera's forward
* vector coincides with the axis, and should be used with care.
*
* Used for:
* IdleBehavior::Behavior::OrbitAtConstantLat ( axis = north = z-axis ) and
* IdleBehavior::Behavior::OrbitAroundUp ( axis = up = y-axis )
*
* \param axis The axis to arbit around, given in model coordinates of the anchor
* \param deltaTime The time step to use for the motion. Controls the rotation angle
* \param position The position of the camera. Will be changed by the function
* \param globalRotation The camera's global rotation. Will be changed by the function
* \param speedScale A speed scale that controls the speed of the motion
*/
void orbitAroundAxis(const glm::dvec3 axis, double deltaTime, glm::dvec3& position,
glm::dquat& globalRotation, double speedScale);
};
} // namespace openspace::interaction
+144
View File
@@ -0,0 +1,144 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___PATH___H__
#define __OPENSPACE_CORE___PATH___H__
#include <openspace/navigation/pathcurve.h>
#include <openspace/navigation/waypoint.h>
#include <ghoul/misc/dictionary.h>
#include <optional>
#include <vector>
namespace openspace {
struct CameraPose;
} // namespace openspace
namespace openspace::interaction {
class Path {
public:
enum Type {
AvoidCollision,
Linear,
ZoomOutOverview,
AvoidCollisionWithLookAt // @TODO (2021-08-13, emmbr) This type right now leads
// to rapid rotations, but is useful in specific
// scenarios, e.g. close to surfaces. Later we want to
// remove it, and create a curve type that looks nicely
// at the targets when moving, avoids collisions and
// doesn't introduce sudden large changes in rotation
};
Path(Waypoint start, Waypoint end, Type type,
std::optional<double> duration = std::nullopt);
Waypoint startPoint() const;
Waypoint endPoint() const;
/**
* Return the total length of the the curve for the path, in meters
*/
double pathLength() const;
/**
* Return a vector of positions corresponding to the control points of the path's
* spline curve
*/
std::vector<glm::dvec3> controlPoints() const;
/**
* Take a step along the current path, corresponding to the delta time step \p dt, and
* return the resulting camera pose. The \p speedScale is a factor that will be
* multiplied with the traversal speed
*/
CameraPose traversePath(double dt, float speedScale = 1.f);
/**
* Return the identifer of the node that is the current appropriate anchor node, of
* the start and end waypoint's reference node. Dtermined based on how far along the
* path we have traveled
*/
std::string currentAnchor() const;
/**
* Return wether the path has reached its end point or not
*/
bool hasReachedEnd() const;
/**
* Compute the interpolated camera pose at a certain distance along the path
*/
CameraPose interpolatedPose(double distance) const;
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
* along the path, in [0, 1]
*/
glm::dquat interpolateRotation(double t) const;
/**
* Compute the interpolated rotation quaternion using an eased SLERP approach
*/
glm::dquat easedSlerpRotation(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
*/
glm::dquat lookAtTargetsRotation(double t) const;
/**
* 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)
*/
double speedAlongPath(double traveledDistance) const;
Waypoint _start;
Waypoint _end;
Type _type;
std::unique_ptr<PathCurve> _curve;
double _speedFactorFromDuration = 1.0;
// Playback variables
double _traveledDistance = 0.0;
double _progressedTime = 0.0; // Time since playback started
};
// 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);
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___PATH___H__
+101
View File
@@ -0,0 +1,101 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___PATHCURVE___H__
#define __OPENSPACE_CORE___PATHCURVE___H__
#include <ghoul/glm.h>
#include <vector>
namespace openspace::interaction {
class Waypoint;
class PathCurve {
public:
virtual ~PathCurve() = 0;
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
*/
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.
*/
virtual glm::dvec3 interpolate(double u) const;
/**
* Return the positions defining the control points for the spline interpolation
*/
std::vector<glm::dvec3> points() const;
protected:
/**
* Precompute information related to the spline parameters, that are
* needed for arc length reparameterization. Must be called after
* 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]
*/
double curveParameter(double s) const;
double approximatedDerivative(double u, double h = 0.0001) const;
double arcLength(double limit = 1.0) const;
double arcLength(double lowerLimit, double upperLimit) const;
std::vector<glm::dvec3> _points;
unsigned int _nSegments = 0;
std::vector<double> _curveParameterSteps; // per segment
std::vector<double> _lengthSums; // per segment
double _totalLength = 0.0;
struct ParameterPair {
double u; // curve parameter
double s; // arc length parameter
};
std::vector<ParameterPair> _parameterSamples;
};
class LinearCurve : public PathCurve {
public:
LinearCurve(const Waypoint& start, const Waypoint& end);
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___PATHCURVE___H__
@@ -0,0 +1,48 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___AVOIDCOLLISIONCURVE___H__
#define __OPENSPACE_CORE___AVOIDCOLLISIONCURVE___H__
#include <openspace/navigation/pathcurve.h>
namespace openspace { class SceneGraphNode; }
namespace openspace::interaction {
class WayPoint;
class AvoidCollisionCurve : public PathCurve {
public:
AvoidCollisionCurve(const Waypoint& start, const Waypoint& end);
private:
void removeCollisions(int step = 0);
std::vector<SceneGraphNode*> _relevantNodes;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_MODULE_AUTONAVIGATION___AVOIDCOLLISIONCURVE___H__
@@ -0,0 +1,41 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___ZOOMOUTOVERVIEWCURVE___H__
#define __OPENSPACE_CORE___ZOOMOUTOVERVIEWCURVE___H__
#include <openspace/navigation/pathcurve.h>
namespace openspace::interaction {
class WayPoint;
class ZoomOutOverviewCurve : public PathCurve {
public:
ZoomOutOverviewCurve(const Waypoint& start, const Waypoint& end);
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___ZOOMOUTOVERVIEWCURVE___H__
@@ -0,0 +1,107 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___PATHNAVIGATOR___H__
#define __OPENSPACE_CORE___PATHNAVIGATOR___H__
#include <openspace/properties/propertyowner.h>
#include <openspace/navigation/path.h>
#include <openspace/properties/list/stringlistproperty.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/doubleproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <ghoul/glm.h>
#include <memory>
namespace openspace {
class Camera;
struct CameraPose;
class SceneGraphNode;
} // namespace openspace
namespace openspace::scripting { struct LuaLibrary; }
namespace openspace::interaction {
class Path;
class PathNavigator : public properties::PropertyOwner {
public:
PathNavigator();
~PathNavigator();
// Accessors
Camera* camera() const;
const SceneGraphNode* anchor() const;
const Path* currentPath() const;
double speedScale() const;
bool hasCurrentPath() const;
bool hasFinished() const;
bool isPlayingPath() const;
void updateCamera(double deltaTime);
void createPath(const ghoul::Dictionary& dictionary);
void clearPath();
void startPath();
void abortPath();
void pausePath();
void continuePath();
double minValidBoundingSphere() const;
const std::vector<SceneGraphNode*>& relevantNodes();
/**
* \return The Lua library that contains all Lua functions available to affect the
* path navigation
*/
static scripting::LuaLibrary luaLibrary();
private:
/**
* Populate list of nodes that are relevant for collision checks, etc
*/
void findRelevantNodes();
void removeRollRotation(CameraPose& pose, double deltaTime);
std::unique_ptr<Path> _currentPath = nullptr;
bool _isPlaying = false;
properties::OptionProperty _defaultPathType;
properties::BoolProperty _includeRoll;
properties::FloatProperty _speedScale;
properties::BoolProperty _applyIdleBehaviorOnFinish;
properties::DoubleProperty _minValidBoundingSphere;
properties::StringListProperty _relevantNodeTags;
std::vector<SceneGraphNode*> _relevantNodes;
bool _hasInitializedRelevantNodes = false;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___PATHNAVIGATOR___H__
+61
View File
@@ -0,0 +1,61 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___WAYPOINT___H__
#define __OPENSPACE_CORE___WAYPOINT___H__
#include <openspace/camera/camerapose.h>
#include <ghoul/glm.h>
#include <string>
namespace openspace { class SceneGraphNode; }
namespace openspace::interaction {
struct NavigationState;
class Waypoint {
public:
Waypoint() = default;
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;
SceneGraphNode* node() const;
std::string nodeIdentifier() const;
double validBoundingSphere() const;
private:
CameraPose _pose;
std::string _nodeIdentifier;
double _validBoundingSphere = 0.0; // to be able to handle nodes with faulty bounding spheres
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___WAYPOINT___H__
@@ -87,7 +87,7 @@ public:
*
* \param value The value that is used to set this Property
*/
virtual void set(std::any value) override;
virtual void set(std::any value) final;
/**
* Returns the <code>std::type_info</code> describing the template parameter
@@ -94,9 +94,9 @@ public:
virtual void updateRendererData();
virtual void raycastersChanged(VolumeRaycaster& raycaster,
RaycasterListener::IsAttached attached);
RaycasterListener::IsAttached attached) override;
virtual void deferredcastersChanged(Deferredcaster& deferredcaster,
DeferredcasterListener::IsAttached isAttached);
DeferredcasterListener::IsAttached isAttached) override;
private:
using RaycasterProgObjMap = std::map<
@@ -32,6 +32,7 @@
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/rendering/framebufferrenderer.h>
#include <chrono>
@@ -219,6 +220,9 @@ private:
} _cameraButtonLocations;
std::string _versionString;
properties::Vec4Property _enabledFontColor;
properties::Vec4Property _disabledFontColor;
};
} // namespace openspace
+41 -58
View File
@@ -26,9 +26,9 @@
#define __OPENSPACE_CORE___PROFILE___H__
#include <openspace/engine/globals.h>
#include <openspace/interaction/navigationhandler.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/util/keys.h>
#include <ghoul/glm.h>
#include <ghoul/misc/exception.h>
#include <optional>
#include <string>
@@ -37,6 +37,8 @@
namespace openspace {
namespace interaction { struct NavigationState; }
namespace scripting { struct LuaLibrary; }
class Profile {
@@ -77,15 +79,20 @@ public:
SetType setType;
std::string name;
std::string value;
};
struct Keybinding {
KeyWithModifier key;
struct Action {
std::string identifier;
std::string documentation;
std::string name;
std::string guiPath;
bool isLocal;
std::string script;
};
struct Keybinding {
KeyWithModifier key;
std::string action;
};
struct Time {
enum class Type {
Absolute,
@@ -120,56 +127,36 @@ public:
explicit Profile(const std::string& content);
std::string serialize() const;
std::string convertToScene() const;
/**
* Saves all current settings, starting from the profile that was loaded at startup,
* and all of the property & asset changes that were made since startup.
*/
void saveCurrentSettingsToProfile(const properties::PropertyOwner& rootOwner,
std::string currentTime,
interaction::NavigationHandler::NavigationState navState);
std::string currentTime, interaction::NavigationState navState);
/// If the value passed to this function is 'true', the addAsset and removeAsset
/// functions will be no-ops instead
void setIgnoreUpdates(bool ignoreUpdates);
/// Adds a new asset and checks for duplicates
/// Adds a new asset and checks for duplicates unless the `ignoreUpdates` member is
/// set to `true`
void addAsset(const std::string& path);
/// Removes an asset
/// Removes an asset unless the `ignoreUpdates` member is set to `true`
void removeAsset(const std::string& path);
/// Removes all assets
void clearAssets();
static constexpr const Version CurrentVersion = Version{ 1, 1 };
Version version() const;
std::vector<Module> modules() const;
std::optional<Meta> meta() const;
std::vector<std::string> assets() const;
std::vector<Property> properties() const;
std::vector<Keybinding> keybindings() const;
std::optional<Time> time() const;
std::vector<double> deltaTimes() const;
std::optional<CameraType> camera() const;
std::vector<std::string> markNodes() const;
std::vector<std::string> additionalScripts() const;
void clearMeta();
void clearTime();
void clearCamera();
void setVersion(Version v);
void setModules(std::vector<Module>& m);
void setMeta(Meta m);
void setProperties(std::vector<Property>& p);
void setKeybindings(std::vector<Keybinding>& k);
void setTime(Time t);
void setDeltaTimes(std::vector<double> dt);
void setCamera(CameraType c);
void setMarkNodes(std::vector<std::string>& n);
void setAdditionalScripts(std::vector<std::string>& s);
Version version = CurrentVersion;
std::vector<Module> modules;
std::optional<Meta> meta;
std::vector<std::string> assets;
std::vector<Property> properties;
std::vector<Action> actions;
std::vector<Keybinding> keybindings;
std::optional<Time> time;
std::vector<double> deltaTimes;
std::optional<CameraType> camera;
std::vector<std::string> markNodes;
std::vector<std::string> additionalScripts;
bool ignoreUpdates = false;
/**
* Returns the Lua library that contains all Lua functions available to provide
@@ -177,25 +164,21 @@ public:
* \return The Lua library that contains all Lua functions available for profiles
*/
static scripting::LuaLibrary luaLibrary();
private:
static constexpr const Version CurrentVersion = Version { 1, 0 };
Version _version = CurrentVersion;
std::vector<Module> _modules;
std::optional<Meta> _meta;
std::vector<std::string> _assets;
std::vector<Property> _properties;
std::vector<Keybinding> _keybindings;
std::optional<Time> _time;
std::vector<double> _deltaTimes;
std::optional<CameraType> _camera;
std::vector<std::string> _markNodes;
std::vector<std::string> _additionalScripts;
bool _ignoreUpdates = false;
};
/**
* This function takes a profile and returns its asset-ifyied version as a string. This
* is the format that is saved as a scene file that, in turn, is provided to OpenSpace as
* the root asset to load. This function is a key step to be able to load a Profile in
* OpenSpace (at the moment).
*
* \param profile The profile that should be converted to the asset-file format
*
* \return The string representation of the provided profile, ready to be loaded as an
* asset
*/
std::string convertToScene(const Profile& profile);
} // namespace openspace
#endif // __OPENSPACE_CORE___PROFILE___H__
+2 -2
View File
@@ -41,7 +41,7 @@ public:
virtual bool isInitializing() const = 0;
};
class SingleThreadedSceneInitializer : public SceneInitializer {
class SingleThreadedSceneInitializer final : public SceneInitializer {
public:
void initializeNode(SceneGraphNode* node) override;
std::vector<SceneGraphNode*> takeInitializedNodes() override;
@@ -51,7 +51,7 @@ private:
std::vector<SceneGraphNode*> _initializedNodes;
};
class MultiThreadedSceneInitializer : public SceneInitializer {
class MultiThreadedSceneInitializer final : public SceneInitializer {
public:
MultiThreadedSceneInitializer(unsigned int nThreads);
@@ -25,8 +25,8 @@
#ifndef __OPENSPACE_CORE___SCRIPTSCHEDULER___H__
#define __OPENSPACE_CORE___SCRIPTSCHEDULER___H__
#include <openspace/navigation/keyframenavigator.h>
#include <openspace/scripting/lualibrary.h>
#include <openspace/interaction/keyframenavigator.h>
#include <functional>
#include <queue>
+59
View File
@@ -0,0 +1,59 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___COLLISIONHELPER___H__
#define __OPENSPACE_CORE___COLLISIONHELPER___H__
#include <ghoul/glm.h>
namespace openspace::collision {
/*
* Calculate the intersection of a line segment and a sphere.
* The line segment is defined from \p p1 to \p p2.
* The sphere is defined by the radius \p r and center point \p center.
* The resulting intersection point is stored in the \p intersectionPoint parameter.
*
* In the case of two intersection points, only care about the first one.
*
* \param p1 The start point for the line segment
* \param p2 The end point for the line segment
* \param center The center point for the sphere
* \param r The radius of the sphere
* \param intersectionPoint A variable to store the resulting intersection point in
* \return True if the line between \p p1 and \p p2 intersects the sphere given by
* \p r and \p center, and false otherwise
*/
bool lineSphereIntersection(glm::dvec3 p1, glm::dvec3 p2, glm::dvec3 center,
double r, glm::dvec3& intersectionPoint);
/*
* Check if the point \p p is inside of the sphere defined by radius \p r and center
* point \p c
*/
bool isPointInsideSphere(const glm::dvec3& p, const glm::dvec3& c, double r);
} // namespace openspace::collision
#endif // __OPENSPACE_CORE___COLLISIONHELPER___H__
+334 -513
View File
@@ -58,545 +58,366 @@
// definitions GLFW v3.1
#include <ghoul/misc/stringconversion.h>
#include <array>
#include <map>
#include <string>
#include <unordered_map>
namespace openspace {
enum class KeyAction : int {
//////////////////////////////////////////////////////////////////////////////////////////
enum class KeyAction : uint8_t {
Release = 0,
Press = 1,
Repeat = 2
};
bool hasKeyAction(KeyAction lhs, KeyAction rhs);
constexpr bool hasKeyAction(KeyAction lhs, KeyAction rhs) {
return static_cast<std::underlying_type_t<KeyAction>>(lhs) &
static_cast<std::underlying_type_t<KeyAction>>(rhs);
}
KeyAction operator|(KeyAction lhs, KeyAction rhs);
KeyAction operator|=(KeyAction& lhs, KeyAction rhs);
constexpr KeyAction operator|(KeyAction lhs, KeyAction rhs) {
return static_cast<KeyAction>(
static_cast<std::underlying_type_t<KeyAction>>(lhs) |
static_cast<std::underlying_type_t<KeyAction>>(rhs)
);
}
enum class KeyModifier : int {
NoModifier = 0,
Shift = 0x0001,
Control = 0x0002,
Alt = 0x0004,
Super = 0x0008
constexpr KeyAction operator|=(KeyAction& lhs, KeyAction rhs) {
return (lhs | rhs);
}
//////////////////////////////////////////////////////////////////////////////////////////
enum class KeyModifier : uint8_t {
None = 0,
Shift = 0x01,
Control = 0x02,
Alt = 0x04,
Super = 0x08
};
static const std::map<int, std::string> KeyModifierNames = {
{0, ""},
{0x0001, "Shift"},
{0x0002, "Control"},
{0x0004, "Alt"},
{0x0008, "Super"},
{0x0003, "Shift+Control"},
{0x0005, "Shift+Alt"},
{0x0009, "Shift+Super"},
{0x0006, "Control+Alt"},
{0x000A, "Control+Super"},
{0x000C, "Alt+Super"},
{0x0007, "Shift+Control+Alt"},
{0x000B, "Shift+Control+Super"},
{0x000D, "Shift+Alt+Super"},
{0x000E, "Control+Alt+Super"},
{0x000F, "Shift+Control+Alt+Super"}
constexpr KeyModifier operator|(KeyModifier lhs, KeyModifier rhs) {
return static_cast<KeyModifier>(
static_cast<std::underlying_type_t<KeyModifier>>(lhs) |
static_cast<std::underlying_type_t<KeyModifier>>(rhs)
);
}
constexpr KeyModifier operator|=(KeyModifier& lhs, KeyModifier rhs) {
return lhs = (lhs | rhs);
}
struct KeyModifierInfo {
KeyModifier modifier;
std::string_view name;
std::string_view identifier;
};
bool hasKeyModifier(KeyModifier lhs, KeyModifier rhs);
KeyModifier operator|(KeyModifier lhs, KeyModifier rhs);
KeyModifier operator|=(KeyModifier& lhs, KeyModifier rhs);
enum class Key {
Unknown = -1,
Space = 32,
Apostrophe = 39,
Comma = 44,
Minus = 45,
Period = 46,
Slash = 47,
Num0 = 48,
Num1 = 49,
Num2 = 50,
Num3 = 51,
Num4 = 52,
Num5 = 53,
Num6 = 54,
Num7 = 55,
Num8 = 56,
Num9 = 57,
SemiColon = 59,
Equal = 61,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
LeftBracket = 91,
BackSlash = 92,
RightBracket = 93,
GraveAccent = 96,
World1 = 161,
World2 = 162,
Escape = 256,
Enter = 257,
Tab = 258,
BackSpace = 259,
Insert = 260,
Delete = 261,
Right = 262,
Left = 263,
Down = 264,
Up = 265,
PageUp = 266,
PageDown = 267,
Home = 268,
End = 269,
CapsLock = 280,
ScrollLock = 281,
NumLock = 282,
PrintScreen = 283,
Pause = 284,
F1 = 290,
F2 = 291,
F3 = 292,
F4 = 293,
F5 = 294,
F6 = 295,
F7 = 296,
F8 = 297,
F9 = 298,
F10 = 299,
F11 = 300,
F12 = 301,
F13 = 302,
F14 = 303,
F15 = 304,
F16 = 305,
F17 = 306,
F18 = 307,
F19 = 308,
F20 = 309,
F21 = 310,
F22 = 311,
F23 = 312,
F24 = 313,
F25 = 314,
Keypad0 = 320,
Keypad1 = 321,
Keypad2 = 322,
Keypad3 = 323,
Keypad4 = 324,
Keypad5 = 325,
Keypad6 = 326,
Keypad7 = 327,
Keypad8 = 328,
Keypad9 = 329,
KeypadDecimal = 330,
KeypadDivide = 331,
KeypadMultiply = 332,
KeypadSubtract = 333,
KeypadAdd = 334,
KeypadEnter = 335,
LeftShift = 340,
LeftControl = 341,
LeftAlt = 342,
LeftSuper = 343,
RightShift = 344,
RightControl = 345,
RightAlt = 346,
RightSuper = 347,
Menu = 348,
Last = Menu
constexpr std::array<KeyModifierInfo, 5> KeyModifierInfos = {
KeyModifierInfo{ KeyModifier::None, "", "" },
KeyModifierInfo{ KeyModifier::Shift, "Shift", "SHIFT" },
KeyModifierInfo{ KeyModifier::Control, "Control", "CTRL" },
KeyModifierInfo{ KeyModifier::Alt, "Alt", "ALT" },
KeyModifierInfo{ KeyModifier::Super, "Super", "SUPER" },
};
static const std::map<int, std::string> KeyNames = {
{32, "Space"},
{39, "'"},
{44, ","},
{45, "-"},
{46, "."},
{47, "/"},
{48, "0"},
{49, "1"},
{50, "2"},
{51, "3"},
{52, "4"},
{53, "5"},
{54, "6"},
{55, "7"},
{56, "8"},
{57, "9"},
{59, ";"},
{61, "="},
{65, "A"},
{66, "B"},
{67, "C"},
{68, "D"},
{69, "E"},
{70, "F"},
{71, "G"},
{72, "H"},
{73, "I"},
{74, "J"},
{75, "K"},
{76, "L"},
{77, "M"},
{78, "N"},
{79, "O"},
{80, "P"},
{81, "Q"},
{82, "R"},
{83, "S"},
{84, "T"},
{85, "U"},
{86, "V"},
{87, "W"},
{88, "X"},
{89, "Y"},
{90, "Z"},
{91, "["},
{92, "\\"},
{93, "]"},
{96, "`"},
{161, "World1"},
{162, "World2"},
{256, "Escape"},
{257, "Enter"},
{258, "Tab"},
{259, "BackSpace"},
{260, "Insert"},
{261, "Delete"},
{262, "Right"},
{263, "Left"},
{264, "Down"},
{265, "Up"},
{266, "PageUp"},
{267, "PageDown"},
{268, "Home"},
{269, "End"},
{280, "CapsLock"},
{281, "ScrollLock"},
{282, "NumLock"},
{283, "PrintScreen"},
{284, "Pause"},
{290, "F1"},
{291, "F2"},
{292, "F3"},
{293, "F4"},
{294, "F5"},
{295, "F6"},
{296, "F7"},
{297, "F8"},
{298, "F9"},
{299, "F10"},
{300, "F11"},
{301, "F12"},
{302, "F13"},
{303, "F14"},
{304, "F15"},
{305, "F16"},
{306, "F17"},
{307, "F18"},
{308, "F19"},
{309, "F20"},
{310, "F21"},
{311, "F22"},
{312, "F23"},
{313, "F24"},
{314, "F25"},
{320, "Keypad 0"},
{321, "Keypad 1"},
{322, "Keypad 2"},
{323, "Keypad 3"},
{324, "Keypad 4"},
{325, "Keypad 5"},
{326, "Keypad 6"},
{327, "Keypad 7"},
{328, "Keypad 8"},
{329, "Keypad 9"},
{330, "Keypad ."},
{331, "Keypad /"},
{332, "Keypad *"},
{333, "Keypad -"},
{334, "Keypad +"},
{335, "Keypad Enter"},
{340, "Left Shift"},
{341, "Left Control"},
{342, "Left Alt"},
{343, "Left Super"},
{344, "Right Shift"},
{345, "Right Control"},
{346, "Right Alt"},
{347, "Right Super"},
{348, "Menu"}
constexpr bool hasKeyModifier(KeyModifier lhs, KeyModifier rhs) {
return static_cast<std::underlying_type_t<KeyModifier>>(lhs) &
static_cast<std::underlying_type_t<KeyModifier>>(rhs);
}
//////////////////////////////////////////////////////////////////////////////////////////
enum class Key : uint16_t {
Unknown = uint16_t(-1),
Space = 32,
Apostrophe = 39,
Comma = 44,
Minus = 45,
Period = 46,
Slash = 47,
Num0 = 48,
Num1 = 49,
Num2 = 50,
Num3 = 51,
Num4 = 52,
Num5 = 53,
Num6 = 54,
Num7 = 55,
Num8 = 56,
Num9 = 57,
SemiColon = 59,
Equal = 61,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
LeftBracket = 91,
BackSlash = 92,
RightBracket = 93,
GraveAccent = 96,
World1 = 161,
World2 = 162,
Escape = 256,
Enter = 257,
Tab = 258,
BackSpace = 259,
Insert = 260,
Delete = 261,
Right = 262,
Left = 263,
Down = 264,
Up = 265,
PageUp = 266,
PageDown = 267,
Home = 268,
End = 269,
CapsLock = 280,
ScrollLock = 281,
NumLock = 282,
PrintScreen = 283,
Pause = 284,
F1 = 290,
F2 = 291,
F3 = 292,
F4 = 293,
F5 = 294,
F6 = 295,
F7 = 296,
F8 = 297,
F9 = 298,
F10 = 299,
F11 = 300,
F12 = 301,
F13 = 302,
F14 = 303,
F15 = 304,
F16 = 305,
F17 = 306,
F18 = 307,
F19 = 308,
F20 = 309,
F21 = 310,
F22 = 311,
F23 = 312,
F24 = 313,
F25 = 314,
Keypad0 = 320,
Keypad1 = 321,
Keypad2 = 322,
Keypad3 = 323,
Keypad4 = 324,
Keypad5 = 325,
Keypad6 = 326,
Keypad7 = 327,
Keypad8 = 328,
Keypad9 = 329,
KeypadDecimal = 330,
KeypadDivide = 331,
KeypadMultiply = 332,
KeypadSubtract = 333,
KeypadAdd = 334,
KeypadEnter = 335,
LeftShift = 340,
LeftControl = 341,
LeftAlt = 342,
LeftSuper = 343,
RightShift = 344,
RightControl = 345,
RightAlt = 346,
RightSuper = 347,
Menu = 348,
Last = Menu
};
struct KeyInfo {
Key key;
std::string_view name;
std::string_view identifier;
};
constexpr const std::array<KeyInfo, 120> KeyInfos = {
KeyInfo { Key::Unknown, "", "" },
KeyInfo { Key::Space, "Space", "SPACE" },
KeyInfo { Key::Apostrophe, "'", "APOSTROPHE" },
KeyInfo { Key::Comma, ",", "COMMA" },
KeyInfo { Key::Minus, "-", "MINUS" },
KeyInfo { Key::Period, ".", "PERIOD" },
KeyInfo { Key::Slash, "/", "SLASH" },
KeyInfo { Key::Num0, "0", "0" },
KeyInfo { Key::Num1, "1", "1" },
KeyInfo { Key::Num2, "2", "2" },
KeyInfo { Key::Num3, "3", "3" },
KeyInfo { Key::Num4, "4", "4" },
KeyInfo { Key::Num5, "5", "5" },
KeyInfo { Key::Num6, "6", "6" },
KeyInfo { Key::Num7, "7", "7" },
KeyInfo { Key::Num8, "8", "8" },
KeyInfo { Key::Num9, "9", "9" },
KeyInfo { Key::SemiColon, ";", "SEMICOLON" },
KeyInfo { Key::Equal, "=", "EQUAL" },
KeyInfo { Key::A, "A", "A" },
KeyInfo { Key::B, "B", "B" },
KeyInfo { Key::C, "C", "C" },
KeyInfo { Key::D, "D", "D" },
KeyInfo { Key::E, "E", "E" },
KeyInfo { Key::F, "F", "F" },
KeyInfo { Key::G, "G", "G" },
KeyInfo { Key::H, "H", "H" },
KeyInfo { Key::I, "I", "I" },
KeyInfo { Key::J, "J", "J" },
KeyInfo { Key::K, "K", "K" },
KeyInfo { Key::L, "L", "L" },
KeyInfo { Key::M, "M", "M" },
KeyInfo { Key::N, "N", "N" },
KeyInfo { Key::O, "O", "O" },
KeyInfo { Key::P, "P", "P" },
KeyInfo { Key::Q, "Q", "Q" },
KeyInfo { Key::R, "R", "R" },
KeyInfo { Key::S, "S", "S" },
KeyInfo { Key::T, "T", "T" },
KeyInfo { Key::U, "U", "U" },
KeyInfo { Key::V, "V", "V" },
KeyInfo { Key::W, "W", "W" },
KeyInfo { Key::X, "X", "X" },
KeyInfo { Key::Y, "Y", "Y" },
KeyInfo { Key::Z, "Z", "Z" },
KeyInfo { Key::LeftBracket, "[", "LEFTBRACKET" },
KeyInfo { Key::BackSlash, "\\", "BACKSLASH" },
KeyInfo { Key::RightBracket, "]", "RIGHTBRACKET" },
KeyInfo { Key::GraveAccent, "`", "GRAVEACCENT" },
KeyInfo { Key::World1, "World1", "WORLD1" },
KeyInfo { Key::World2, "World2", "WORLD2" },
KeyInfo { Key::Escape, "Escape", "ESC" },
KeyInfo { Key::Enter, "Enter", "ENTER" },
KeyInfo { Key::Tab, "Tab", "TAB" },
KeyInfo { Key::BackSpace, "Backspace", "BACKSPACE" },
KeyInfo { Key::Insert, "Insert", "INSERT" },
KeyInfo { Key::Delete, "Delete", "DELETE" },
KeyInfo { Key::Right, "Right", "RIGHT" },
KeyInfo { Key::Left, "Left", "LEFT" },
KeyInfo { Key::Down, "Down", "DOWN" },
KeyInfo { Key::Up, "Up", "UP" },
KeyInfo { Key::PageUp, "PageUp", "PAGEUP" },
KeyInfo { Key::PageDown, "PageDown", "PAGEDOWN" },
KeyInfo { Key::Home, "Home", "HOME" },
KeyInfo { Key::End, "End", "END" },
KeyInfo { Key::CapsLock, "CapsLock", "CAPS_LOCK" },
KeyInfo { Key::ScrollLock, "ScrollLock", "SCROLL_LOCK" },
KeyInfo { Key::NumLock, "NumLock", "NUM_LOCK" },
KeyInfo { Key::PrintScreen, "PrintScreen", "PRINT_SCREEN" },
KeyInfo { Key::Pause, "Pause", "PAUSE" },
KeyInfo { Key::F1, "F1", "F1" },
KeyInfo { Key::F2, "F2", "F2" },
KeyInfo { Key::F3, "F3", "F3" },
KeyInfo { Key::F4, "F4", "F4" },
KeyInfo { Key::F5, "F5", "F5" },
KeyInfo { Key::F6, "F6", "F6" },
KeyInfo { Key::F7, "F7", "F7" },
KeyInfo { Key::F8, "F8", "F8" },
KeyInfo { Key::F9, "F9", "F9" },
KeyInfo { Key::F10, "F10", "F10" },
KeyInfo { Key::F11, "F11", "F11" },
KeyInfo { Key::F12, "F12", "F12" },
KeyInfo { Key::F13, "F13", "F13" },
KeyInfo { Key::F14, "F14", "F14" },
KeyInfo { Key::F15, "F15", "F15" },
KeyInfo { Key::F16, "F16", "F16" },
KeyInfo { Key::F17, "F17", "F17" },
KeyInfo { Key::F18, "F18", "F18" },
KeyInfo { Key::F19, "F19", "F19" },
KeyInfo { Key::F20, "F20", "F20" },
KeyInfo { Key::F21, "F21", "F21" },
KeyInfo { Key::F22, "F22", "F22" },
KeyInfo { Key::F23, "F23", "F23" },
KeyInfo { Key::F24, "F24", "F24" },
KeyInfo { Key::F25, "F25", "F25" },
KeyInfo { Key::Keypad0, "Keypad 0", "KP_0" },
KeyInfo { Key::Keypad1, "Keypad 1", "KP_1" },
KeyInfo { Key::Keypad2, "Keypad 2", "KP_2" },
KeyInfo { Key::Keypad3, "Keypad 3", "KP_3" },
KeyInfo { Key::Keypad4, "Keypad 4", "KP_4" },
KeyInfo { Key::Keypad5, "Keypad 5", "KP_5" },
KeyInfo { Key::Keypad6, "Keypad 6", "KP_6" },
KeyInfo { Key::Keypad7, "Keypad 7", "KP_7" },
KeyInfo { Key::Keypad8, "Keypad 8", "KP_8" },
KeyInfo { Key::Keypad9, "Keypad 9", "KP_9" },
KeyInfo { Key::KeypadDecimal, "Keypad .", "KP_DECIMAL" },
KeyInfo { Key::KeypadDivide, "Keypad /", "KP_DIVIDE" },
KeyInfo { Key::KeypadMultiply, "Keypad *", "KP_MULTIPLY" },
KeyInfo { Key::KeypadSubtract, "Keypad -", "KP_SUBTRACT" },
KeyInfo { Key::KeypadAdd, "Keypad +", "KP_ADD" },
KeyInfo { Key::KeypadEnter, "Keypad Enter", "KP_ENTER" },
KeyInfo { Key::LeftShift, "Left Shift", "LEFT_SHIFT" },
KeyInfo { Key::LeftControl, "Left Control", "LEFT_CONTROL" },
KeyInfo { Key::LeftAlt, "Left Alt", "LEFT_ALT" },
KeyInfo { Key::LeftSuper, "Left Super", "LEFT_SUPER" },
KeyInfo { Key::RightShift, "Right Shift", "RIGHT_SHIFT" },
KeyInfo { Key::RightControl, "Right Control", "RIGHT_CONTROL" },
KeyInfo { Key::RightAlt, "Right Alt", "RIGHT_ALT" },
KeyInfo { Key::RightSuper, "Right Super", "RIGHT_SUPER" },
KeyInfo { Key::Menu, "Menu", "MENU" }
};
//////////////////////////////////////////////////////////////////////////////////////////
struct KeyWithModifier {
Key key;
KeyModifier modifier;
Key key = Key::Unknown;
KeyModifier modifier = KeyModifier::None;
};
constexpr inline bool isKeypadKey(Key key) noexcept {
return key == Key::Keypad0 || key == Key::Keypad1 || key == Key::Keypad2 ||
key == Key::Keypad3 || key == Key::Keypad4 || key == Key::Keypad5 ||
key == Key::Keypad6 || key == Key::Keypad7 || key == Key::Keypad8 ||
key == Key::Keypad9 || key == Key::KeypadEnter || key == Key::KeypadAdd ||
key == Key::KeypadSubtract || key == Key::KeypadMultiply ||
key == Key::KeypadDivide;
}
KeyWithModifier stringToKey(std::string str);
bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs);
bool operator==(const KeyWithModifier& lhs, const KeyWithModifier& rhs);
std::string keyToString(KeyWithModifier keyWithModifier);
static const std::map<std::string, KeyModifier> KeyModifierMapping = {
{ "SHIFT", KeyModifier::Shift },
{ "ALT", KeyModifier::Alt },
{ "CTRL", KeyModifier::Control },
{ "SUPER", KeyModifier::Super }
};
// @TODO (abock, 2021-08-12) This function should die
constexpr bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs) noexcept
{
if (lhs.modifier == rhs.modifier) {
return lhs.key < rhs.key;
}
else {
return lhs.modifier < rhs.modifier;
}
}
static const std::map<std::string, Key> KeyMapping = {
{ "0", Key::Num0 },
{ "1", Key::Num1 },
{ "2", Key::Num2 },
{ "3", Key::Num3 },
{ "4", Key::Num4 },
{ "5", Key::Num5 },
{ "6", Key::Num6 },
{ "7", Key::Num7 },
{ "8", Key::Num8 },
{ "9", Key::Num9 },
{ "A", Key::A },
{ "B", Key::B },
{ "C", Key::C },
{ "D", Key::D },
{ "E", Key::E },
{ "F", Key::F },
{ "G", Key::G },
{ "H", Key::H },
{ "I", Key::I },
{ "J", Key::J },
{ "K", Key::K },
{ "L", Key::L },
{ "M", Key::M },
{ "N", Key::N },
{ "O", Key::O },
{ "P", Key::P },
{ "Q", Key::Q },
{ "R", Key::R },
{ "S", Key::S },
{ "T", Key::T },
{ "U", Key::U },
{ "V", Key::V },
{ "W", Key::W },
{ "X", Key::X },
{ "Y", Key::Y },
{ "Z", Key::Z },
{ "LeftBracket", Key::LeftBracket },
{ "LEFTBRACKET", Key::LeftBracket },
{ "LEFT_BRACKET", Key::LeftBracket },
{ "Backslash", Key::BackSlash },
{ "BACKSLASH", Key::BackSlash },
{ "RightBracket", Key::RightBracket },
{ "RIGHTBRACKET", Key::RightBracket },
{ "RIGHT_BRACKET", Key::RightBracket },
{ "GraveAccent", Key::GraveAccent },
{ "GRAVEACCENT", Key::GraveAccent },
{ "GRAVE_ACCENT", Key::GraveAccent },
{ "Space", Key::Space },
{ "SPACE", Key::Space },
{ "Apostrophe", Key::Apostrophe },
{ "APOSTROPHE", Key::Apostrophe },
{ "Comma", Key::Comma },
{ "COMMA", Key::Comma },
{ "Minus", Key::Minus },
{ "MINUS", Key::Minus },
{ "Period", Key::Period },
{ "PERIOD", Key::Period },
{ "Slash", Key::Slash },
{ "SLASH", Key::Slash },
{ "Semicolon", Key::SemiColon },
{ "SEMICOLON", Key::SemiColon },
{ "SEMI COLON", Key::SemiColon },
{ "Equal", Key::Equal },
{ "EQUAL", Key::Equal },
{ "World1", Key::World1 },
{ "WORLD1", Key::World1 },
{ "WORLD_1", Key::World1 },
{ "World2", Key::World2 },
{ "WORLD2", Key::World2 },
{ "WORLD_2", Key::World2 },
{ "Esc", Key::Escape },
{ "ESC", Key::Escape },
{ "ESCAPE", Key::Escape},
{ "Enter", Key::Enter },
{ "ENTER", Key::Enter },
{ "Tab", Key::Tab },
{ "TAB", Key::Tab },
{ "Backspace", Key::BackSpace },
{ "BACKSPACE", Key::BackSpace },
{ "Insert", Key::Insert },
{ "INSERT", Key::Insert },
{ "DEL", Key::Delete },
{ "Delete", Key::Delete },
{ "DELETE", Key::Delete },
{ "Right", Key::Right },
{ "RIGHT", Key::Right },
{ "Left", Key::Left },
{ "LEFT", Key::Left },
{ "Down", Key::Down },
{ "DOWN", Key::Down },
{ "Up", Key::Up },
{ "UP", Key::Up },
{ "PageUp", Key::PageUp },
{ "PAGEUP", Key::PageUp },
{ "PAGE_UP", Key::PageUp },
{ "PageDown", Key::PageDown },
{ "PAGEDOWN", Key::PageDown },
{ "PAGE_DOWN", Key::PageDown },
{ "Home", Key::Home },
{ "HOME", Key::Home },
{ "End", Key::End },
{ "END", Key::End },
{ "CapsLock", Key::CapsLock },
{ "CAPSLOCK", Key::CapsLock },
{ "CAPS_LOCK", Key::CapsLock },
{ "ScrollLock", Key::ScrollLock },
{ "SCROLLLOCK", Key::ScrollLock },
{ "SCROLL_LOCK", Key::ScrollLock },
{ "NumLock", Key::NumLock },
{ "NUMLOCK", Key::NumLock },
{ "NUM_LOCK", Key::NumLock },
{ "PrintScreen", Key::PrintScreen },
{ "PRINTSCREEN", Key::PrintScreen },
{ "PRINT_SCREEN", Key::PrintScreen },
{ "Pause", Key::Pause },
{ "PAUSE", Key::Pause },
{ "F1", Key::F1 },
{ "F2", Key::F2 },
{ "F3", Key::F3 },
{ "F4", Key::F4 },
{ "F5", Key::F5 },
{ "F6", Key::F6 },
{ "F7", Key::F7 },
{ "F8", Key::F8 },
{ "F9", Key::F9 },
{ "F10", Key::F10 },
{ "F11", Key::F11 },
{ "F12", Key::F12 },
{ "F13", Key::F13 },
{ "F14", Key::F14 },
{ "F15", Key::F15 },
{ "F16", Key::F16 },
{ "F17", Key::F17 },
{ "F18", Key::F18 },
{ "F19", Key::F19 },
{ "F20", Key::F20 },
{ "F21", Key::F21 },
{ "F22", Key::F22 },
{ "F23", Key::F23 },
{ "F24", Key::F24 },
{ "F25", Key::F25 },
{ "Keypad0", Key::Keypad0 },
{ "KP0", Key::Keypad0 },
{ "KP_0", Key::Keypad0 },
{ "Keypad1", Key::Keypad1 },
{ "KP1", Key::Keypad1 },
{ "KP_1", Key::Keypad1 },
{ "Keypad2", Key::Keypad2 },
{ "KP2", Key::Keypad2 },
{ "KP_2", Key::Keypad2 },
{ "Keypad3", Key::Keypad3 },
{ "KP3", Key::Keypad3 },
{ "KP_3", Key::Keypad3 },
{ "Keypad4", Key::Keypad4 },
{ "KP4", Key::Keypad4 },
{ "KP_4", Key::Keypad4 },
{ "Keypad5", Key::Keypad5 },
{ "KP5", Key::Keypad5 },
{ "KP_5", Key::Keypad5 },
{ "Keypad6", Key::Keypad6 },
{ "KP6", Key::Keypad6 },
{ "KP_6", Key::Keypad6 },
{ "Keypad7", Key::Keypad7 },
{ "KP7", Key::Keypad7 },
{ "KP_7", Key::Keypad7 },
{ "Keypad8", Key::Keypad8 },
{ "KP8", Key::Keypad8 },
{ "KP_8", Key::Keypad8 },
{ "Keypad9", Key::Keypad9 },
{ "KP9", Key::Keypad9 },
{ "KP_9", Key::Keypad9 },
{ "KeypadDecimal", Key::KeypadDecimal },
{ "KPDECIMAL", Key::KeypadDecimal },
{ "KP_DECIMAL", Key::KeypadDecimal },
{ "KeypadDivide", Key::KeypadDivide },
{ "KPDIVIDE", Key::KeypadDivide },
{ "KP_DIVIDE", Key::KeypadDivide },
{ "KeypadMultiply", Key::KeypadMultiply },
{ "KPMULTIPLY", Key::KeypadMultiply },
{ "KP_MULTIPLY", Key::KeypadMultiply },
{ "KeypadSubtract", Key::KeypadSubtract },
{ "KPSUBTRACT", Key::KeypadSubtract },
{ "KP_SUBTRACT", Key::KeypadSubtract },
{ "KeypadAdd", Key::KeypadAdd },
{ "KPADD", Key::KeypadAdd },
{ "KP_ADD", Key::KeypadAdd },
{ "KeypadEnter", Key::KeypadEnter },
{ "KPENTER", Key::KeypadEnter },
{ "KP_ENTER", Key::KeypadEnter },
{ "KeypadEqual", Key::KeypadEnter },
{ "KPEQUAL", Key::KeypadEnter },
{ "KP_EQUAL", Key::KeypadEnter },
{ "LeftShift", Key::LeftShift },
{ "LSHIFT", Key::LeftShift },
{ "LEFTSHIFT", Key::LeftShift },
{ "LEFT_SHIFT", Key::LeftShift },
{ "LeftControl", Key::LeftControl },
{ "LCTRL", Key::LeftControl },
{ "LEFTCONTROL", Key::LeftControl },
{ "LEFT_CONTROL", Key::LeftControl },
{ "LeftAlt", Key::LeftAlt },
{ "LALT", Key::LeftAlt },
{ "LEFTALT", Key::LeftAlt },
{ "LEFT_ALT", Key::LeftAlt },
{ "LeftSuper", Key::LeftSuper },
{ "LEFTSUPER", Key::LeftSuper },
{ "LEFT_SUPER", Key::LeftSuper },
{ "RightShift", Key::RightShift },
{ "RSHIFT", Key::RightShift },
{ "RIGHTSHIFT", Key::RightShift },
{ "RIGHT_SHIFT", Key::RightShift },
{ "RightControl", Key::RightControl },
{ "RCTRL", Key::RightControl },
{ "RIGHTCONTROL", Key::RightControl },
{ "RIGHT_CONTROL", Key::RightControl },
{ "RightAlt", Key::RightAlt },
{ "RALT", Key::RightAlt },
{ "RIGHTALT", Key::RightAlt },
{ "RIGHT_ALT", Key::RightAlt },
{ "RightSuper", Key::RightSuper },
{ "RIGHTSUPER", Key::RightSuper },
{ "RIGHT_SUPER", Key::RightSuper },
{ "Menu", Key::Menu },
{ "MENU", Key::Menu }
};
constexpr bool operator==(const KeyWithModifier& lhs, const KeyWithModifier& rhs) noexcept
{
return (lhs.key == rhs.key) && (lhs.modifier == rhs.modifier);
}
} // namespace openspace
+48
View File
@@ -0,0 +1,48 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___UNIVERSALHELPERS___H__
#define __OPENSPACE_CORE___UNIVERSALHELPERS___H__
/*
* This file is meant to contain generally useful functions that is used a bit all over
* the place but that do not belong in any other, more specific, file.
*
* If you implement a function that can be useful in several other situations, feel free
* to document it and put it this file
*/
namespace openspace::helpers {
/*
* Remap a parameter t in [0,1] to a subinterval [start, end], by shifting and scaling
* the value to match the interval. If \p t is smaller than \p start, the return value
* will be 0 and if bigger than \p end it will be 1. Other values will be linearly
* interpolated within the range [start, end]
*/
double shiftAndScale(double t, double start, double end);
} // namespace openspace::helpers
#endif // __OPENSPACE_CORE___UNIVERSALHELPERS___H__
+1 -1
View File
@@ -25,7 +25,7 @@
#ifndef __OPENSPACE_CORE___UPDATESTRUCTURES___H__
#define __OPENSPACE_CORE___UPDATESTRUCTURES___H__
#include <openspace/util/camera.h>
#include <openspace/camera/camera.h>
#include <openspace/util/time.h>
namespace openspace {