Compute the model offset in the rig, using the bind pose of the hips.

This commit is contained in:
Anthony J. Thibault 2015-10-02 10:34:34 -07:00
parent fa864d29f9
commit a1b54945d6
3 changed files with 14 additions and 0 deletions

View file

@ -246,6 +246,9 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
Hand* hand = _owningAvatar->getHand();
hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
// let rig compute the model offset
setOffset(_rig->getModelOffset());
// Don't Relax toward hand positions when in animGraph mode.
if (!_rig->getEnableAnimGraph()) {
const float HAND_RESTORATION_RATE = 0.25f;

View file

@ -1263,3 +1263,12 @@ void Rig::initAnimGraph(const QUrl& url, const FBXGeometry& fbxGeometry) {
qCCritical(animation) << "Error loading" << url.toDisplayString() << "code = " << error << "str =" << str;
});
}
glm::vec3 Rig::getModelOffset() const {
if (_animSkeleton && _rootJointIndex >= 0) {
return -_animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
} else {
const glm::vec3 DEFAULT_MODEL_OFFSET(0.0f, 0.0f, 0.0f);
return DEFAULT_MODEL_OFFSET;
}
}

View file

@ -204,6 +204,8 @@ public:
AnimSkeleton::ConstPointer getAnimSkeleton() const { return _animSkeleton; }
bool disableHands {false}; // should go away with rig animation (and Rig::inverseKinematics)
glm::vec3 getModelOffset() const;
protected:
void updateLeanJoint(int index, float leanSideways, float leanForward, float torsoTwist);