fix for broken neck on some body models

This commit is contained in:
Andrew Meadows 2014-06-10 09:38:38 -07:00
parent f3fb39574f
commit c9ba71aa01
3 changed files with 11 additions and 5 deletions

View file

@ -30,7 +30,7 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) {
} }
setTranslation(neckPosition); setTranslation(neckPosition);
glm::quat neckParentRotation; glm::quat neckParentRotation;
if (!owningAvatar->getSkeletonModel().getNeckParentRotation(neckParentRotation)) { if (!owningAvatar->getSkeletonModel().getNeckParentRotationFromDefaultOrientation(neckParentRotation)) {
neckParentRotation = owningAvatar->getOrientation(); neckParentRotation = owningAvatar->getOrientation();
} }
setRotation(neckParentRotation); setRotation(neckParentRotation);

View file

@ -434,7 +434,7 @@ bool SkeletonModel::getNeckPosition(glm::vec3& neckPosition) const {
return isActive() && getJointPositionInWorldFrame(_geometry->getFBXGeometry().neckJointIndex, neckPosition); return isActive() && getJointPositionInWorldFrame(_geometry->getFBXGeometry().neckJointIndex, neckPosition);
} }
bool SkeletonModel::getNeckParentRotation(glm::quat& neckParentRotation) const { bool SkeletonModel::getNeckParentRotationFromDefaultOrientation(glm::quat& neckParentRotation) const {
if (!isActive()) { if (!isActive()) {
return false; return false;
} }
@ -442,7 +442,13 @@ bool SkeletonModel::getNeckParentRotation(glm::quat& neckParentRotation) const {
if (geometry.neckJointIndex == -1) { if (geometry.neckJointIndex == -1) {
return false; return false;
} }
return getJointRotationInWorldFrame(geometry.joints.at(geometry.neckJointIndex).parentIndex, neckParentRotation); int parentIndex = geometry.joints.at(geometry.neckJointIndex).parentIndex;
glm::quat worldFrameRotation;
if (getJointRotationInWorldFrame(parentIndex, worldFrameRotation)) {
neckParentRotation = worldFrameRotation * _jointStates[parentIndex].getFBXJoint().inverseDefaultRotation;
return true;
}
return false;
} }
bool SkeletonModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { bool SkeletonModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {

View file

@ -86,9 +86,9 @@ public:
/// \return whether or not the neck was found /// \return whether or not the neck was found
bool getNeckPosition(glm::vec3& neckPosition) const; bool getNeckPosition(glm::vec3& neckPosition) const;
/// Returns the rotation of the neck joint's parent. /// Returns the rotation of the neck joint's parent from default orientation
/// \return whether or not the neck was found /// \return whether or not the neck was found
bool getNeckParentRotation(glm::quat& neckRotation) const; bool getNeckParentRotationFromDefaultOrientation(glm::quat& neckParentRotation) const;
/// Retrieve the positions of up to two eye meshes. /// Retrieve the positions of up to two eye meshes.
/// \return whether or not both eye meshes were found /// \return whether or not both eye meshes were found