From 515cc5316cafa0253660fcf9aaffb4f2d7ba8be3 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 17 Jan 2014 10:54:44 -0800 Subject: [PATCH 1/2] Get rid of code to decay pitch on movement. --- interface/src/avatar/MyAvatar.cpp | 33 ++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 02e89c9df5..3c5fdb243f 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -180,29 +180,22 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) { const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f; const int OCULUS_YAW_OFFSET_THRESHOLD = 10; - if (!Application::getInstance()->getFaceshift()->isActive()) { - // Decay HeadPitch as a function of acceleration, so that you look straight ahead when - // you start moving, but don't do this with an HMD like the Oculus. - if (!OculusManager::isConnected()) { - if (forwardAcceleration > ACCELERATION_PULL_THRESHOLD) { - _head.setMousePitch(_head.getMousePitch() * qMax(0.0f, - (1.f - forwardAcceleration * ACCELERATION_PITCH_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 + if (!Application::getInstance()->getFaceshift()->isActive() && OculusManager::isConnected() && + 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(); + // match the body yaw to the oculus yaw + _bodyYaw = getAbsoluteHeadYaw(); - // set the head yaw to zero for this draw - _head.setYaw(0); + // set the head yaw to zero for this draw + _head.setYaw(0); - // correct the oculus yaw offset - OculusManager::updateYawOffset(); - } + // correct the oculus yaw offset + OculusManager::updateYawOffset(); } const float WALKING_SPEED_THRESHOLD = 0.2f; From 7a4353428e4dd975aced8616663c25b9e0a3dd63 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 17 Jan 2014 11:05:26 -0800 Subject: [PATCH 2/2] Fixed eye rotations. --- interface/src/avatar/FaceModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/FaceModel.cpp b/interface/src/avatar/FaceModel.cpp index 61005481a8..d164d5c899 100644 --- a/interface/src/avatar/FaceModel.cpp +++ b/interface/src/avatar/FaceModel.cpp @@ -65,7 +65,7 @@ void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBX void FaceModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { // likewise with the eye joints - glm::mat4 inverse = glm::inverse(parentState.transform * + glm::mat4 inverse = glm::inverse(parentState.transform * glm::translate(state.translation) * joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation)); glm::vec3 front = glm::vec3(inverse * glm::vec4(_owningHead->getOrientation() * IDENTITY_FRONT, 0.0f)); glm::vec3 lookAt = glm::vec3(inverse * glm::vec4(_owningHead->getLookAtPosition() +