refactor Entities

This commit is contained in:
MihailRis
2025-08-09 21:19:01 +03:00
parent 36a522bee0
commit 3eae377024
23 changed files with 485 additions and 348 deletions
+18 -1
View File
@@ -23,7 +23,7 @@ Bone::Bone(
std::string name,
std::string model,
std::vector<std::unique_ptr<Bone>> bones,
glm::vec3 offset
const glm::vec3& offset
)
: index(index),
name(std::move(name)),
@@ -53,6 +53,23 @@ Skeleton::Skeleton(const SkeletonConfig* config)
}
}
dv::value Skeleton::serialize(bool saveTextures, bool savePose) const {
auto root = dv::object();
if (saveTextures) {
auto& map = root.object("textures");
for (auto& [slot, texture] : textures) {
map[slot] = texture;
}
}
if (savePose) {
auto& list = root.list("pose");
for (auto& mat : pose.matrices) {
list.add(dv::to_value(mat));
}
}
return root;
}
static void get_all_nodes(std::vector<Bone*>& nodes, Bone* node) {
nodes[node->getIndex()] = node;
for (auto& subnode : node->getSubnodes()) {