24 m_bone_parents(bone_count, 0),
41 m_bone_parents.resize(m_bone_parents.size() + bone_count, 0);
44 return first_bone_index;
58 m_bone_parents.clear();
65 const auto [iterator, inserted] = m_pose_map.emplace(name, *
this);
69 throw std::invalid_argument(
"Duplicate pose name");
72 return iterator->second;
77 if (!m_pose_map.erase(name))
79 throw std::invalid_argument(
"Pose not found");
90 if (child_index < parent_index)
92 throw std::invalid_argument(
"Child bone index precedes parent bone index");
95 m_bone_parents[child_index] = parent_index;
100 if (
auto i = m_bone_map.find(name); i != m_bone_map.end())
102 if (i->second != index)
104 throw std::invalid_argument(
"Duplicate bone name");
109 m_bone_map[name] = index;
115 if (
auto i = m_bone_map.find(name); i != m_bone_map.end())
125 if (
auto i = m_pose_map.find(name); i != m_pose_map.end())
135 if (
auto i = m_pose_map.find(name); i != m_pose_map.end())
std::uint16_t bone_index_type
Bone index type.
Animatable skeleton pose.
void resize()
Updates the number of bones in the rest pose if the skeleton has been modified.
void update(bone_index_type first_index, std::size_t bone_count) override
Updates a subset of the pose after one or more relative transforms have been changed.
Skeletal animation skeleton.
void remove_poses()
Removes all poses from the skeleton, excluding the rest pose.
std::optional< bone_index_type > get_bone_index(hash::fnv1a32_t name) const
Finds the index of a bone from the bone's name.
bone_index_type add_bones(std::size_t bone_count)
Add one or more bones to the skeleton.
void update_rest_pose()
Updates the rest pose of the skeleton.
void remove_bones()
Removes all bones from the skeleton.
const animation_pose * get_pose(hash::fnv1a32_t name) const
Finds a pose from the poses's name.
void set_bone_parent(bone_index_type child_index, bone_index_type parent_index)
Sets the parent of a bone.
void set_bone_name(bone_index_type index, hash::fnv1a32_t name)
Sets the name of a bone.
bone_index_type add_bone()
Adds a single bone to the skeleton.
skeleton()
Constructs an empty skeleton.
animation_pose & add_pose(hash::fnv1a32_t name)
Adds a pose to the skeleton.
void remove_pose(hash::fnv1a32_t name)
Removes a pose from the skeleton.
@ bone_index
Vertex bone indices (uvec4)
32-bit FNV-1a hash value.