mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
added some docs
This commit is contained in:
parent
b9bf6f4c05
commit
f99b579c14
2 changed files with 11 additions and 7 deletions
|
@ -1445,10 +1445,11 @@ void AnimInverseKinematics::initRelativePosesFromSolutionSource(SolutionSource s
|
|||
}
|
||||
}
|
||||
|
||||
// pre-compute information about each joint influeced by this spline IK target.
|
||||
void AnimInverseKinematics::computeSplineJointInfosForIKTarget(const AnimContext& context, const IKTarget& target) {
|
||||
std::vector<SplineJointInfo> splineJointInfoVec;
|
||||
|
||||
// build default spline
|
||||
// build spline between the default poses.
|
||||
AnimPose tipPose = _skeleton->getAbsoluteDefaultPose(target.getIndex());
|
||||
AnimPose basePose = _skeleton->getAbsoluteDefaultPose(_hipsIndex);
|
||||
|
||||
|
@ -1461,9 +1462,11 @@ void AnimInverseKinematics::computeSplineJointInfosForIKTarget(const AnimContext
|
|||
} else {
|
||||
spline = computeSplineFromTipAndBase(tipPose, basePose);
|
||||
}
|
||||
|
||||
// measure the total arc length along the spline
|
||||
float totalArcLength = spline.arcLength(1.0f);
|
||||
|
||||
// AJT: FIXME: TODO: this won't work for horizontal splines...
|
||||
// FIXME: TODO: this won't work for horizontal splines...
|
||||
float baseToTipHeight = tipPose.trans().y - basePose.trans().y;
|
||||
|
||||
int index = target.getIndex();
|
||||
|
@ -1471,10 +1474,10 @@ void AnimInverseKinematics::computeSplineJointInfosForIKTarget(const AnimContext
|
|||
while (index != endIndex) {
|
||||
AnimPose defaultPose = _skeleton->getAbsoluteDefaultPose(index);
|
||||
|
||||
// AJT: FIXME: TODO: this wont work for horizontal splines...
|
||||
// FIXME: TODO: this wont work for horizontal splines...
|
||||
float ratio = (defaultPose.trans().y - basePose.trans().y) / baseToTipHeight;
|
||||
|
||||
// compute offset from default spline pose to default pose.
|
||||
// compute offset from spline to the default pose.
|
||||
float t = spline.arcLengthInverse(ratio * totalArcLength);
|
||||
AnimPose pose(glm::vec3(1.0f), glm::normalize(glm::lerp(basePose.rot(), tipPose.rot(), t)), spline(t));
|
||||
AnimPose offsetPose = pose.inverse() * defaultPose;
|
||||
|
|
|
@ -117,10 +117,11 @@ protected:
|
|||
AnimPoseVec _relativePoses; // current relative poses
|
||||
AnimPoseVec _limitCenterPoses; // relative
|
||||
|
||||
// used to pre-compute information about each joint influeced by a spline IK target.
|
||||
struct SplineJointInfo {
|
||||
int jointIndex;
|
||||
float ratio;
|
||||
AnimPose offsetPose;
|
||||
int jointIndex; // joint in the skeleton that this information pertains to.
|
||||
float ratio; // percentage (0..1) along the spline for this joint.
|
||||
AnimPose offsetPose; // local offset from the spline to the joint.
|
||||
};
|
||||
std::map<int, std::vector<SplineJointInfo>> _splineJointInfoMap;
|
||||
|
||||
|
|
Loading…
Reference in a new issue