Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar auto scale: match avatar eye height to user eye height. #942

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion interface/resources/qml/hifi/avatarapp/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ Rectangle {
Layout.alignment: Qt.AlignVCenter
}
}
}

RowLayout {
id: avatarScaleButtonsRow
anchors.top: avatarScaleRow.bottom

ShadowRectangle {
width: 37
Expand All @@ -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: 50
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: "Auto"
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);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions interface/src/avatar/MyAvatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
8 changes: 8 additions & 0 deletions interface/src/avatar/MyAvatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down