Skip to content

Commit 7f2178b

Browse files
Reverted adding animCount as member variable. Unload() only unloads one animation. Replaced UpdateBones() with Blend() which utilizes UpdateModelAnimationEx()
1 parent d945e03 commit 7f2178b

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

include/ModelAnimation.hpp

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

@@ -34,9 +33,10 @@ class ModelAnimation : public ::ModelAnimation {
3433
* Load model animations from file
3534
*/
3635
static std::vector<ModelAnimation> Load(const std::string& fileName) {
37-
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &animCount);
36+
int count = 0;
37+
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
3838

39-
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + animCount);
39+
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + count);
4040

4141
RL_FREE(modelAnimations);
4242

@@ -73,29 +73,26 @@ class ModelAnimation : public ::ModelAnimation {
7373
* Unload animation data
7474
*/
7575
void Unload() {
76-
if(animCount <= 0) {
77-
throw std::runtime_error("ModelAnimation::Unload() called on an object that was not loaded with any animations.");
78-
}
79-
80-
::UnloadModelAnimations(this, animCount);
76+
::UnloadModelAnimations(this, 1);
8177
}
8278

8379
/**
8480
* Update model animation pose
8581
*/
86-
ModelAnimation& Update(const ::Model& model, int frame) {
82+
ModelAnimation& Update(const ::Model& model, float frame) {
8783
::UpdateModelAnimation(model, *this, frame);
8884
return *this;
8985
}
9086

9187
/**
92-
* Update model animation mesh bone matrices (GPU skinning)
88+
* Blend two animation poses
9389
*/
94-
ModelAnimation& UpdateBones(const ::Model& model, int frame) {
95-
::UpdateModelAnimation(model, *this, frame);
90+
ModelAnimation& Blend(const ::Model& model, float frameA, const ::ModelAnimation& animB, float frameB, float blend) {
91+
::UpdateModelAnimationEx(model, *this, frameA, animB, frameB, blend);
9692
return *this;
9793
}
9894

95+
9996
/**
10097
* Check model animation skeleton match
10198
*/

0 commit comments

Comments
 (0)