mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:18:12 +02:00
apply flexCoeff to tip of joint chain as well.
This commit is contained in:
parent
abe19310da
commit
87adeb0565
2 changed files with 20 additions and 8 deletions
|
@ -68,7 +68,7 @@
|
||||||
"typeVar": "rightHandType",
|
"typeVar": "rightHandType",
|
||||||
"weightVar": "rightHandWeight",
|
"weightVar": "rightHandWeight",
|
||||||
"weight": 1.0,
|
"weight": 1.0,
|
||||||
"flexCoefficients": [1, 0.5, 0.5, 0.2, 0.00, 0.00, 0.00, 0.0, 0.0]
|
"flexCoefficients": [1, 0.5, 0.5, 0.25, 0.1, 0.05, 0.01, 0.0, 0.0]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"jointName": "LeftHand",
|
"jointName": "LeftHand",
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
"typeVar": "leftHandType",
|
"typeVar": "leftHandType",
|
||||||
"weightVar": "leftHandWeight",
|
"weightVar": "leftHandWeight",
|
||||||
"weight": 1.0,
|
"weight": 1.0,
|
||||||
"flexCoefficients": [1, 0.5, 0.5, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0]
|
"flexCoefficients": [1, 0.5, 0.5, 0.2, 0.00, 0.00, 0.00, 0.0, 0.0]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"jointName": "RightFoot",
|
"jointName": "RightFoot",
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
"typeVar": "spine2Type",
|
"typeVar": "spine2Type",
|
||||||
"weightVar": "spine2Weight",
|
"weightVar": "spine2Weight",
|
||||||
"weight": 1.0,
|
"weight": 1.0,
|
||||||
"flexCoefficients": [0.45, 0.45]
|
"flexCoefficients": [1.0, 0.5, 0.5]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"jointName": "Head",
|
"jointName": "Head",
|
||||||
|
|
|
@ -195,7 +195,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const AnimContext&
|
||||||
|
|
||||||
// solve all targets
|
// solve all targets
|
||||||
for (auto& target: targets) {
|
for (auto& target: targets) {
|
||||||
bool debug = numLoops == MAX_IK_LOOPS;
|
bool debug = false;
|
||||||
solveTargetWithCCD(context, target, absolutePoses, debug);
|
solveTargetWithCCD(context, target, absolutePoses, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +254,8 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const AnimContext&
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const IKTarget& target, const AnimPoseVec& absolutePoses, bool debug) {
|
void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const IKTarget& target, const AnimPoseVec& absolutePoses, bool debug) {
|
||||||
|
size_t chainDepth = 0;
|
||||||
|
|
||||||
IKTarget::Type targetType = target.getType();
|
IKTarget::Type targetType = target.getType();
|
||||||
if (targetType == IKTarget::Type::RotationOnly) {
|
if (targetType == IKTarget::Type::RotationOnly) {
|
||||||
// the final rotation will be enforced after the iterations
|
// the final rotation will be enforced after the iterations
|
||||||
|
@ -287,9 +289,18 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const
|
||||||
targetType == IKTarget::Type::RotationAndPosition ||
|
targetType == IKTarget::Type::RotationAndPosition ||
|
||||||
targetType == IKTarget::Type::HipsRelativeRotationAndPosition) {
|
targetType == IKTarget::Type::HipsRelativeRotationAndPosition) {
|
||||||
|
|
||||||
// rotate tip directly to target orientation
|
// rotate tip toward target orientation
|
||||||
tipOrientation = target.getRotation();
|
glm::quat deltaRot = target.getRotation() * glm::inverse(tipOrientation);
|
||||||
glm::quat tipRelativeRotation = glm::inverse(tipParentOrientation) * tipOrientation;
|
|
||||||
|
// decompose deltaRot into axis angle
|
||||||
|
glm::vec3 axis = glm::axis(deltaRot);
|
||||||
|
float angle = glm::angle(deltaRot);
|
||||||
|
|
||||||
|
// apply flexCoefficent and re-compose quat
|
||||||
|
glm::quat deltaRotation = glm::angleAxis(angle * target.getFlexCoefficient(chainDepth), axis);
|
||||||
|
|
||||||
|
// compute parent relative rotation
|
||||||
|
glm::quat tipRelativeRotation = glm::inverse(tipParentOrientation) * deltaRotation * tipOrientation;
|
||||||
|
|
||||||
// then enforce tip's constraint
|
// then enforce tip's constraint
|
||||||
RotationConstraint* constraint = getConstraint(tipIndex);
|
RotationConstraint* constraint = getConstraint(tipIndex);
|
||||||
|
@ -301,6 +312,7 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const
|
||||||
tipRelativeRotation = tipRelativeRotation;
|
tipRelativeRotation = tipRelativeRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the relative rotation change in the accumulator
|
// store the relative rotation change in the accumulator
|
||||||
_accumulators[tipIndex].add(tipRelativeRotation, target.getWeight());
|
_accumulators[tipIndex].add(tipRelativeRotation, target.getWeight());
|
||||||
|
|
||||||
|
@ -312,7 +324,7 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const
|
||||||
// cache tip absolute position
|
// cache tip absolute position
|
||||||
glm::vec3 tipPosition = absolutePoses[tipIndex].trans();
|
glm::vec3 tipPosition = absolutePoses[tipIndex].trans();
|
||||||
|
|
||||||
size_t chainDepth = 1;
|
chainDepth++;
|
||||||
|
|
||||||
// descend toward root, pivoting each joint to get tip closer to target position
|
// descend toward root, pivoting each joint to get tip closer to target position
|
||||||
while (pivotIndex != _hipsIndex && pivotsParentIndex != -1) {
|
while (pivotIndex != _hipsIndex && pivotsParentIndex != -1) {
|
||||||
|
|
Loading…
Reference in a new issue