| @@ -52,7 +52,6 @@ AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float i · 51 unmodified lines |
| 52 | if (i < MAX_NUMBER_FLEX_VARIABLES) { | 52 | if (i < MAX_NUMBER_FLEX_VARIABLES) { |
| 53 | _tipTargetFlexCoefficients[i] = tipTargetFlexCoefficients[i]; | 53 | _tipTargetFlexCoefficients[i] = tipTargetFlexCoefficients[i]; |
| 54 | } | 54 | } |
| 55 | | | |
| 56 | } | 55 | } |
| 57 | _numTipTargetFlexCoefficients = std::min((int)tipTargetFlexCoefficients.size(), MAX_NUMBER_FLEX_VARIABLES); | 56 | _numTipTargetFlexCoefficients = std::min((int)tipTargetFlexCoefficients.size(), MAX_NUMBER_FLEX_VARIABLES); |
| 58 | | 57 | |
| @@ -70,7 +69,6 @@ AnimSplineIK::~AnimSplineIK() { · 11 unmodified lines |
| 70 | } | 69 | } |
| 71 | | 70 | |
| 72 | const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) { | 71 | const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) { |
| 73 | | | |
| 74 | assert(_children.size() == 1); | 72 | assert(_children.size() == 1); |
| 75 | if (_children.size() != 1) { | 73 | if (_children.size() != 1) { |
| 76 | return _poses; | 74 | return _poses; |
| @@ -135,8 +133,6 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const · 58 unmodified lines |
| 135 | _poses[_baseJointIndex] = baseParentAbsPose.inverse() * baseTargetAbsolutePose; | 133 | _poses[_baseJointIndex] = baseParentAbsPose.inverse() * baseTargetAbsolutePose; |
| 136 | _poses[_baseJointIndex].scale() = glm::vec3(1.0f); | 134 | _poses[_baseJointIndex].scale() = glm::vec3(1.0f); |
| 137 | | 135 | |
| 138 | | | |
| 139 | | | |
| 140 | // initialize the middle joint target | 136 | // initialize the middle joint target |
| 141 | IKTarget midTarget; | 137 | IKTarget midTarget; |
| 142 | midTarget.setType((int)IKTarget::Type::Spline); | 138 | midTarget.setType((int)IKTarget::Type::Spline); |
| @@ -167,7 +163,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const · 24 unmodified lines |
| 167 | tipTarget.setPose(tipRotation, tipTranslation); | 163 | tipTarget.setPose(tipRotation, tipTranslation); |
| 168 | tipTarget.setWeight(1.0f); | 164 | tipTarget.setWeight(1.0f); |
| 169 | tipTarget.setFlexCoefficients(_numTipTargetFlexCoefficients, _tipTargetFlexCoefficients); | 165 | tipTarget.setFlexCoefficients(_numTipTargetFlexCoefficients, _tipTargetFlexCoefficients); |
| 170 | | 166 | |
| 171 | // solve the upper spine spline | 167 | // solve the upper spine spline |
| 172 | AnimChain upperJointChain; | 168 | AnimChain upperJointChain; |
| 173 | AnimPoseVec finalAbsolutePoses; | 169 | AnimPoseVec finalAbsolutePoses; |
| @@ -241,7 +237,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const · 67 unmodified lines |
| 241 | | 237 | |
| 242 | | 238 | |
| 243 | } else if (context.getEnableDebugDrawIKTargets() != _previousEnableDebugIKTargets) { | 239 | } else if (context.getEnableDebugDrawIKTargets() != _previousEnableDebugIKTargets) { |
| 244 | | 240 | |
| 245 | // remove markers if they were added last frame. | 241 | // remove markers if they were added last frame. |
| 246 | QString name = QString("ikTargetSplineTip"); | 242 | QString name = QString("ikTargetSplineTip"); |
| 247 | DebugDraw::getInstance().removeMyAvatarMarker(name); | 243 | DebugDraw::getInstance().removeMyAvatarMarker(name); |
| @@ -374,9 +370,9 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, int base, c · 126 unmodified lines |
| 374 | } | 370 | } |
| 375 | } | 371 | } |
| 376 | ::blend(1, &absolutePoses[splineJointInfo.jointIndex], &desiredAbsPose, interpedCoefficient, &flexedAbsPose); | 372 | ::blend(1, &absolutePoses[splineJointInfo.jointIndex], &desiredAbsPose, interpedCoefficient, &flexedAbsPose); |
| 377 | | 373 | |
| 378 | AnimPose relPose = parentAbsPose.inverse() * flexedAbsPose; | 374 | AnimPose relPose = parentAbsPose.inverse() * flexedAbsPose; |
| 379 | | 375 | |
| 380 | bool constrained = false; | 376 | bool constrained = false; |
| 381 | if (splineJointInfo.jointIndex != base) { | 377 | if (splineJointInfo.jointIndex != base) { |
| 382 | // constrain the amount the spine can stretch or compress | 378 | // constrain the amount the spine can stretch or compress |
| @@ -398,7 +394,7 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, int base, c · 15 unmodified lines |
| 398 | relPose.trans() = glm::vec3(0.0f); | 394 | relPose.trans() = glm::vec3(0.0f); |
| 399 | } | 395 | } |
| 400 | } | 396 | } |
| 401 | | 397 | |
| 402 | if (!chainInfoOut.setRelativePoseAtJointIndex(splineJointInfo.jointIndex, relPose)) { | 398 | if (!chainInfoOut.setRelativePoseAtJointIndex(splineJointInfo.jointIndex, relPose)) { |
| 403 | qCDebug(animation) << "error: joint not found in spline chain"; | 399 | qCDebug(animation) << "error: joint not found in spline chain"; |
| 404 | } | 400 | } |