rename rig to skeleton

This commit is contained in:
MihailRis
2024-07-10 04:28:12 +03:00
parent 91230ecbeb
commit 60f4f33180
24 changed files with 187 additions and 187 deletions
+22 -22
View File
@@ -17,8 +17,8 @@ namespace model {
}
namespace rigging {
struct Rig;
class RigConfig;
struct Skeleton;
class SkeletonConfig;
struct Pose {
std::vector<glm::mat4> matrices;
@@ -28,19 +28,19 @@ namespace rigging {
}
};
class RigNode {
class Bone {
size_t index;
std::string name;
std::string modelName;
std::vector<std::unique_ptr<RigNode>> subnodes;
std::vector<std::unique_ptr<Bone>> bones;
model::Model* model = nullptr;
bool modelUpdated = true;
public:
RigNode(
Bone(
size_t index,
std::string name,
std::string model,
std::vector<std::unique_ptr<RigNode>> subnodes);
std::vector<std::unique_ptr<Bone>> bones);
void setModel(const std::string& name);
@@ -59,59 +59,59 @@ namespace rigging {
}
const auto& getSubnodes() const {
return subnodes;
return bones;
}
};
struct Rig {
const RigConfig* config;
struct Skeleton {
const SkeletonConfig* config;
Pose pose;
Pose calculated;
std::unordered_map<std::string, std::string> textures;
};
class RigConfig {
class SkeletonConfig {
std::string name;
std::unique_ptr<RigNode> root;
std::unique_ptr<Bone> root;
std::unordered_map<std::string, size_t> indices;
/// Nodes and indices are ordered from root to subnodes.
/// Nodes and indices are ordered from root to bones.
/// Example:
/// 0 - root
/// 1 --- sub1
/// 2 ----- subsub1
/// 3 --- sub2
std::vector<RigNode*> nodes;
std::vector<Bone*> nodes;
size_t update(
size_t index,
Rig& rig,
RigNode* node,
Skeleton& skeleton,
Bone* node,
glm::mat4 matrix) const;
public:
RigConfig(const std::string& name, std::unique_ptr<RigNode> root,
SkeletonConfig(const std::string& name, std::unique_ptr<Bone> root,
size_t nodesCount);
void update(Rig& rig, glm::mat4 matrix) const;
void update(Skeleton& skeleton, glm::mat4 matrix) const;
void render(
Assets* assets,
ModelBatch& batch,
Rig& rig,
Skeleton& skeleton,
const glm::mat4& matrix) const;
Rig instance() const {
return Rig {
Skeleton instance() const {
return Skeleton {
this, Pose(nodes.size()), Pose(nodes.size()), {}
};
}
static std::unique_ptr<RigConfig> parse(
static std::unique_ptr<SkeletonConfig> parse(
std::string_view src,
std::string_view file,
std::string_view name
);
const std::vector<RigNode*>& getNodes() const {
const std::vector<Bone*>& getNodes() const {
return nodes;
}