mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 09:54:24 +02:00
Merge pull request #7125 from hyperlogic/tony/ik-bugfix
AnimInverseKinematics: fix for extra twist in lowerSpine joints.
This commit is contained in:
commit
07df96b6b3
1 changed files with 3 additions and 3 deletions
|
@ -278,8 +278,8 @@ int AnimInverseKinematics::solveTargetWithCCD(const IKTarget& target, AnimPoseVe
|
||||||
if (axisLength > MIN_AXIS_LENGTH) {
|
if (axisLength > MIN_AXIS_LENGTH) {
|
||||||
// compute angle of rotation that brings tip closer to target
|
// compute angle of rotation that brings tip closer to target
|
||||||
axis /= axisLength;
|
axis /= axisLength;
|
||||||
float angle = acosf(glm::dot(leverArm, targetLine) / (glm::length(leverArm) * glm::length(targetLine)));
|
float cosAngle = glm::clamp(glm::dot(leverArm, targetLine) / (glm::length(leverArm) * glm::length(targetLine)), -1.0f, 1.0f);
|
||||||
|
float angle = acosf(cosAngle);
|
||||||
const float MIN_ADJUSTMENT_ANGLE = 1.0e-4f;
|
const float MIN_ADJUSTMENT_ANGLE = 1.0e-4f;
|
||||||
if (angle > MIN_ADJUSTMENT_ANGLE) {
|
if (angle > MIN_ADJUSTMENT_ANGLE) {
|
||||||
// reduce angle by a fraction (for stability)
|
// reduce angle by a fraction (for stability)
|
||||||
|
@ -348,7 +348,7 @@ int AnimInverseKinematics::solveTargetWithCCD(const IKTarget& target, AnimPoseVe
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep track of tip's new transform as we descend towards root
|
// keep track of tip's new transform as we descend towards root
|
||||||
tipPosition = jointPosition + deltaRotation * leverArm;
|
tipPosition = jointPosition + deltaRotation * (tipPosition - jointPosition);
|
||||||
tipOrientation = glm::normalize(deltaRotation * tipOrientation);
|
tipOrientation = glm::normalize(deltaRotation * tipOrientation);
|
||||||
tipParentOrientation = glm::normalize(deltaRotation * tipParentOrientation);
|
tipParentOrientation = glm::normalize(deltaRotation * tipParentOrientation);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue