diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 795325d761..d8c4dde1a8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6351,8 +6351,8 @@ void Application::update(float deltaTime) { if (deltaTime > FLT_EPSILON && userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z) == 0.0f) { myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH)); myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW)); - myAvatar->setDriveKey(MyAvatar::DELTA_PITCH, -1.0f * userInputMapper->getActionState(controller::Action::DELTA_PITCH)); - myAvatar->setDriveKey(MyAvatar::DELTA_YAW, -1.0f * userInputMapper->getActionState(controller::Action::DELTA_YAW)); + myAvatar->setDriveKey(MyAvatar::DELTA_PITCH, -_myCamera.getSensitivity() * userInputMapper->getActionState(controller::Action::DELTA_PITCH)); + myAvatar->setDriveKey(MyAvatar::DELTA_YAW, -_myCamera.getSensitivity() * userInputMapper->getActionState(controller::Action::DELTA_YAW)); myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW)); } } diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 9f8a8ec013..79d9ebaa5c 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -358,6 +358,16 @@ void setupPreferences() { preference->setItems(items); preferences->addPreference(preference); } + { + auto getter = [myAvatar]()->float { return qApp->getCamera().getSensitivity(); }; + auto setter = [myAvatar](float value) { qApp->getCamera().setSensitivity(value); }; + auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter); + preference->setMin(0.01f); + preference->setMax(5.0f); + preference->setStep(0.1); + preference->setDecimals(2); + preferences->addPreference(preference); + } { auto getter = [myAvatar]()->int { return myAvatar->getControlScheme(); }; auto setter = [myAvatar](int index) { myAvatar->setControlScheme(index); }; diff --git a/libraries/shared/src/shared/Camera.h b/libraries/shared/src/shared/Camera.h index 0dc8703b2d..f6ce9be2d8 100644 --- a/libraries/shared/src/shared/Camera.h +++ b/libraries/shared/src/shared/Camera.h @@ -45,6 +45,7 @@ class Camera : public QObject { Q_PROPERTY(QString mode READ getModeString WRITE setModeString NOTIFY modeUpdated) Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT) Q_PROPERTY(bool captureMouse READ getCaptureMouse WRITE setCaptureMouse NOTIFY captureMouseUpdated) + Q_PROPERTY(float sensitivity READ getSensitivity WRITE setSensitivity) public: Camera(); @@ -128,6 +129,20 @@ public slots: */ void setCaptureMouse(bool captureMouse) { _captureMouse = captureMouse; emit captureMouseUpdated(captureMouse); } + /**jsdoc + * Gets the current camera sensitivity. + * @function Camera.getSensitivity + * @returns {boolean} The current camera sensitivity. + */ + float getSensitivity() const { return _sensitivity; } + + /**jsdoc + * Sets the camera sensitivity. Higher values mean that the camera will be more sensitive to mouse movements. + * @function Camera.setSensitivity + * @param {boolean} sensitivity - The desired camera sensitivity. + */ + void setSensitivity(float sensitivity) { _sensitivity = glm::max(0.0f, sensitivity); } + /**jsdoc * Computes a {@link PickRay} based on the current camera configuration and the specified x, y position on the * screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and @@ -228,6 +243,7 @@ private: glm::vec3 _lookingAt; bool _captureMouse { false }; + float _sensitivity { 1.0f }; }; #endif // hifi_Camera_h