mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
refactor Entities
This commit is contained in:
parent
36a522bee0
commit
3eae377024
23 changed files with 485 additions and 348 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue