From cddc4c15cc184a822407f46d3690f52ca84baf2b Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sat, 16 Jun 2018 20:04:17 +0800 Subject: [PATCH] Make root node and direct children as breathe scaling target if no spine node marked. --- src/rigcontroller.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rigcontroller.cpp b/src/rigcontroller.cpp index 361c0838..f7530ea4 100644 --- a/src/rigcontroller.cpp +++ b/src/rigcontroller.cpp @@ -74,13 +74,21 @@ void RigController::lift(QVector3D offset) void RigController::breathe(float amount) { - if (m_spine.empty() || amount <= 0) + if (m_inputJointNodeTree.joints().empty() || amount <= 0) return; std::vector spineJoints; for (auto i = 0u; i < m_spine.size(); i++) { int jointIndex = m_inputJointNodeTree.nodeToJointIndex(m_spine[i].first, m_spine[i].second); spineJoints.push_back(jointIndex); } + if (spineJoints.empty()) { + // if no spine joints found, make the root node and its direct children as spine + spineJoints.push_back(0); + for (const auto &child: m_inputJointNodeTree.joints()[0].children) + spineJoints.push_back(child); + } + if (spineJoints.empty()) + return; // make sure parent get processed first std::sort(spineJoints.begin(), spineJoints.end()); float inverseAmount = 1 / amount;