diff --git a/src/animalposer.cpp b/src/animalposer.cpp index 6e924871..68fae8be 100644 --- a/src/animalposer.cpp +++ b/src/animalposer.cpp @@ -20,13 +20,13 @@ void AnimalPoser::resolveTransform() resolveChainRotation(chain.second); } - int firstSpineBoneIndex = findBoneIndex(Rigger::firstSpineBoneName); - if (-1 == firstSpineBoneIndex) { - qDebug() << "Find first spine bone failed:" << Rigger::firstSpineBoneName; - return; - } + //int firstSpineBoneIndex = findBoneIndex(Rigger::firstSpineBoneName); + //if (-1 == firstSpineBoneIndex) { + // qDebug() << "Find first spine bone failed:" << Rigger::firstSpineBoneName; + // return; + //} - const auto &firstSpineBone = bones()[firstSpineBoneIndex]; + //const auto &firstSpineBone = bones()[firstSpineBoneIndex]; float mostBottomYBeforeTransform = std::numeric_limits::max(); for (const auto &bone: bones()) { @@ -38,15 +38,15 @@ void AnimalPoser::resolveTransform() auto transformedJointNodeTree = m_jointNodeTree; transformedJointNodeTree.recalculateTransformMatrices(); float mostBottomYAfterTransform = std::numeric_limits::max(); - QVector3D firstSpineBonePositionAfterTransform = firstSpineBone.headPosition; + //QVector3D firstSpineBonePositionAfterTransform = firstSpineBone.headPosition; for (int i = 0; i < (int)transformedJointNodeTree.nodes().size(); ++i) { const auto &bone = bones()[i]; const auto &jointNode = transformedJointNodeTree.nodes()[i]; QVector3D newPosition = jointNode.transformMatrix * bone.tailPosition; - if (0 == i) { + //if (0 == i) { // Root bone's tail position is the first spine bone's head position - firstSpineBonePositionAfterTransform = newPosition; - } + // firstSpineBonePositionAfterTransform = newPosition; + //} if (newPosition.y() < mostBottomYAfterTransform) mostBottomYAfterTransform = newPosition.y(); } diff --git a/src/animalrigger.cpp b/src/animalrigger.cpp index c8542c2c..ab3d6590 100644 --- a/src/animalrigger.cpp +++ b/src/animalrigger.cpp @@ -219,6 +219,7 @@ bool AnimalRigger::rig() auto tailIndices = m_marksMap.find(std::make_pair(BoneMark::Tail, SkeletonSide::None)); auto leftLimbIndices = m_marksMap.find(std::make_pair(BoneMark::Limb, SkeletonSide::Left)); auto rightLimbIndices = m_marksMap.find(std::make_pair(BoneMark::Limb, SkeletonSide::Right)); + bool hasTail = false; std::vector nosideMarkIndices; std::vector leftMarkIndices; std::vector righMarkIndices; @@ -229,6 +230,7 @@ bool AnimalRigger::rig() if (tailIndices != m_marksMap.end()) { for (const auto &index: tailIndices->second) nosideMarkIndices.push_back(index); + hasTail = true; } if (leftLimbIndices != m_marksMap.end()) { for (const auto &index: leftLimbIndices->second) @@ -421,7 +423,7 @@ bool AnimalRigger::rig() spineBoneHeadPosition.setY(averagePoint.y()); } - QString spineName = namingSpine(spineGenerateOrder); + QString spineName = namingSpine(spineGenerateOrder, hasTail); m_resultBones.push_back(RiggerBone()); RiggerBone &spineBone = m_resultBones.back(); @@ -439,8 +441,8 @@ bool AnimalRigger::rig() m_resultBones[boneIndexMap[Rigger::rootBoneName]].tailPosition = spineBone.headPosition; m_resultBones[boneIndexMap[Rigger::rootBoneName]].children.push_back(spineBone.index); } else { - m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder - 1)]].tailPosition = spineBone.headPosition; - m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder - 1)]].children.push_back(spineBone.index); + m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder - 1, hasTail)]].tailPosition = spineBone.headPosition; + m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder - 1, hasTail)]].children.push_back(spineBone.index); } for (const auto &chainMarkIndex: spineNode.chainMarkIndices) { @@ -460,7 +462,7 @@ bool AnimalRigger::rig() if (1 == spineGenerateOrder) { m_resultBones[boneIndexMap[Rigger::rootBoneName]].children.push_back(ribBone.index); } else { - m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder)]].children.push_back(ribBone.index); + m_resultBones[boneIndexMap[namingSpine(spineGenerateOrder, hasTail)]].children.push_back(ribBone.index); } std::vector jointMarkIndices; @@ -619,10 +621,14 @@ QString AnimalRigger::namingChain(const QString &baseName, SkeletonSide side, in return namingChainPrefix(baseName, side, orderInSide, totalInSide) + "_Joint" + QString::number(jointOrder); } -QString AnimalRigger::namingSpine(int spineOrder) +QString AnimalRigger::namingSpine(int spineOrder, bool hasTail) { - if (1 == spineOrder) - return Rigger::firstSpineBoneName; + if (hasTail) { + if (spineOrder <= 2) { + return "Spine0" + QString::number(spineOrder); + } + spineOrder -= 2; + } return "Spine" + QString::number(spineOrder); } diff --git a/src/animalrigger.h b/src/animalrigger.h index d0ca8c39..72fd786f 100644 --- a/src/animalrigger.h +++ b/src/animalrigger.h @@ -19,7 +19,7 @@ protected: BoneMark translateBoneMark(BoneMark boneMark) override; private: bool collectJontsForChain(int markIndex, std::vector &jointMarkIndices); - static QString namingSpine(int spineOrder); + static QString namingSpine(int spineOrder, bool hasTail); static QString namingConnector(const QString &spineName, const QString &chainName); static QString namingChain(const QString &baseName, SkeletonSide side, int orderInSide, int totalInSide, int jointOrder); static QString namingChainPrefix(const QString &baseName, SkeletonSide side, int orderInSide, int totalInSide); diff --git a/src/posedocument.cpp b/src/posedocument.cpp index 0da0b167..79b6955a 100644 --- a/src/posedocument.cpp +++ b/src/posedocument.cpp @@ -514,13 +514,14 @@ float PoseDocument::findFootBottomY() const return maxY; } -float PoseDocument::findLegHeight() const -{ - float firstSpineY = findFirstSpineY(); - float footBottomY = findFootBottomY(); - return std::abs(footBottomY - firstSpineY); -} +//float PoseDocument::findLegHeight() const +//{ +// float firstSpineY = findFirstSpineY(); +// float footBottomY = findFootBottomY(); +// return std::abs(footBottomY - firstSpineY); +//} +/* float PoseDocument::findFirstSpineY() const { const auto &findFirstSpine = m_boneNameToIdsMap.find(Rigger::firstSpineBoneName); @@ -535,6 +536,7 @@ float PoseDocument::findFirstSpineY() const } return firstSpineNode->y; } +*/ void PoseDocument::toParameters(std::map> ¶meters, const std::set &limitNodeIds) const { diff --git a/src/posedocument.h b/src/posedocument.h index a66413e8..e77dc30c 100644 --- a/src/posedocument.h +++ b/src/posedocument.h @@ -61,8 +61,8 @@ public: private: QString findBoneNameByNodeId(const QUuid &nodeId); float findFootBottomY() const; - float findFirstSpineY() const; - float findLegHeight() const; + //float findFirstSpineY() const; + //float findLegHeight() const; void parametersToNodes(const std::vector *rigBones, const float heightAboveGroundLevel, std::map> *boneNameToIdsMap, diff --git a/src/rigger.cpp b/src/rigger.cpp index 5e420aba..bf8f3f5a 100644 --- a/src/rigger.cpp +++ b/src/rigger.cpp @@ -7,7 +7,7 @@ size_t Rigger::m_maxCutOffSplitterExpandRound = 3; QString Rigger::rootBoneName = "Body"; -QString Rigger::firstSpineBoneName = "Spine1"; +//QString Rigger::firstSpineBoneName = "Spine1"; Rigger::Rigger(const std::vector &verticesPositions, const std::set &inputTriangles) : diff --git a/src/rigger.h b/src/rigger.h index eea49fb8..9885f498 100644 --- a/src/rigger.h +++ b/src/rigger.h @@ -130,7 +130,7 @@ public: const std::map &resultWeights(); virtual bool rig() = 0; static QString rootBoneName; - static QString firstSpineBoneName; + //static QString firstSpineBoneName; protected: virtual bool validate() = 0; virtual bool isCutOffSplitter(BoneMark boneMark) = 0;