From 20d95080f1c0a6a252e1ee7e4364451c93db672c Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 5 Nov 2015 12:03:45 -0800 Subject: [PATCH] IK fix for avatars exported from Blender This should fix the issue with the hips moving erratically when arm IK is enabled. The main issue is that the IK system assumed that the "Hips" joint was the root of the skeleton. For Blender avatar this is not the case as it inserts an "Armature" node at the root instead. --- libraries/animation/src/AnimInverseKinematics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/animation/src/AnimInverseKinematics.cpp b/libraries/animation/src/AnimInverseKinematics.cpp index 42e9472819..6355426dae 100644 --- a/libraries/animation/src/AnimInverseKinematics.cpp +++ b/libraries/animation/src/AnimInverseKinematics.cpp @@ -156,11 +156,11 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vectorgetParentIndex(tipIndex); - if (pivotIndex == -1) { + if (pivotIndex == -1 || pivotIndex == _hipsIndex) { continue; } int pivotsParentIndex = _skeleton->getParentIndex(pivotIndex); - if (pivotsParentIndex == -1) { + if (pivotsParentIndex == -1 || pivotIndex == _hipsIndex) { // TODO?: handle case where tip's parent is root? continue; } @@ -173,7 +173,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vectorgetParentIndex(i); - if (parentIndex != -1) { + if (parentIndex != -1 && parentIndex != _hipsIndex) { absolutePoses[i] = absolutePoses[parentIndex] * _relativePoses[i]; } } @@ -295,7 +295,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vectorgetParentIndex(tipIndex); - if (parentIndex != -1) { + if (parentIndex != -1 && parentIndex != _hipsIndex) { const glm::quat& targetRotation = target.getRotation(); // compute tip's new parent-relative rotation // Q = Qp * q --> q' = Qp^ * Q