mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 11:09:37 -06:00
Move abstract function updateStateFromInput to the concrete classes
This commit is contained in:
@@ -42,8 +42,6 @@ public:
|
||||
CameraInteractionStates(double sensitivity, double velocityScaleFactor);
|
||||
virtual ~CameraInteractionStates() = default;
|
||||
|
||||
virtual void updateStateFromInput(const InputState& inputState, double deltaTime) = 0;
|
||||
|
||||
void setRotationalFriction(double friction);
|
||||
void setHorizontalFriction(double friction);
|
||||
void setVerticalFriction(double friction);
|
||||
|
||||
@@ -74,7 +74,8 @@ public:
|
||||
|
||||
JoystickCameraStates(double sensitivity, double velocityScaleFactor);
|
||||
|
||||
void updateStateFromInput(const InputState& inputState, double deltaTime) override;
|
||||
void updateStateFromInput(
|
||||
const JoystickInputStates& joystickInputStates, double deltaTime);
|
||||
|
||||
void setAxisMapping(int axis, AxisType mapping,
|
||||
AxisInvert shouldInvert = AxisInvert::No,
|
||||
|
||||
@@ -33,7 +33,7 @@ class MouseCameraStates : public CameraInteractionStates {
|
||||
public:
|
||||
MouseCameraStates(double sensitivity, double velocityScaleFactor);
|
||||
|
||||
void updateStateFromInput(const InputState& inputState, double deltaTime) override;
|
||||
void updateStateFromInput(const InputState& inputState, double deltaTime);
|
||||
|
||||
void setInvertMouseButton(bool value);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class ScriptCameraStates : public CameraInteractionStates {
|
||||
public:
|
||||
ScriptCameraStates();
|
||||
|
||||
void updateStateFromInput(const InputState& inputState, double deltaTime) override;
|
||||
void updateStateFromInput(double deltaTime);
|
||||
|
||||
void addLocalRotation(const glm::dvec2& delta);
|
||||
void addGlobalRotation(const glm::dvec2& delta);
|
||||
|
||||
@@ -65,7 +65,8 @@ public:
|
||||
|
||||
WebsocketCameraStates(double sensitivity, double velocityScaleFactor);
|
||||
|
||||
void updateStateFromInput(const InputState& inputState, double deltaTime) override;
|
||||
void updateStateFromInput(
|
||||
const WebsocketInputStates& websocketInputStates, double deltaTime);
|
||||
|
||||
void setAxisMapping(int axis, AxisType mapping,
|
||||
AxisInvert shouldInvert = AxisInvert::No,
|
||||
|
||||
@@ -37,7 +37,8 @@ JoystickCameraStates::JoystickCameraStates(double sensitivity, double velocitySc
|
||||
: CameraInteractionStates(sensitivity, velocityScaleFactor)
|
||||
{}
|
||||
|
||||
void JoystickCameraStates::updateStateFromInput(const InputState& inputState,
|
||||
void JoystickCameraStates::updateStateFromInput(
|
||||
const JoystickInputStates& joystickInputStates,
|
||||
double deltaTime)
|
||||
{
|
||||
std::pair<bool, glm::dvec2> globalRotation = { false, glm::dvec2(0.0) };
|
||||
@@ -52,7 +53,7 @@ void JoystickCameraStates::updateStateFromInput(const InputState& inputState,
|
||||
continue;
|
||||
}
|
||||
|
||||
float rawValue = inputState.joystickAxis(i);
|
||||
float rawValue = joystickInputStates.axis(i);
|
||||
float value = rawValue;
|
||||
|
||||
if (t.isSticky) {
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace openspace::interaction {
|
||||
|
||||
ScriptCameraStates::ScriptCameraStates() : CameraInteractionStates(1.0, 1.0) {}
|
||||
|
||||
void ScriptCameraStates::updateStateFromInput(const InputState&, double deltaTime) {
|
||||
void ScriptCameraStates::updateStateFromInput(double deltaTime) {
|
||||
if (_localRotation != glm::dvec2(0.0)) {
|
||||
_localRotationState.velocity.set(
|
||||
_localRotation * _sensitivity,
|
||||
|
||||
@@ -39,7 +39,8 @@ WebsocketCameraStates::WebsocketCameraStates(double sensitivity,
|
||||
: CameraInteractionStates(sensitivity, velocityScaleFactor)
|
||||
{}
|
||||
|
||||
void WebsocketCameraStates::updateStateFromInput(const InputState& inputState,
|
||||
void WebsocketCameraStates::updateStateFromInput(
|
||||
const WebsocketInputStates& websocketInputStates,
|
||||
double deltaTime)
|
||||
{
|
||||
std::pair<bool, glm::dvec2> globalRotation = { false, glm::dvec2(0.0) };
|
||||
@@ -48,14 +49,14 @@ void WebsocketCameraStates::updateStateFromInput(const InputState& inputState,
|
||||
std::pair<bool, glm::dvec2> globalRoll = { false, glm::dvec2(0.0) };
|
||||
std::pair<bool, glm::dvec2> localRotation = { false, glm::dvec2(0.0) };
|
||||
|
||||
if (inputState.hasWebsocketStates()) {
|
||||
if (!websocketInputStates.empty()) {
|
||||
for (int i = 0; i < WebsocketInputState::MaxAxes; ++i) {
|
||||
AxisInformation t = _axisMapping[i];
|
||||
if (t.type == AxisType::None) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float value = inputState.websocketAxis(i);
|
||||
float value = websocketInputStates.axis(i);
|
||||
bool hasValue = std::fabs(value) > t.deadzone;
|
||||
|
||||
if (!hasValue) {
|
||||
|
||||
@@ -547,9 +547,9 @@ void OrbitalNavigator::updateStatesFromInput(const InputState& inputState,
|
||||
double deltaTime)
|
||||
{
|
||||
_mouseStates.updateStateFromInput(inputState, deltaTime);
|
||||
_joystickStates.updateStateFromInput(inputState, deltaTime);
|
||||
_websocketStates.updateStateFromInput(inputState, deltaTime);
|
||||
_scriptStates.updateStateFromInput(inputState, deltaTime);
|
||||
_joystickStates.updateStateFromInput(*global::joystickInputStates, deltaTime);
|
||||
_websocketStates.updateStateFromInput(*global::websocketInputStates, deltaTime);
|
||||
_scriptStates.updateStateFromInput(deltaTime);
|
||||
|
||||
bool interactionHappened = _mouseStates.hasNonZeroVelocities() ||
|
||||
_joystickStates.hasNonZeroVelocities() ||
|
||||
|
||||
Reference in New Issue
Block a user