Skip to content

Commit d4cf1eb

Browse files
Fixed: ModelAnimation now has attribute animCount which is used to load animations and unload them.
1 parent 0041e29 commit d4cf1eb

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

include/ModelAnimation.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace raylib {
1313
* Model animation
1414
*/
1515
class ModelAnimation : public ::ModelAnimation {
16+
int animCount = 0;
1617
public:
1718
ModelAnimation(const ::ModelAnimation& model) { set(model); }
1819

@@ -26,16 +27,16 @@ class ModelAnimation : public ::ModelAnimation {
2627
other.keyframePoses = nullptr;
2728
}
2829

29-
// TODO: Implement a way to unload all animations at once, as the current Unload() only unloads one animation.
30-
~ModelAnimation() { Unload(1); }
30+
// Unloads animation data using populated animCount field, which is set by Load() method.
31+
~ModelAnimation() { Unload(); }
3132

3233
/**
3334
* Load model animations from file
3435
*/
3536
static std::vector<ModelAnimation> Load(const std::string& fileName) {
36-
int count = 0;
37-
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
38-
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + count);
37+
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &animCount);
38+
39+
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + animCount);
3940

4041
RL_FREE(modelAnimations);
4142

@@ -58,7 +59,7 @@ class ModelAnimation : public ::ModelAnimation {
5859
return *this;
5960
}
6061

61-
Unload(1);
62+
Unload();
6263
set(other);
6364

6465
other.boneCount = 0;
@@ -71,7 +72,7 @@ class ModelAnimation : public ::ModelAnimation {
7172
/**
7273
* Unload animation data
7374
*/
74-
void Unload(int animCount) { ::UnloadModelAnimations(this, animCount); }
75+
void Unload() { ::UnloadModelAnimations(this, animCount); }
7576

7677
/**
7778
* Update model animation pose

0 commit comments

Comments
 (0)