void StaticArmature::clone_from(const IArmature & rhs) { for (auto& j : rhs.joints()) m_order.push_back(j.ID); this->m_joints.resize(m_order.size()); this->m_rootIdx = rhs.root()->ID; this->m_defaultFrame = rhs.bind_frame(); // Copy Joint meta-data for (auto& j : rhs.joints()) m_joints[j.ID] = j; // rebuild structure for (int i : this->m_order) { if (m_joints[i].ParentID >= 0 && m_joints[i].ParentID != i) { m_joints[m_joints[i].ParentID].append_children_back(&m_joints[i]); } } }
void FrameRebuildLocal(const IArmature& armature, ArmatureFrameView frame) { for (auto& joint : armature.joints()) { auto& bone = frame[joint.ID]; if (joint.is_root()) { bone.LclRotation = bone.GblRotation; bone.LclScaling = bone.GblScaling; bone.LclTranslation = bone.GblTranslation; bone.LclLength = bone.GblLength = 1.0f; // Length of root doesnot have any meaning } else { bone.UpdateLocalData(frame[joint.ParentID]); } } }