fix: destroyed skeleton config access on skeleton reload

This commit is contained in:
MihailRis 2026-04-05 10:31:44 +03:00
parent 33db2633a2
commit 9893c09fd5
9 changed files with 35 additions and 22 deletions

View file

@ -78,7 +78,7 @@ namespace rigging {
};
struct Skeleton {
const SkeletonConfig* config;
std::shared_ptr<const SkeletonConfig> config;
Pose pose;
Pose calculated;
std::vector<BoneFlags> flags;
@ -89,13 +89,15 @@ namespace rigging {
util::VecInterpolation<3, float> interpolation {false};
Skeleton(const SkeletonConfig* config);
Skeleton(std::shared_ptr<const SkeletonConfig> config);
dv::value serialize(bool saveTextures, bool savePose) const;
void deserialize(const dv::value& root);
void setConfig(std::shared_ptr<const SkeletonConfig> config);
};
class SkeletonConfig {
class SkeletonConfig : public std::enable_shared_from_this<SkeletonConfig> {
std::string name;
std::unique_ptr<Bone> root;
std::unordered_map<std::string, size_t> indices;
@ -135,7 +137,7 @@ namespace rigging {
) const;
Skeleton instance() const {
return Skeleton(this);
return Skeleton(shared_from_this());
}
const Bone* find(std::string_view str) const;