Skip to content

Commit 7eb898f

Browse files
authored
Merge pull request #380 from execphantasmagoria/next
[Fixes #381] Replaces GPU Skinning for Animation Blending
2 parents 3cfa3db + c674194 commit 7eb898f

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

include/Matrix.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ class Matrix : public ::Matrix {
120120

121121
[[nodiscard]] Matrix Multiply(const ::Matrix& right) const { return ::MatrixMultiply(*this, right); }
122122

123+
[[nodiscard]] Matrix Multiply(float value) const { return ::MatrixMultiplyValue(*this, value); }
124+
123125
Matrix operator*(const ::Matrix& matrix) { return ::MatrixMultiply(*this, matrix); }
124126

127+
Matrix operator*(float value) { return ::MatrixMultiplyValue(*this, value); }
128+
125129
static Matrix Frustum(double left, double right, double bottom, double top, double near, double far) {
126130
return ::MatrixFrustum(left, right, bottom, top, near, far);
127131
}

include/Model.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ class Model : public ::Model {
136136
}
137137

138138
/**
139-
* Update model animation pose
139+
* Blend two model animation poses
140140
*/
141-
Model& UpdateAnimationsEx(const ::ModelAnimation& animA, float frameA, const ::ModelAnimation& animB, float frameB, float blend) {
141+
Model& BlendAnimation(const ::ModelAnimation& animA, float frameA, const ::ModelAnimation& animB, float frameB, float blend) {
142142
::UpdateModelAnimationEx(*this, animA, frameA, animB, frameB, blend);
143143
return *this;
144144
}

include/ModelAnimation.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ class ModelAnimation : public ::ModelAnimation {
2626
other.keyframePoses = nullptr;
2727
}
2828

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

3232
/**
3333
* Load model animations from file
3434
*/
3535
static std::vector<ModelAnimation> Load(const std::string& fileName) {
3636
int count = 0;
3737
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
38+
3839
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + count);
3940

4041
RL_FREE(modelAnimations);
@@ -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,24 +72,31 @@ class ModelAnimation : public ::ModelAnimation {
7172
/**
7273
* Unload animation data
7374
*/
74-
void Unload(int animCount) { ::UnloadModelAnimations(this, animCount); }
75+
void Unload() {
76+
::UnloadModelAnimations(this, 1);
77+
}
78+
79+
static void Unload(ModelAnimation *modelAnimation, int count) {
80+
::UnloadModelAnimations(modelAnimation, count);
81+
}
7582

7683
/**
7784
* Update model animation pose
7885
*/
79-
ModelAnimation& Update(const ::Model& model, int frame) {
86+
ModelAnimation& Update(const ::Model& model, float frame) {
8087
::UpdateModelAnimation(model, *this, frame);
8188
return *this;
8289
}
8390

8491
/**
85-
* Update model animation mesh bone matrices (GPU skinning)
92+
* Blend two animation poses
8693
*/
87-
ModelAnimation& UpdateBones(const ::Model& model, int frame) {
88-
::UpdateModelAnimation(model, *this, frame);
94+
ModelAnimation& Blend(const ::Model& model, float frameA, const ::ModelAnimation& animB, float frameB, float blend) {
95+
::UpdateModelAnimationEx(model, *this, frameA, animB, frameB, blend);
8996
return *this;
9097
}
9198

99+
92100
/**
93101
* Check model animation skeleton match
94102
*/

0 commit comments

Comments
 (0)