diff --git a/interface/resources/qml/hifi/avatarapp/Settings.qml b/interface/resources/qml/hifi/avatarapp/Settings.qml index 4d4a0ee8094..8c8f558fa54 100644 --- a/interface/resources/qml/hifi/avatarapp/Settings.qml +++ b/interface/resources/qml/hifi/avatarapp/Settings.qml @@ -178,9 +178,14 @@ Rectangle { Layout.alignment: Qt.AlignVCenter } } + } + + RowLayout { + id: avatarScaleButtonsRow + anchors.top: avatarScaleRow.bottom ShadowRectangle { - width: 37 + width: 31 height: 28 AvatarAppStyle { id: style @@ -203,7 +208,43 @@ Rectangle { MouseArea { anchors.fill: parent onClicked: { - scaleSlider.value = 10 + scaleSlider.notify = false; + scaleSlider.value = 10; + scaleSlider.notify = true; + root.scaleChanged(1.0); + } + } + } + + ShadowRectangle { + width: 107 + height: 28 + AvatarAppStyle { + id: style2 + } + + gradient: Gradient { + GradientStop { position: 0.0; color: style2.colors.blueHighlight } + GradientStop { position: 1.0; color: style2.colors.blueAccent } + } + + radius: 3 + + RalewaySemiBold { + color: 'white' + anchors.centerIn: parent + text: "Real Height" + size: 18 + } + + MouseArea { + anchors.fill: parent + onClicked: { + scaleValue = MyAvatar.getAutoAvatarScale(); + scaleSlider.notify = false; + scaleSlider.value = Math.round(scaleValue * 10); + scaleSlider.notify = true; + root.scaleChanged(scaleValue); } } } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b3231b906db..1030d78817d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -4566,6 +4566,12 @@ float MyAvatar::getAvatarScale() { return getTargetScale(); } +// Gets the scale for the avatar that makes the avatar's eye height match the user's real-world eye height +// (derived from the 'User real world height' Interface setting). +float MyAvatar::getAutoAvatarScale() const { + return getUserEyeHeight() / getUnscaledEyeHeight(); +} + void MyAvatar::setAvatarScale(float val) { if (QThread::currentThread() != thread()) { diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 3140c68f88a..9d4524bda27 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -1598,6 +1598,14 @@ class MyAvatar : public Avatar { */ Q_INVOKABLE float getAvatarScale(); + /**jsdoc + * Gets the scale for the avatar that makes the avatar's eye height match the user's real-world eye height (derived from + * the "User real world height" Interface setting). + * @function MyAvatar.getAutoAvatarScale + * @returns {number} The scale for the avatar that makes the avatar's eye height match the user's real-world eye height. + */ + Q_INVOKABLE float getAutoAvatarScale() const; + /**jsdoc * Sets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on * permissible scale values imposed by the domain.