3#include "pixelbullet/filesystem/virtual_path.h"
4#include "pixelbullet/filesystem/virtual_path_serialization.h"
5#include "pixelbullet/scene/components/animation_state_component.h"
6#include "pixelbullet/scene/entity_id.h"
7#include "pixelbullet/serialization/node.h"
11#include <unordered_map>
18 std::string name =
"Default";
24 return lhs.name == rhs.name && lhs.clip_asset == rhs.clip_asset;
27inline bool operator!=(
const SkeletonAnimationClipBinding& lhs,
const SkeletonAnimationClipBinding& rhs)
35 std::vector<EntityId> joint_entities;
36 std::vector<SkeletonAnimationClipBinding> clips;
41 return lhs.skeleton_asset == rhs.skeleton_asset && lhs.joint_entities == rhs.joint_entities && lhs.clips == rhs.clips;
44inline bool operator!=(
const SkeletonAnimationComponent& lhs,
const SkeletonAnimationComponent& rhs)
49inline std::string NormalizeSkeletonAnimationClipName(std::string_view name, std::string_view fallback)
51 std::string normalized = name.empty() ? std::string(fallback) : std::string(name);
52 if (normalized.empty())
54 normalized = std::string(fallback);
61 std::unordered_map<std::string, std::size_t> counts;
64 std::string normalized_name = NormalizeSkeletonAnimationClipName(clip.name,
"Default");
65 const auto [it, inserted] = counts.emplace(normalized_name, 0u);
69 normalized_name +=
" " + std::to_string(it->second + 1u);
71 clip.name = std::move(normalized_name);
76 const std::string_view name)
80 if (clip.name == name)
92 if (clip.name == name)
103 if (component.clips.empty())
108 if (state !=
nullptr && !state->active_clip.empty())
116 return &component.clips.front();
121 node[
"name"] << clip.name;
122 node[
"clipAsset"] << clip.clip_asset;
128 if (node.has_property(
"name"))
130 node[
"name"] >> clip.name;
134 clip.name =
"Default";
136 node[
"clipAsset"] >> clip.clip_asset;
142 node[
"skeletonAsset"] << component.skeleton_asset;
143 node[
"jointEntities"] << component.joint_entities;
144 node[
"clips"] << component.clips;
150 node[
"skeletonAsset"] >> component.skeleton_asset;
151 if (node.has_property(
"jointEntities"))
153 node[
"jointEntities"] >> component.joint_entities;
157 component.joint_entities.clear();
159 if (node.has_property(
"clips"))
161 node[
"clips"] >> component.clips;
165 component.clips.clear();
167 NormalizeSkeletonAnimationComponent(component);
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:49
Definition virtual_path.h:10
Definition animation_state_component.h:10
Definition skeleton_animation_component.h:17
Definition skeleton_animation_component.h:33