mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:37:17 +02:00
Merge pull request #6320 from hyperlogic/tony/blender-avatar-ik-fix
IK fix for avatars exported from Blender
This commit is contained in:
commit
e410030dd9
1 changed files with 5 additions and 5 deletions
|
@ -156,11 +156,11 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vector<I
|
||||||
// cache tip absolute transform
|
// cache tip absolute transform
|
||||||
int tipIndex = target.getIndex();
|
int tipIndex = target.getIndex();
|
||||||
int pivotIndex = _skeleton->getParentIndex(tipIndex);
|
int pivotIndex = _skeleton->getParentIndex(tipIndex);
|
||||||
if (pivotIndex == -1) {
|
if (pivotIndex == -1 || pivotIndex == _hipsIndex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int pivotsParentIndex = _skeleton->getParentIndex(pivotIndex);
|
int pivotsParentIndex = _skeleton->getParentIndex(pivotIndex);
|
||||||
if (pivotsParentIndex == -1) {
|
if (pivotsParentIndex == -1 || pivotIndex == _hipsIndex) {
|
||||||
// TODO?: handle case where tip's parent is root?
|
// TODO?: handle case where tip's parent is root?
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vector<I
|
||||||
glm::quat tipParentRotation = absolutePoses[pivotIndex].rot;
|
glm::quat tipParentRotation = absolutePoses[pivotIndex].rot;
|
||||||
|
|
||||||
// descend toward root, pivoting each joint to get tip closer to target
|
// descend toward root, pivoting each joint to get tip closer to target
|
||||||
while (pivotsParentIndex != -1) {
|
while (pivotsParentIndex != _hipsIndex && pivotsParentIndex != -1) {
|
||||||
// compute the two lines that should be aligned
|
// compute the two lines that should be aligned
|
||||||
glm::vec3 jointPosition = absolutePoses[pivotIndex].trans;
|
glm::vec3 jointPosition = absolutePoses[pivotIndex].trans;
|
||||||
glm::vec3 leverArm = tipPosition - jointPosition;
|
glm::vec3 leverArm = tipPosition - jointPosition;
|
||||||
|
@ -285,7 +285,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vector<I
|
||||||
// only update the absolutePoses that need it: those between lowestMovedIndex and _maxTargetIndex
|
// only update the absolutePoses that need it: those between lowestMovedIndex and _maxTargetIndex
|
||||||
for (int i = lowestMovedIndex; i <= _maxTargetIndex; ++i) {
|
for (int i = lowestMovedIndex; i <= _maxTargetIndex; ++i) {
|
||||||
int parentIndex = _skeleton->getParentIndex(i);
|
int parentIndex = _skeleton->getParentIndex(i);
|
||||||
if (parentIndex != -1) {
|
if (parentIndex != -1 && parentIndex != _hipsIndex) {
|
||||||
absolutePoses[i] = absolutePoses[parentIndex] * _relativePoses[i];
|
absolutePoses[i] = absolutePoses[parentIndex] * _relativePoses[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vector<I
|
||||||
for (auto& target: targets) {
|
for (auto& target: targets) {
|
||||||
int tipIndex = target.getIndex();
|
int tipIndex = target.getIndex();
|
||||||
int parentIndex = _skeleton->getParentIndex(tipIndex);
|
int parentIndex = _skeleton->getParentIndex(tipIndex);
|
||||||
if (parentIndex != -1) {
|
if (parentIndex != -1 && parentIndex != _hipsIndex) {
|
||||||
const glm::quat& targetRotation = target.getRotation();
|
const glm::quat& targetRotation = target.getRotation();
|
||||||
// compute tip's new parent-relative rotation
|
// compute tip's new parent-relative rotation
|
||||||
// Q = Qp * q --> q' = Qp^ * Q
|
// Q = Qp * q --> q' = Qp^ * Q
|
||||||
|
|
Loading…
Reference in a new issue