diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index e5413105f8..be5fa39e1b 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -497,14 +497,18 @@ void MyAvatar::resetSensorsAndBody() { reset(true, false, true); } -// forceFollowYPos: true to force the body matrix to be affected by the HMD's -// vertical position, even if crouch recentering is disabled. -void MyAvatar::centerBody(const bool forceFollowYPos) { +void MyAvatar::centerBody() { if (QThread::currentThread() != thread()) { QMetaObject::invokeMethod(this, "centerBody"); return; } + centerBodyInternal(false); +} + +// forceFollowYPos (default false): true to force the body matrix to be affected by the HMD's +// vertical position, even if crouch recentering is disabled. +void MyAvatar::centerBodyInternal(const bool forceFollowYPos) { // derive the desired body orientation from the current hmd orientation, before the sensor reset. auto newBodySensorMatrix = deriveBodyFromHMDSensor(forceFollowYPos); // Based on current cached HMD position/rotation.. @@ -5323,7 +5327,7 @@ void MyAvatar::setAllowAvatarStandingPreference(const MyAvatar::AllowAvatarStand // Set the correct vertical position for the avatar body relative to the HMD, // according to the newly-selected avatar standing preference. - centerBody(false); + centerBodyInternal(false); } // Set the user preference of when the avatar may lean. @@ -6693,7 +6697,7 @@ void MyAvatar::beginSit(const glm::vec3& position, const glm::quat& rotation) { setHMDLeanRecenterEnabled(false); // Disable movement setSitDriveKeysStatus(false); - centerBody(true); + centerBodyInternal(true); int hipIndex = getJointIndex("Hips"); clearPinOnJoint(hipIndex); pinJoint(hipIndex, position, rotation); @@ -6711,7 +6715,7 @@ void MyAvatar::endSit(const glm::vec3& position, const glm::quat& rotation) { _characterController.setSeated(false); setCollisionsEnabled(true); setHMDLeanRecenterEnabled(true); - centerBody(false); + centerBodyInternal(false); slamPosition(position); setWorldOrientation(rotation); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 9e817b5167..c06a1a88ab 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -594,7 +594,7 @@ public: * the HMD. * @function MyAvatar.centerBody */ - Q_INVOKABLE void centerBody(const bool forceFollowYPos); // thread-safe + Q_INVOKABLE void centerBody(); // thread-safe /**jsdoc @@ -2812,6 +2812,7 @@ private: void resetLookAtRotation(const glm::vec3& avatarPosition, const glm::quat& avatarOrientation); void resetPointAt(); static glm::vec3 aimToBlendValues(const glm::vec3& aimVector, const glm::quat& frameOrientation); + void centerBodyInternal(const bool forceFollowYPos = false); // Avatar Preferences QUrl _fullAvatarURLFromPreferences;