Mask joints from animation when explicitly set.

This commit is contained in:
Andrzej Kapolka 2014-05-20 17:10:53 -07:00
parent d3e5e3ccf1
commit 7124b4a196
2 changed files with 13 additions and 3 deletions

View file

@ -1200,6 +1200,7 @@ bool Model::setJointRotation(int jointIndex, const glm::quat& rotation, bool fro
state.rotation = state.rotation * glm::inverse(state.combinedRotation) * rotation *
glm::inverse(fromBind ? _geometry->getFBXGeometry().joints.at(jointIndex).inverseBindRotation :
_geometry->getFBXGeometry().joints.at(jointIndex).inverseDefaultRotation);
state.animationDisabled = true;
return true;
}
@ -1232,6 +1233,7 @@ bool Model::restoreJointPosition(int jointIndex, float percent) {
const FBXJoint& joint = geometry.joints.at(index);
state.rotation = safeMix(state.rotation, joint.rotation, percent);
state.translation = glm::mix(state.translation, joint.translation, percent);
state.animationDisabled = false;
}
return true;
}
@ -1265,6 +1267,7 @@ void Model::applyRotationDelta(int jointIndex, const glm::quat& delta, bool cons
glm::quat newRotation = glm::quat(glm::clamp(eulers, joint.rotationMin, joint.rotationMax));
state.combinedRotation = state.combinedRotation * glm::inverse(state.rotation) * newRotation;
state.rotation = newRotation;
state.animationDisabled = true;
}
const int BALL_SUBDIVISIONS = 10;
@ -1694,7 +1697,10 @@ void AnimationHandle::simulate(float deltaTime) {
for (int i = 0; i < _jointMappings.size(); i++) {
int mapping = _jointMappings.at(i);
if (mapping != -1) {
_model->_jointStates[mapping].rotation = frame.rotations.at(i);
Model::JointState& state = _model->_jointStates[mapping];
if (!state.animationDisabled) {
state.rotation = frame.rotations.at(i);
}
}
}
stop();
@ -1709,8 +1715,10 @@ void AnimationHandle::simulate(float deltaTime) {
for (int i = 0; i < _jointMappings.size(); i++) {
int mapping = _jointMappings.at(i);
if (mapping != -1) {
_model->_jointStates[mapping].rotation = safeMix(floorFrame.rotations.at(i),
ceilFrame.rotations.at(i), frameFraction);
Model::JointState& state = _model->_jointStates[mapping];
if (!state.animationDisabled) {
state.rotation = safeMix(floorFrame.rotations.at(i), ceilFrame.rotations.at(i), frameFraction);
}
}
}
}

View file

@ -12,6 +12,7 @@
#ifndef hifi_Model_h
#define hifi_Model_h
#include <QBitArray>
#include <QObject>
#include <QUrl>
@ -251,6 +252,7 @@ protected:
glm::quat rotation; // rotation relative to parent
glm::mat4 transform; // rotation to world frame + translation in model frame
glm::quat combinedRotation; // rotation from joint local to world frame
bool animationDisabled; // if true, animations do not affect this joint
};
bool _shapesAreDirty;