28#ifndef OZZ_OZZ_ANIMATION_RUNTIME_SKELETON_UTILS_H_
29#define OZZ_OZZ_ANIMATION_RUNTIME_SKELETON_UTILS_H_
33#include "ozz/animation/runtime/export.h"
34#include "ozz/animation/runtime/skeleton.h"
35#include "ozz/base/maths/transform.h"
42 const Skeleton& _skeleton,
int _joint);
47inline bool IsLeaf(
const Skeleton& _skeleton,
int _joint) {
48 const int num_joints = _skeleton.num_joints();
49 assert(_joint >= 0 && _joint < num_joints &&
"_joint index out of range");
50 const span<const int16_t>& parents = _skeleton.joint_parents();
51 const int next = _joint + 1;
52 return next == num_joints || parents[next] != _joint;
56OZZ_ANIMATION_DLL
int FindJoint(
const Skeleton& _skeleton,
const char* _name);
64template <
typename _Fct>
65inline _Fct IterateJointsDF(
const Skeleton& _skeleton, _Fct _fct,
66 int _from = Skeleton::kNoParent) {
67 const span<const int16_t>& parents = _skeleton.joint_parents();
68 const int num_joints = _skeleton.num_joints();
71 static_assert(Skeleton::kNoParent < 0,
72 "Algorithm relies on kNoParent being negative");
73 for (
int i = _from < 0 ? 0 : _from, process = i < num_joints; process;
74 ++i, process = i < num_joints && parents[i] >= _from) {
84template <
typename _Fct>
85inline _Fct IterateJointsDFReverse(
const Skeleton& _skeleton, _Fct _fct) {
86 const span<const int16_t>& parents = _skeleton.joint_parents();
87 for (
int i = _skeleton.num_joints() - 1; i >= 0; --i) {