Merge pull request #1574 from ey6es/master

Get rid of code to decay pitch on movement, fix eye rotations.
This commit is contained in:
Philip Rosedale 2014-01-17 11:24:48 -08:00
commit edc93347d1
2 changed files with 14 additions and 21 deletions

View file

@ -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() +

View file

@ -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;