Fix wrong middle bone index
parent
73d4676675
commit
f0379740ca
|
@ -128,8 +128,9 @@ void AnimalPoser::resolveChainRotation(const std::vector<QString> &limbBoneNames
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float matchLimbLength = (matchBeginBonePositions.second.first - matchBeginBonePositions.second.second).length() +
|
float matchBeginBoneLength = (matchBeginBonePositions.second.first - matchBeginBonePositions.second.second).length();
|
||||||
(matchMiddleBonePositions.second.first - matchMiddleBonePositions.second.second).length();
|
float matchMiddleBoneLength = (matchMiddleBonePositions.second.first - matchMiddleBonePositions.second.second).length();
|
||||||
|
float matchLimbLength = matchBeginBoneLength + matchMiddleBoneLength;
|
||||||
|
|
||||||
auto matchDistanceBetweenBeginAndEndBones = (matchBeginBonePositions.second.first - matchMiddleBonePositions.second.second).length();
|
auto matchDistanceBetweenBeginAndEndBones = (matchBeginBonePositions.second.first - matchMiddleBonePositions.second.second).length();
|
||||||
auto matchRotatePlaneNormal = QVector3D::crossProduct((matchBeginBonePositions.second.second - matchBeginBonePositions.second.first).normalized(), (matchMiddleBonePositions.second.second - matchBeginBonePositions.second.second).normalized());
|
auto matchRotatePlaneNormal = QVector3D::crossProduct((matchBeginBonePositions.second.second - matchBeginBonePositions.second.first).normalized(), (matchMiddleBonePositions.second.second - matchBeginBonePositions.second.second).normalized());
|
||||||
|
@ -148,14 +149,12 @@ void AnimalPoser::resolveChainRotation(const std::vector<QString> &limbBoneNames
|
||||||
qDebug() << middleBoneName << "not found in rigged bones";
|
qDebug() << middleBoneName << "not found in rigged bones";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto &middleBone = bones()[beginBoneIndex];
|
const auto &middleBone = bones()[middleBoneIndex];
|
||||||
|
|
||||||
float targetBeginBoneLength = (beginBone.headPosition - beginBone.tailPosition).length();
|
float targetBeginBoneLength = (beginBone.headPosition - beginBone.tailPosition).length();
|
||||||
float targetMiddleBoneLength = (middleBone.headPosition - middleBone.tailPosition).length();
|
float targetMiddleBoneLength = (middleBone.headPosition - middleBone.tailPosition).length();
|
||||||
float targetLimbLength = targetBeginBoneLength + targetMiddleBoneLength;
|
float targetLimbLength = targetBeginBoneLength + targetMiddleBoneLength;
|
||||||
|
|
||||||
//qDebug() << beginBoneName << "targetLimbLength:" << targetLimbLength << "matchLimbLength:" << matchLimbLength;
|
|
||||||
|
|
||||||
float targetDistanceBetweenBeginAndEndBones = matchDistanceBetweenBeginAndEndBones * (targetLimbLength / matchLimbLength);
|
float targetDistanceBetweenBeginAndEndBones = matchDistanceBetweenBeginAndEndBones * (targetLimbLength / matchLimbLength);
|
||||||
QVector3D targetEndBoneStartPosition = beginBone.headPosition + matchDirectionBetweenBeginAndEndPones * targetDistanceBetweenBeginAndEndBones;
|
QVector3D targetEndBoneStartPosition = beginBone.headPosition + matchDirectionBetweenBeginAndEndPones * targetDistanceBetweenBeginAndEndBones;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue