mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
apply "hips offset" to root of state graph
(Somemtimes the hips are not the root. I'm looking at YOU blender!)
This commit is contained in:
parent
3cdd88e06c
commit
00715f1906
2 changed files with 16 additions and 6 deletions
|
@ -376,13 +376,13 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
|
|||
++constraintItr;
|
||||
}
|
||||
} else {
|
||||
// shift the hips according to the offset from the previous frame
|
||||
// shift the everything according to the _hipsOffset from the previous frame
|
||||
float offsetLength = glm::length(_hipsOffset);
|
||||
const float MIN_HIPS_OFFSET_LENGTH = 0.03f;
|
||||
if (offsetLength > MIN_HIPS_OFFSET_LENGTH) {
|
||||
// but only if offset is long enough
|
||||
float scaleFactor = ((offsetLength - MIN_HIPS_OFFSET_LENGTH) / offsetLength);
|
||||
_relativePoses[_hipsIndex].trans = underPoses[_hipsIndex].trans + scaleFactor * _hipsOffset;
|
||||
_relativePoses[_rootIndex].trans = underPoses[_rootIndex].trans + scaleFactor * _hipsOffset;
|
||||
}
|
||||
|
||||
solveWithCyclicCoordinateDescent(targets);
|
||||
|
@ -775,9 +775,18 @@ void AnimInverseKinematics::setSkeletonInternal(AnimSkeleton::ConstPointer skele
|
|||
initConstraints();
|
||||
_headIndex = _skeleton->nameToJointIndex("Head");
|
||||
_hipsIndex = _skeleton->nameToJointIndex("Hips");
|
||||
|
||||
// walk up the hierarchy until we find the root and cache its index
|
||||
_rootIndex = _hipsIndex;
|
||||
int parentIndex = _skeleton->getParentIndex(_hipsIndex);
|
||||
while (parentIndex != -1) {
|
||||
_rootIndex = parentIndex;
|
||||
parentIndex = _skeleton->getParentIndex(_rootIndex);
|
||||
}
|
||||
} else {
|
||||
clearConstraints();
|
||||
_headIndex = -1;
|
||||
_hipsIndex = -1;
|
||||
_rootIndex = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,13 +79,14 @@ protected:
|
|||
AnimPoseVec _relativePoses; // current relative poses
|
||||
|
||||
// experimental data for moving hips during IK
|
||||
int _headIndex = -1;
|
||||
int _hipsIndex = -1;
|
||||
glm::vec3 _hipsOffset = Vectors::ZERO;
|
||||
glm::vec3 _hipsOffset { Vectors::ZERO };
|
||||
int _headIndex { -1 };
|
||||
int _hipsIndex { -1 };
|
||||
int _rootIndex { -1 };
|
||||
|
||||
// _maxTargetIndex is tracked to help optimize the recalculation of absolute poses
|
||||
// during the the cyclic coordinate descent algorithm
|
||||
int _maxTargetIndex = 0;
|
||||
int _maxTargetIndex { 0 };
|
||||
};
|
||||
|
||||
#endif // hifi_AnimInverseKinematics_h
|
||||
|
|
Loading…
Reference in a new issue