mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
Limit rotation while seated to not trigger recentering
This commit is contained in:
parent
bd488f0196
commit
7c55cee1f0
1 changed files with 13 additions and 5 deletions
|
@ -3510,6 +3510,12 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
float timeScale = deltaTime * FPS;
|
float timeScale = deltaTime * FPS;
|
||||||
|
|
||||||
bool faceForward = false;
|
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) {
|
if (!computeLookAt) {
|
||||||
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
||||||
_lookAtCameraTarget = eyesPosition + getWorldOrientation() * Vectors::FRONT;
|
_lookAtCameraTarget = eyesPosition + getWorldOrientation() * Vectors::FRONT;
|
||||||
|
@ -3532,9 +3538,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
_lookAtPitch = _previousLookAtPitch;
|
_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);
|
faceForward = isMovingFwdBwd || (isMovingSideways && !isRotatingWhileSeated);
|
||||||
// Blend the avatar orientation with the camera look at if moving forward.
|
// Blend the avatar orientation with the camera look at if moving forward.
|
||||||
if (faceForward || _shouldTurnToFaceCamera) {
|
if (faceForward || _shouldTurnToFaceCamera) {
|
||||||
|
@ -3619,8 +3623,12 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
if (frontBackDot < 0.0f) {
|
if (frontBackDot < 0.0f) {
|
||||||
ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight);
|
ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight);
|
||||||
cameraVector = (ajustedYawVector * _lookAtPitch) * Vectors::FRONT;
|
cameraVector = (ajustedYawVector * _lookAtPitch) * Vectors::FRONT;
|
||||||
if (frontBackDot < -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE))) {
|
if (!isRotatingWhileSeated) {
|
||||||
_shouldTurnToFaceCamera = true;
|
if (frontBackDot < -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE))) {
|
||||||
|
_shouldTurnToFaceCamera = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setWorldOrientation(previousOrientation);
|
||||||
}
|
}
|
||||||
} else if (frontBackDot > glm::sin(glm::radians(REORIENT_ANGLE))) {
|
} else if (frontBackDot > glm::sin(glm::radians(REORIENT_ANGLE))) {
|
||||||
_shouldTurnToFaceCamera = false;
|
_shouldTurnToFaceCamera = false;
|
||||||
|
|
Loading…
Reference in a new issue