mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
Merge pull request #1234 from ey6es/master
Don't decay head roll/pitch when moving if Faceshift is active. This should fix https://basecamp.com/2151194/projects/2058851-avatar/todos/69596930-avatar-body-still.
This commit is contained in:
commit
e47abf2f4c
1 changed files with 22 additions and 20 deletions
|
@ -269,27 +269,29 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
||||||
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
||||||
|
|
||||||
// Decay HeadPitch as a function of acceleration, so that you look straight ahead when
|
if (!Application::getInstance()->getFaceshift()->isActive()) {
|
||||||
// you start moving, but don't do this with an HMD like the Oculus.
|
// Decay HeadPitch as a function of acceleration, so that you look straight ahead when
|
||||||
if (!OculusManager::isConnected()) {
|
// you start moving, but don't do this with an HMD like the Oculus.
|
||||||
if (forwardAcceleration > ACCELERATION_PULL_THRESHOLD) {
|
if (!OculusManager::isConnected()) {
|
||||||
_head.setPitch(_head.getPitch() * (1.f - forwardAcceleration * ACCELERATION_PITCH_DECAY * deltaTime));
|
if (forwardAcceleration > ACCELERATION_PULL_THRESHOLD) {
|
||||||
_head.setYaw(_head.getYaw() * (1.f - forwardAcceleration * ACCELERATION_YAW_DECAY * deltaTime));
|
_head.setPitch(_head.getPitch() * (1.f - forwardAcceleration * ACCELERATION_PITCH_DECAY * deltaTime));
|
||||||
|
_head.setYaw(_head.getYaw() * (1.f - forwardAcceleration * ACCELERATION_YAW_DECAY * deltaTime));
|
||||||
|
}
|
||||||
|
} else if (fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD
|
||||||
|
&& fabs(_head.getYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) {
|
||||||
|
// if we're wearing the oculus
|
||||||
|
// and this acceleration is above the pull threshold
|
||||||
|
// and the head yaw if off the body by more than OCULUS_YAW_OFFSET_THRESHOLD
|
||||||
|
|
||||||
|
// match the body yaw to the oculus yaw
|
||||||
|
_bodyYaw = getAbsoluteHeadYaw();
|
||||||
|
|
||||||
|
// set the head yaw to zero for this draw
|
||||||
|
_head.setYaw(0);
|
||||||
|
|
||||||
|
// correct the oculus yaw offset
|
||||||
|
OculusManager::updateYawOffset();
|
||||||
}
|
}
|
||||||
} else if (fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD
|
|
||||||
&& fabs(_head.getYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) {
|
|
||||||
// if we're wearing the oculus
|
|
||||||
// and this acceleration is above the pull threshold
|
|
||||||
// and the head yaw if off the body by more than OCULUS_YAW_OFFSET_THRESHOLD
|
|
||||||
|
|
||||||
// match the body yaw to the oculus yaw
|
|
||||||
_bodyYaw = getAbsoluteHeadYaw();
|
|
||||||
|
|
||||||
// set the head yaw to zero for this draw
|
|
||||||
_head.setYaw(0);
|
|
||||||
|
|
||||||
// correct the oculus yaw offset
|
|
||||||
OculusManager::updateYawOffset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply the head lean values to the ball positions...
|
//apply the head lean values to the ball positions...
|
||||||
|
|
Loading…
Reference in a new issue