mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +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;
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue