diff --git a/src/motionsgenerator.cpp b/src/motionsgenerator.cpp index 04d1ca57..7d83a6cf 100644 --- a/src/motionsgenerator.cpp +++ b/src/motionsgenerator.cpp @@ -188,8 +188,10 @@ const JointNodeTree &MotionsGenerator::poseJointNodeTree(const QUuid &poseId) if (findResult != m_poseJointNodeTreeMap.end()) return findResult->second; + const auto ¶meters = m_poses[poseId]; + m_poser->reset(); - m_poser->parameters() = m_poses[poseId]; + m_poser->parameters() = parameters; m_poser->commit(); auto insertResult = m_poseJointNodeTreeMap.insert({poseId, m_poser->resultJointNodeTree()}); return insertResult.first->second; diff --git a/src/posedocument.cpp b/src/posedocument.cpp index 9e605ccb..2bf33740 100644 --- a/src/posedocument.cpp +++ b/src/posedocument.cpp @@ -132,11 +132,16 @@ void PoseDocument::fromParameters(const std::vector *rigBones, if (findXResult != map.end() || findYResult != map.end() || findZResult != map.end()) { - bone.tailPosition = { + QVector3D toPosition = { valueOfKeyInMapOrEmpty(map, "toX").toFloat(), valueOfKeyInMapOrEmpty(map, "toY").toFloat(), valueOfKeyInMapOrEmpty(map, "toZ").toFloat() }; + bone.tailPosition = toPosition; + for (const auto &child: bone.children) { + auto &childBone = bones[child]; + childBone.headPosition = toPosition; + } } } } @@ -405,7 +410,6 @@ void PoseDocument::toParameters(std::map> &p boneParameter["translateY"] = QString::number(translateY); } for (const auto &item: m_boneNameToIdsMap) { - auto &boneParameter = parameters[item.first]; const auto &boneNodeIdPair = item.second; auto findFirstNode = nodeMap.find(boneNodeIdPair.first); if (findFirstNode == nodeMap.end()) @@ -413,6 +417,7 @@ void PoseDocument::toParameters(std::map> &p auto findSecondNode = nodeMap.find(boneNodeIdPair.second); if (findSecondNode == nodeMap.end()) continue; + auto &boneParameter = parameters[item.first]; boneParameter["fromX"] = QString::number(toOutcomeX(findFirstNode->second.x)); boneParameter["fromY"] = QString::number(toOutcomeY(findFirstNode->second.y)); boneParameter["fromZ"] = QString::number(toOutcomeZ(findFirstNode->second.z)); diff --git a/src/poseeditwidget.cpp b/src/poseeditwidget.cpp index 029389af..908703dd 100644 --- a/src/poseeditwidget.cpp +++ b/src/poseeditwidget.cpp @@ -222,6 +222,9 @@ void PoseEditWidget::updatePreview() if (nullptr == poser) return; + m_parameters.clear(); + m_poseDocument->toParameters(m_parameters); + poser->parameters() = m_parameters; poser->commit(); m_posePreviewManager->postUpdate(*poser, m_document->currentRiggedOutcome(), *rigWeights);