Limit rotation while seated to not trigger recentering

This commit is contained in:
luiscuenca 2019-09-30 17:37:14 -07:00
parent bd488f0196
commit 7c55cee1f0
No known key found for this signature in database
GPG key ID: 2387ECD129A6961D

View file

@ -3510,6 +3510,12 @@ void MyAvatar::updateOrientation(float deltaTime) {
float timeScale = deltaTime * FPS;
bool faceForward = false;
bool isMovingFwdBwd = getDriveKey(TRANSLATE_Z) != 0.0f;
bool isMovingSideways = getDriveKey(TRANSLATE_X) != 0.0f;
bool isCameraYawing = getDriveKey(DELTA_YAW) + getDriveKey(STEP_YAW) + getDriveKey(YAW) != 0.0f;
bool isRotatingWhileSeated = !isCameraYawing && isMovingSideways && _characterController.getSeated();
glm::quat previousOrientation = getWorldOrientation();
if (!computeLookAt) {
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
_lookAtCameraTarget = eyesPosition + getWorldOrientation() * Vectors::FRONT;
@ -3532,9 +3538,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
_lookAtPitch = _previousLookAtPitch;
}
}
bool isMovingFwdBwd = getDriveKey(TRANSLATE_Z) != 0.0f;
bool isMovingSideways = getDriveKey(TRANSLATE_X) != 0.0f;
bool isRotatingWhileSeated = isMovingSideways && _characterController.getSeated();
faceForward = isMovingFwdBwd || (isMovingSideways && !isRotatingWhileSeated);
// Blend the avatar orientation with the camera look at if moving forward.
if (faceForward || _shouldTurnToFaceCamera) {
@ -3619,8 +3623,12 @@ void MyAvatar::updateOrientation(float deltaTime) {
if (frontBackDot < 0.0f) {
ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight);
cameraVector = (ajustedYawVector * _lookAtPitch) * Vectors::FRONT;
if (frontBackDot < -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE))) {
_shouldTurnToFaceCamera = true;
if (!isRotatingWhileSeated) {
if (frontBackDot < -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE))) {
_shouldTurnToFaceCamera = true;
}
} else {
setWorldOrientation(previousOrientation);
}
} else if (frontBackDot > glm::sin(glm::radians(REORIENT_ANGLE))) {
_shouldTurnToFaceCamera = false;