From 6ca06f4e80dce86397843f66f6ac562e4edfb428 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Mon, 10 Jun 2019 10:09:30 +0930 Subject: [PATCH] Fix rig Fix the left and right limbs pairing algorithm --- src/animalrigger.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/animalrigger.cpp b/src/animalrigger.cpp index 55f5a15b..15ff6f29 100644 --- a/src/animalrigger.cpp +++ b/src/animalrigger.cpp @@ -201,13 +201,17 @@ bool AnimalRigger::rig() std::set bodyVerticies; bool isMainBodyVerticalAligned = false; + float bodyLength = 0; addTrianglesToVertices(bodyTriangles, bodyVerticies); { QVector3D xMin, xMax, yMin, yMax, zMin, zMax; resolveBoundingBox(bodyVerticies, xMin, xMax, yMin, yMax, zMin, zMax); - isMainBodyVerticalAligned = fabs(yMax.y() - yMin.y()) > fabs(zMax.z() - zMin.z()); + float yLength = fabs(yMax.y() - yMin.y()); + float zLength = fabs(zMax.z() - zMin.z()); + isMainBodyVerticalAligned = yLength > zLength; + bodyLength = isMainBodyVerticalAligned ? yLength : zLength; } - qDebug() << "isMainBodyVerticalAligned:" << isMainBodyVerticalAligned; + qDebug() << "isMainBodyVerticalAligned:" << isMainBodyVerticalAligned << "bodyLength:" << bodyLength; // Collect all branchs auto neckIndices = m_marksMap.find(std::make_pair(BoneMark::Neck, SkeletonSide::None)); @@ -291,7 +295,7 @@ bool AnimalRigger::rig() const auto &mark = m_marks[chainColumns[side]->at(sideIndices[side])]; const auto &coord = isMainBodyVerticalAligned ? mark.bonePosition.y() : mark.bonePosition.z(); - if (coord <= choosenCoord + 0.001) { + if (coord <= choosenCoord + bodyLength / 5) { chainMarkIndices.insert(chainColumns[side]->at(sideIndices[side])); sumOfChainPositions += mark.bonePosition; ++countOfChains;