diff --git a/rwengine/src/engine/Animator.hpp b/rwengine/src/engine/Animator.hpp index 52eebbac..9cb06d41 100644 --- a/rwengine/src/engine/Animator.hpp +++ b/rwengine/src/engine/Animator.hpp @@ -34,7 +34,7 @@ class Animator { float speed; /// Automatically restart bool repeat; - std::map boneInstances; + std::map, ModelFrame*> boneInstances; }; /** diff --git a/rwengine/src/loaders/LoaderIFP.cpp b/rwengine/src/loaders/LoaderIFP.cpp index a42728e0..2c3c9ab1 100644 --- a/rwengine/src/loaders/LoaderIFP.cpp +++ b/rwengine/src/loaders/LoaderIFP.cpp @@ -79,7 +79,7 @@ bool LoaderIFP::loadFromMemory(char* data) { CPAN* cpan = read(data, dataI); ANIM* frames = read(data, dataI); - AnimationBone* bonedata = new AnimationBone; + auto bonedata = std::make_shared(); bonedata->name = frames->name; bonedata->frames.reserve(frames->frames); diff --git a/rwengine/src/loaders/LoaderIFP.hpp b/rwengine/src/loaders/LoaderIFP.hpp index 4605fcd4..b51853ea 100644 --- a/rwengine/src/loaders/LoaderIFP.hpp +++ b/rwengine/src/loaders/LoaderIFP.hpp @@ -40,7 +40,7 @@ struct AnimationBone { */ struct Animation { std::string name; - std::map bones; + std::map> bones; float duration; }; diff --git a/rwengine/src/objects/CharacterObject.cpp b/rwengine/src/objects/CharacterObject.cpp index 14377332..15fd9d15 100644 --- a/rwengine/src/objects/CharacterObject.cpp +++ b/rwengine/src/objects/CharacterObject.cpp @@ -198,7 +198,7 @@ glm::vec3 CharacterObject::updateMovementAnimation(float dt) { const auto& root = modelroot->getChildren()[0]; auto it = movementAnimation->bones.find(root->getName()); if (it != movementAnimation->bones.end()) { - AnimationBone* rootBone = it->second; + auto rootBone = it->second; float step = dt; const float duration = animator->getAnimation(AnimIndexMovement)->duration; diff --git a/tests/test_animation.cpp b/tests/test_animation.cpp index adca5315..e4b2fc0d 100644 --- a/tests/test_animation.cpp +++ b/tests/test_animation.cpp @@ -18,16 +18,19 @@ BOOST_AUTO_TEST_CASE(test_matrix) { Animator animator(test_model); animation->duration = 1.f; - animation->bones["player"] = new AnimationBone{ - "player", - 0, - 0, - 1.0f, - AnimationBone::RT0, - { - {glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0}, - {glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1}, - }}; + animation->bones["player"] = std::shared_ptr( + new AnimationBone { + "player", + 0, + 0, + 1.0f, + AnimationBone::RT0, + { + {glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0}, + {glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1}, + } + } + ); animator.playAnimation(0, animation, 1.f, false);