mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
Made computeSplineJointInfosForIKTarget more general
It should now work for non-vertical oriented splines.
This commit is contained in:
parent
f99b579c14
commit
551426f46e
1 changed files with 4 additions and 4 deletions
|
@ -1466,16 +1466,16 @@ void AnimInverseKinematics::computeSplineJointInfosForIKTarget(const AnimContext
|
||||||
// measure the total arc length along the spline
|
// measure the total arc length along the spline
|
||||||
float totalArcLength = spline.arcLength(1.0f);
|
float totalArcLength = spline.arcLength(1.0f);
|
||||||
|
|
||||||
// FIXME: TODO: this won't work for horizontal splines...
|
glm::vec3 baseToTip = tipPose.trans() - basePose.trans();
|
||||||
float baseToTipHeight = tipPose.trans().y - basePose.trans().y;
|
float baseToTipLength = glm::length(baseToTip);
|
||||||
|
glm::vec3 baseToTipNormal = baseToTip / baseToTipLength;
|
||||||
|
|
||||||
int index = target.getIndex();
|
int index = target.getIndex();
|
||||||
int endIndex = _skeleton->getParentIndex(_hipsIndex);
|
int endIndex = _skeleton->getParentIndex(_hipsIndex);
|
||||||
while (index != endIndex) {
|
while (index != endIndex) {
|
||||||
AnimPose defaultPose = _skeleton->getAbsoluteDefaultPose(index);
|
AnimPose defaultPose = _skeleton->getAbsoluteDefaultPose(index);
|
||||||
|
|
||||||
// FIXME: TODO: this wont work for horizontal splines...
|
float ratio = glm::dot(defaultPose.trans() - basePose.trans(), baseToTipNormal) / baseToTipLength;
|
||||||
float ratio = (defaultPose.trans().y - basePose.trans().y) / baseToTipHeight;
|
|
||||||
|
|
||||||
// compute offset from spline to the default pose.
|
// compute offset from spline to the default pose.
|
||||||
float t = spline.arcLengthInverse(ratio * totalArcLength);
|
float t = spline.arcLengthInverse(ratio * totalArcLength);
|
||||||
|
|
Loading…
Reference in a new issue