mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Compute only when delta is not zero
This commit is contained in:
parent
8a6cb93a84
commit
793b2917f6
1 changed files with 14 additions and 10 deletions
|
@ -3419,19 +3419,23 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
_lookAtOffsetYaw = getWorldOrientation();
|
||||
_lookAtOffsetPitch = Quaternions::IDENTITY;
|
||||
} else {
|
||||
// Set look at vector
|
||||
// Compute new look at vectors
|
||||
if (totalBodyYaw > 0.0f) {
|
||||
_lookAtOffsetYaw = _lookAtOffsetYaw * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f)));
|
||||
}
|
||||
float pitchIncrement = getDriveKey(PITCH) * _pitchSpeed * deltaTime
|
||||
+ getDriveKey(DELTA_PITCH) * _pitchSpeed / PITCH_SPEED_DEFAULT;
|
||||
_lookAtOffsetYaw = _lookAtOffsetYaw * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f)));
|
||||
|
||||
glm::quat _previousLookAtOffsetPitch = _lookAtOffsetPitch;
|
||||
_lookAtOffsetPitch = _lookAtOffsetPitch * glm::quat(glm::radians(glm::vec3(pitchIncrement, 0.0f, 0.0f)));
|
||||
// Limit the camera horizontal pitch
|
||||
float MAX_LOOK_AT_PITCH_DEGREES = 80.0f;
|
||||
float pitchFromHorizont = glm::degrees(angleBetween(getLookAtOffset() * Vectors::FRONT, _lookAtOffsetYaw * Vectors::FRONT));
|
||||
if (pitchFromHorizont > MAX_LOOK_AT_PITCH_DEGREES || pitchFromHorizont < -MAX_LOOK_AT_PITCH_DEGREES) {
|
||||
_lookAtOffsetPitch = _previousLookAtOffsetPitch;
|
||||
if (pitchIncrement > 0.0f) {
|
||||
glm::quat _previousLookAtOffsetPitch = _lookAtOffsetPitch;
|
||||
_lookAtOffsetPitch = _lookAtOffsetPitch * glm::quat(glm::radians(glm::vec3(pitchIncrement, 0.0f, 0.0f)));
|
||||
// Limit the camera horizontal pitch
|
||||
float MAX_LOOK_AT_PITCH_DEGREES = 80.0f;
|
||||
float pitchFromHorizont = glm::degrees(angleBetween(getLookAtOffset() * Vectors::FRONT, _lookAtOffsetYaw * Vectors::FRONT));
|
||||
if (pitchFromHorizont > MAX_LOOK_AT_PITCH_DEGREES || pitchFromHorizont < -MAX_LOOK_AT_PITCH_DEGREES) {
|
||||
_lookAtOffsetPitch = _previousLookAtOffsetPitch;
|
||||
}
|
||||
}
|
||||
|
||||
// Blend the avatar orientation with the camera look at if moving forward.
|
||||
if (faceForward) {
|
||||
const float FACE_FORWARD_BLEND = 0.25f;
|
||||
|
|
Loading…
Reference in a new issue