mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 11:08:06 +02:00
add camera sensitivity slider
This commit is contained in:
parent
9546cebe3c
commit
e4f32f1cea
3 changed files with 28 additions and 2 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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); };
|
||||
|
|
|
@ -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 <code>x, y</code> 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
|
||||
|
|
Loading…
Reference in a new issue