From dec9e9d3380c4c03e4997d254170a16273f5d7fb Mon Sep 17 00:00:00 2001 From: Phil Palmer Date: Sun, 27 Dec 2020 02:50:29 -0500 Subject: [PATCH] VR fix for different avatar scales. Previously, if the avatar scale wasn't 1, the body and viewpoint would given the wrong vertical position in some situations, eg: getting up from click-to-sit; changing the 'Allow my avatar to stand' setting. The avatar scale was being taken into account where it shouldn't have in MyAvatar::deriveBodyFromHMDSensor. The bug started in 8b839fe71b9a2d412100d61671fbd1d71cb6d8c9 ("VR fixes for different user heights and avatar scales". Repro: 1. Set 'Allow my avatar to stand: Always' 2. Reduce the avatar scale to the minumum. 3. Set 'Allow my avatar to stand: When I stand' 4. Previously, the viewpoint would suddenly be below the floor. --- interface/src/avatar/MyAvatar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 4694df155e..72d6190f66 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -4845,7 +4845,8 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor(const bool forceFollowYPos) const { if (!forceFollowYPos && !getHMDCrouchRecenterEnabled()) { // Set the body's vertical position as if it were standing in its T-pose. - bodyPos.y = worldToSensorScale * rig.getUnscaledHipsHeight(); + const float userToRigScale = getUserEyeHeight() / getUnscaledEyeHeight(); + bodyPos.y = userToRigScale * rig.getUnscaledHipsHeight(); } glm::mat4 bodyMat = createMatFromQuatAndPos(bodyQuat, bodyPos);