Fix for model offset when using Rig Animations.

This commit is contained in:
Anthony J. Thibault 2015-10-02 11:40:46 -07:00
parent fc7b6dee84
commit c0be32d359
3 changed files with 9 additions and 6 deletions

View file

@ -247,7 +247,10 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
// let rig compute the model offset
setOffset(_rig->getModelOffset());
glm::vec3 modelOffset;
if (_rig->getModelOffset(modelOffset)) {
setOffset(modelOffset);
}
// Don't Relax toward hand positions when in animGraph mode.
if (!_rig->getEnableAnimGraph()) {

View file

@ -1203,11 +1203,11 @@ void Rig::initAnimGraph(const QUrl& url, const FBXGeometry& fbxGeometry) {
});
}
glm::vec3 Rig::getModelOffset() const {
bool Rig::getModelOffset(glm::vec3& modelOffsetOut) const {
if (_animSkeleton && _rootJointIndex >= 0) {
return -_animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
modelOffsetOut = -_animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
return true;
} else {
const glm::vec3 DEFAULT_MODEL_OFFSET(0.0f, 0.0f, 0.0f);
return DEFAULT_MODEL_OFFSET;
return false;
}
}

View file

@ -204,7 +204,7 @@ public:
AnimSkeleton::ConstPointer getAnimSkeleton() const { return _animSkeleton; }
bool disableHands {false}; // should go away with rig animation (and Rig::inverseKinematics)
glm::vec3 getModelOffset() const;
bool getModelOffset(glm::vec3& modelOffsetOut) const;
protected: