19 for (
size_t iJoint = 0; iJoint <
joints.size(); ++iJoint) {
26 for (
size_t i = 0; i <
joints.size(); i++) {
27 if (
joints[i].name == name) {
36 std::vector<std::string> result;
37 result.reserve(
joints.size());
38 for (
const auto& j :
joints) {
39 result.emplace_back(j.name);
50 "Out of bounds getChildrenJoints query. Requested index: {}. Number of joints: {}",
54 std::vector<size_t> childrenJoints;
55 std::vector<int> jointDistance(
joints.size(), -1);
56 jointDistance[jointId] = 0;
60 for (
size_t jointIter = jointId + 1; jointIter <
joints.size(); ++jointIter) {
61 const auto jointParent =
joints[jointIter].parent;
62 const int distParent = (jointParent ==
kInvalidIndex) ? -1 : jointDistance[jointParent];
63 if ((recursive && distParent >= 0) || (!recursive && distParent == 0)) {
64 jointDistance[jointIter] = distParent + 1;
65 childrenJoints.push_back(jointIter);
69 return childrenJoints;
77 if (jointId == ancestorJointId) {
80 jointId =
joints[jointId].parent;
93 return joint1 == joint2 ||
joints[joint1].parent == joint2 ||
joints[joint2].parent == joint1;
101 while (joint1 != joint2) {
105 }
else if (joint1 < joint2) {
106 joint2 =
joints[joint2].parent;
108 joint1 =
joints[joint1].parent;
#define MT_CHECK(condition,...)
Runtime check macros with two interchangeable backends:
#define MT_THROW_IF_T(Condition, Exception,...)
Conditionally throws an exception of a specified type with a formatted message if the condition is tr...
JointListT< float > JointList
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
The skeletal structure of a momentum Character.
size_t commonAncestor(size_t joint1, size_t joint2) const
Returns the lowest common ancestor of two joints in the hierarchy, or kInvalidIndex if either joint i...
size_t getJointIdByName(std::string_view name) const
Returns the index of a joint with the given name, or kInvalidIndex if not found.
JointList joints
The list of joints in this skeleton, ordered such that every joint's parent appears earlier in the li...
std::vector< size_t > getChildrenJoints(size_t jointId, bool recursive=true) const
Returns indices of child joints of the specified joint.
std::vector< std::string > getJointNames() const
bool isAncestor(size_t jointId, size_t ancestorJointId) const
Returns true if ancestorJointId is an ancestor of jointId.
bool isSameOrAdjacentJoints(size_t joint1, size_t joint2) const
Returns true if the two joints are the same, or one is the direct parent of the other.