mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
Add recenter timer and temp API
This commit is contained in:
parent
0fac1e134f
commit
18af7c5d84
2 changed files with 57 additions and 6 deletions
|
@ -3619,17 +3619,18 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
glm::vec3 avatarVectorRight = getWorldOrientation() * Vectors::RIGHT;
|
glm::vec3 avatarVectorRight = getWorldOrientation() * Vectors::RIGHT;
|
||||||
float leftRightDot = glm::dot(cameraYawVector, avatarVectorRight);
|
float leftRightDot = glm::dot(cameraYawVector, avatarVectorRight);
|
||||||
|
|
||||||
const float REORIENT_ANGLE = 65.0f;
|
const float DEFAULT_REORIENT_ANGLE = 65.0f;
|
||||||
|
const float FIRST_PERSON_REORIENT_ANGLE = 95.0f;
|
||||||
const float TRIGGER_REORIENT_ANGLE = 45.0f;
|
const float TRIGGER_REORIENT_ANGLE = 45.0f;
|
||||||
const float FIRST_PERSON_TRIGGER_REORIENT_ANGLE = 45.0f;
|
// const float FIRST_PERSON_TRIGGER_REORIENT_ANGLE = 45.0f;
|
||||||
glm::vec3 ajustedYawVector = cameraYawVector;
|
glm::vec3 ajustedYawVector = cameraYawVector;
|
||||||
float limitAngle = 0.0f;
|
float limitAngle = 0.0f;
|
||||||
float triggerAngle = -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE));
|
float triggerAngle = -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE));
|
||||||
if (mode == CAMERA_MODE_FIRST_PERSON) {
|
if (mode == CAMERA_MODE_FIRST_PERSON) {
|
||||||
limitAngle = glm::sin(glm::radians(FIRST_PERSON_TRIGGER_REORIENT_ANGLE));
|
limitAngle = glm::sin(glm::radians(90.0f - _recenterAngle));
|
||||||
triggerAngle = limitAngle;
|
triggerAngle = limitAngle;
|
||||||
}
|
}
|
||||||
|
float reorientAngle = mode == CAMERA_MODE_FIRST_PERSON ? FIRST_PERSON_REORIENT_ANGLE : DEFAULT_REORIENT_ANGLE;
|
||||||
if (frontBackDot < limitAngle) {
|
if (frontBackDot < limitAngle) {
|
||||||
if (frontBackDot < 0.0f) {
|
if (frontBackDot < 0.0f) {
|
||||||
ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight);
|
ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight);
|
||||||
|
@ -3637,8 +3638,9 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
}
|
}
|
||||||
if (frontBackDot < triggerAngle) {
|
if (frontBackDot < triggerAngle) {
|
||||||
_shouldTurnToFaceCamera = true;
|
_shouldTurnToFaceCamera = true;
|
||||||
|
_firstPersonSteadyHeadTimer = 0.0f;
|
||||||
}
|
}
|
||||||
} else if (frontBackDot > glm::sin(glm::radians(REORIENT_ANGLE))) {
|
} else if (frontBackDot > glm::sin(glm::radians(reorientAngle))) {
|
||||||
_shouldTurnToFaceCamera = false;
|
_shouldTurnToFaceCamera = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3660,6 +3662,22 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
_lookAtCameraTarget = targetPoint;
|
_lookAtCameraTarget = targetPoint;
|
||||||
}
|
}
|
||||||
_headLookAtActive = true;
|
_headLookAtActive = true;
|
||||||
|
// const float FIRST_PERSON_RECENTER_SECONDS = 5.0f;
|
||||||
|
if (mode == CAMERA_MODE_FIRST_PERSON) {
|
||||||
|
if (getDriveKey(YAW) + getDriveKey(STEP_YAW) + getDriveKey(DELTA_YAW) == 0.0f) {
|
||||||
|
if (_firstPersonSteadyHeadTimer < _recenterSeconds) {
|
||||||
|
if (_firstPersonSteadyHeadTimer > 0.0f) {
|
||||||
|
_firstPersonSteadyHeadTimer += deltaTime;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_shouldTurnToFaceCamera = true;
|
||||||
|
_firstPersonSteadyHeadTimer = 0.0f;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_firstPersonSteadyHeadTimer = deltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
head->setBaseYaw(0.0f);
|
head->setBaseYaw(0.0f);
|
||||||
head->setBasePitch(getHead()->getBasePitch() + getDriveKey(PITCH) * _pitchSpeed * deltaTime
|
head->setBasePitch(getHead()->getBasePitch() + getDriveKey(PITCH) * _pitchSpeed * deltaTime
|
||||||
|
@ -6754,4 +6772,30 @@ glm::vec3 MyAvatar::getLookAtPivotPoint() {
|
||||||
glm::vec3 avatarUp = getWorldOrientation() * Vectors::UP;
|
glm::vec3 avatarUp = getWorldOrientation() * Vectors::UP;
|
||||||
glm::vec3 yAxisEyePosition = getWorldPosition() + avatarUp * glm::dot(avatarUp, _skeletonModel->getDefaultEyeModelPosition());
|
glm::vec3 yAxisEyePosition = getWorldPosition() + avatarUp * glm::dot(avatarUp, _skeletonModel->getDefaultEyeModelPosition());
|
||||||
return yAxisEyePosition;
|
return yAxisEyePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap MyAvatar::getLookAtCameraData() {
|
||||||
|
QVariantMap result;
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
BLOCKING_INVOKE_METHOD(this, "getLookAtCameraData",
|
||||||
|
Q_RETURN_ARG(QVariantMap, result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result.insert("recenterSeconds", _recenterSeconds);
|
||||||
|
result.insert("recenterAngle", _recenterAngle);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE void MyAvatar::setLookAtCameraData(const QVariantMap& data) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "setLookAtCameraData",
|
||||||
|
Q_ARG(const QVariantMap&, data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.contains("recenterSeconds")) {
|
||||||
|
_recenterSeconds = data["recenterSeconds"].toFloat();
|
||||||
|
}
|
||||||
|
if (data.contains("recenterAngle")) {
|
||||||
|
_recenterAngle = data["recenterAngle"].toFloat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1857,6 +1857,9 @@ public:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE QVariantMap getFlowData();
|
Q_INVOKABLE QVariantMap getFlowData();
|
||||||
|
|
||||||
|
Q_INVOKABLE QVariantMap getLookAtCameraData();
|
||||||
|
Q_INVOKABLE void setLookAtCameraData(const QVariantMap& data);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Gets the indexes of currently colliding flow joints.
|
* Gets the indexes of currently colliding flow joints.
|
||||||
* @function MyAvatar.getCollidingFlowJoints
|
* @function MyAvatar.getCollidingFlowJoints
|
||||||
|
@ -2654,6 +2657,10 @@ private:
|
||||||
bool _shouldTurnToFaceCamera { false };
|
bool _shouldTurnToFaceCamera { false };
|
||||||
bool _scriptControlsHeadLookAt { false };
|
bool _scriptControlsHeadLookAt { false };
|
||||||
float _scriptHeadControlTimer { 0.0f };
|
float _scriptHeadControlTimer { 0.0f };
|
||||||
|
float _firstPersonSteadyHeadTimer { 0.0f };
|
||||||
|
|
||||||
|
float _recenterSeconds { 5.0f };
|
||||||
|
float _recenterAngle { 45.0f };
|
||||||
|
|
||||||
Setting::Handle<float> _realWorldFieldOfView;
|
Setting::Handle<float> _realWorldFieldOfView;
|
||||||
Setting::Handle<bool> _useAdvancedMovementControls;
|
Setting::Handle<bool> _useAdvancedMovementControls;
|
||||||
|
|
Loading…
Reference in a new issue