mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Compute spine length on skeleton load
This commit is contained in:
parent
e9316d30d0
commit
36dc2dc49d
2 changed files with 13 additions and 0 deletions
|
@ -938,10 +938,22 @@ void AnimInverseKinematics::setSkeletonInternal(AnimSkeleton::ConstPointer skele
|
|||
} else {
|
||||
_hipsParentIndex = -1;
|
||||
}
|
||||
|
||||
auto currentJointIndex = _headIndex;
|
||||
auto parentJointIndex = _skeleton->getParentIndex(currentJointIndex);
|
||||
_spineLength = 0.0f;
|
||||
while (currentJointIndex != _hipsIndex && parentJointIndex != -1) {
|
||||
_spineLength += glm::distance(_skeleton->getAbsoluteDefaultPose(currentJointIndex).trans(),
|
||||
_skeleton->getAbsoluteDefaultPose(parentJointIndex).trans());
|
||||
|
||||
currentJointIndex = parentJointIndex;
|
||||
parentJointIndex = _skeleton->getParentIndex(currentJointIndex);
|
||||
}
|
||||
} else {
|
||||
clearConstraints();
|
||||
_headIndex = -1;
|
||||
_hipsIndex = -1;
|
||||
_hipsParentIndex = -1;
|
||||
_spineLength = 0.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ protected:
|
|||
int _headIndex { -1 };
|
||||
int _hipsIndex { -1 };
|
||||
int _hipsParentIndex { -1 };
|
||||
float _spineLength { 0.0f };
|
||||
|
||||
// _maxTargetIndex is tracked to help optimize the recalculation of absolute poses
|
||||
// during the the cyclic coordinate descent algorithm
|
||||
|
|
Loading…
Reference in a new issue