diff --git a/src/animalposer.cpp b/src/animalposer.cpp index 9ef75f2f..8d315d79 100644 --- a/src/animalposer.cpp +++ b/src/animalposer.cpp @@ -54,7 +54,7 @@ void AnimalPoser::resolveTransform() mostBottomYBeforeTransform = bone.tailPosition.y(); } - float legHeightBeforeTransform = std::abs(mostBottomYBeforeTransform - firstSpineBone.headPosition.y()); + //float legHeightBeforeTransform = std::abs(mostBottomYBeforeTransform - firstSpineBone.headPosition.y()); auto transformedJointNodeTree = m_jointNodeTree; transformedJointNodeTree.recalculateTransformMatrices(); float mostBottomYAfterTransform = std::numeric_limits::max(); @@ -70,11 +70,13 @@ void AnimalPoser::resolveTransform() if (newPosition.y() < mostBottomYAfterTransform) mostBottomYAfterTransform = newPosition.y(); } - float legHeightAfterTransform = std::abs(mostBottomYAfterTransform - firstSpineBonePositionAfterTransform.y()); - float translateY = legHeightAfterTransform - legHeightBeforeTransform; + //float legHeightAfterTransform = std::abs(mostBottomYAfterTransform - firstSpineBonePositionAfterTransform.y()); + //float translateY = legHeightAfterTransform - legHeightBeforeTransform; + float translateY = mostBottomYBeforeTransform - mostBottomYAfterTransform; //qDebug() << "Leg height changed, translateY:" << translateY << "legHeightBeforeTransform:" << legHeightBeforeTransform << "legHeightAfterTransform:" << legHeightAfterTransform << "firstSpineBonePositionAfterTransform:" << firstSpineBonePositionAfterTransform << "firstSpineBone.headPosition:" << firstSpineBone.headPosition; + /* const auto &findRootParameters = parameters().find(Rigger::rootBoneName); if (findRootParameters != parameters().end()) { auto findHeightAboveGroundLevel = findRootParameters->second.find("heightAboveGroundLevel"); @@ -85,6 +87,7 @@ void AnimalPoser::resolveTransform() //qDebug() << "heightAboveGroundLevel:" << heightAboveGroundLevel << "myHeightAboveGroundLevel:" << myHeightAboveGroundLevel << "legHeightBeforeTransform:" << legHeightBeforeTransform << "applied translateY:" << translateY; } } + */ if (!qFuzzyIsNull(translateY)) { int rootBoneIndex = findBoneIndex(Rigger::rootBoneName); diff --git a/src/motionsgenerator.cpp b/src/motionsgenerator.cpp index 6ac86150..0b5f2199 100644 --- a/src/motionsgenerator.cpp +++ b/src/motionsgenerator.cpp @@ -85,8 +85,11 @@ float MotionsGenerator::calculatePoseDuration(const QUuid &poseId) if (nullptr == pose) return 0; float totalDuration = 0; - for (const auto &frame: *pose) { - totalDuration += valueOfKeyInMapOrEmpty(frame.first, "duration").toFloat(); + if (pose->size() > 1) { + // Pose with only one frame has zero duration + for (const auto &frame: *pose) { + totalDuration += valueOfKeyInMapOrEmpty(frame.first, "duration").toFloat(); + } } return totalDuration; } @@ -149,6 +152,8 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set &vi float interval = 1.0 / m_fps; float lastProgress = 0; + if (totalDuration < interval) + totalDuration = interval; for (float progress = 0; progress < totalDuration; ) { int clipIndex = findClipIndexByProgress(progress); if (-1 == clipIndex) { diff --git a/src/posedocument.cpp b/src/posedocument.cpp index 1288b4dd..b727b247 100644 --- a/src/posedocument.cpp +++ b/src/posedocument.cpp @@ -158,8 +158,8 @@ void PoseDocument::reset() m_otherIds.clear(); m_boneNameToIdsMap.clear(); m_bonesPartId = QUuid(); - m_groundPartId = QUuid(); - m_groundEdgeId = QUuid(); + //m_groundPartId = QUuid(); + //m_groundEdgeId = QUuid(); emit cleanup(); emit parametersChanged(); } @@ -253,24 +253,24 @@ void PoseDocument::fromParameters(const std::vector *rigBones, otherParameters); std::map> boneNameToIdsMap; - QUuid groundPartId; + //QUuid groundPartId; QUuid bonesPartId; - QUuid groundEdgeId; + //QUuid groundEdgeId; parametersToNodes(&otherBones, otherHeightAboveGroundLevel, &boneNameToIdsMap, - &groundPartId, + //&groundPartId, &bonesPartId, - &groundEdgeId, + //&groundEdgeId, true); } parametersToNodes(&bones, heightAboveGroundLevel, &m_boneNameToIdsMap, - &m_groundPartId, + //&m_groundPartId, &m_bonesPartId, - &m_groundEdgeId, + //&m_groundEdgeId, false); emit parametersChanged(); @@ -279,9 +279,9 @@ void PoseDocument::fromParameters(const std::vector *rigBones, void PoseDocument::parametersToNodes(const std::vector *rigBones, const float heightAboveGroundLevel, std::map> *boneNameToIdsMap, - QUuid *groundPartId, + //QUuid *groundPartId, QUuid *bonesPartId, - QUuid *groundEdgeId, + //QUuid *groundEdgeId, bool isOther) { if (nullptr == rigBones || rigBones->empty()) { @@ -402,6 +402,7 @@ void PoseDocument::parametersToNodes(const std::vector *rigBones, nodeMap[findRootNodeId->second].setRadius(m_nodeRadius * 2); } + /* if (!isOther) { *groundPartId = QUuid::createUuid(); auto &groundPart = partMap[*groundPartId]; @@ -452,6 +453,7 @@ void PoseDocument::parametersToNodes(const std::vector *rigBones, nodeMap[groundNodesPair.second].edgeIds.push_back(edge.id); } } + */ if (isOther) { for (const auto &nodeIt: newAddedNodeIds) @@ -536,6 +538,7 @@ float PoseDocument::findFirstSpineY() const void PoseDocument::toParameters(std::map> ¶meters, const std::set &limitNodeIds) const { + /* float heightAboveGroundLevel = 0; auto findGroundEdge = edgeMap.find(m_groundEdgeId); if (findGroundEdge != edgeMap.end()) { @@ -559,6 +562,7 @@ void PoseDocument::toParameters(std::map> &p auto &boneParameter = parameters[Rigger::rootBoneName]; boneParameter["heightAboveGroundLevel"] = QString::number(heightAboveGroundLevel); } + */ for (const auto &item: m_boneNameToIdsMap) { const auto &boneNodeIdPair = item.second; auto findFirstNode = nodeMap.find(boneNodeIdPair.first); diff --git a/src/posedocument.h b/src/posedocument.h index 63976d7f..a66413e8 100644 --- a/src/posedocument.h +++ b/src/posedocument.h @@ -66,18 +66,18 @@ private: void parametersToNodes(const std::vector *rigBones, const float heightAboveGroundLevel, std::map> *boneNameToIdsMap, - QUuid *groundPartId, + //QUuid *groundPartId, QUuid *bonesPartId, - QUuid *groundEdgeId, + //QUuid *groundEdgeId, bool isOther=false); void updateBonesAndHeightAboveGroundLevelFromParameters(std::vector *bones, float *heightAboveGroundLevel, const std::map> ¶meters); std::map> m_boneNameToIdsMap; - QUuid m_groundPartId; + //QUuid m_groundPartId; QUuid m_bonesPartId; - QUuid m_groundEdgeId; + //QUuid m_groundEdgeId; std::deque m_undoItems; std::deque m_redoItems; std::vector m_riggerBones; diff --git a/src/posemanagewidget.cpp b/src/posemanagewidget.cpp index 40bb4d89..14d9b416 100644 --- a/src/posemanagewidget.cpp +++ b/src/posemanagewidget.cpp @@ -12,9 +12,8 @@ PoseManageWidget::PoseManageWidget(const Document *document, QWidget *parent) : { QPushButton *addPoseButton = new QPushButton(Theme::awesome()->icon(fa::plus), tr("Add Pose...")); addPoseButton->hide(); - connect(addPoseButton, &QPushButton::clicked, this, &PoseManageWidget::showAddPoseDialog); - + QHBoxLayout *toolsLayout = new QHBoxLayout; toolsLayout->addWidget(addPoseButton);