From 0041e29ac1477b82992536ff837b3f0e7036a800 Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Thu, 5 Mar 2026 10:40:45 +0530 Subject: [PATCH 1/8] Updated Multiply() operator* to enable MatrixMultiplyValue() --- include/Matrix.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/Matrix.hpp b/include/Matrix.hpp index 7f82138d..829dba83 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -120,8 +120,12 @@ class Matrix : public ::Matrix { [[nodiscard]] Matrix Multiply(const ::Matrix& right) const { return ::MatrixMultiply(*this, right); } + [[nodiscard]] Matrix Multiply(float value) const { return ::MatrixMultiplyValue(*this, value); } + Matrix operator*(const ::Matrix& matrix) { return ::MatrixMultiply(*this, matrix); } + Matrix operator*(float value) { return ::MatrixMultiplyValue(*this, value); } + static Matrix Frustum(double left, double right, double bottom, double top, double near, double far) { return ::MatrixFrustum(left, right, bottom, top, near, far); } From d4cf1eb895d75104e02172e3dbccbb6d05c552d4 Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Thu, 5 Mar 2026 11:17:32 +0530 Subject: [PATCH 2/8] Fixed: ModelAnimation now has attribute animCount which is used to load animations and unload them. --- include/ModelAnimation.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index c5b2efd1..18b8aa02 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -13,6 +13,7 @@ namespace raylib { * Model animation */ class ModelAnimation : public ::ModelAnimation { + int animCount = 0; public: ModelAnimation(const ::ModelAnimation& model) { set(model); } @@ -26,16 +27,16 @@ class ModelAnimation : public ::ModelAnimation { other.keyframePoses = nullptr; } - // TODO: Implement a way to unload all animations at once, as the current Unload() only unloads one animation. - ~ModelAnimation() { Unload(1); } + // Unloads animation data using populated animCount field, which is set by Load() method. + ~ModelAnimation() { Unload(); } /** * Load model animations from file */ static std::vector Load(const std::string& fileName) { - int count = 0; - ::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count); - std::vector mats(modelAnimations, modelAnimations + count); + ::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &animCount); + + std::vector mats(modelAnimations, modelAnimations + animCount); RL_FREE(modelAnimations); @@ -58,7 +59,7 @@ class ModelAnimation : public ::ModelAnimation { return *this; } - Unload(1); + Unload(); set(other); other.boneCount = 0; @@ -71,7 +72,7 @@ class ModelAnimation : public ::ModelAnimation { /** * Unload animation data */ - void Unload(int animCount) { ::UnloadModelAnimations(this, animCount); } + void Unload() { ::UnloadModelAnimations(this, animCount); } /** * Update model animation pose From d945e03215f2aef0c10c33ab3e80e3bbdbb5941b Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Thu, 5 Mar 2026 11:23:08 +0530 Subject: [PATCH 3/8] Updated Unload() to check if animCount is 0 before unloading. --- include/ModelAnimation.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 18b8aa02..d23dc3e4 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -72,7 +72,13 @@ class ModelAnimation : public ::ModelAnimation { /** * Unload animation data */ - void Unload() { ::UnloadModelAnimations(this, animCount); } + void Unload() { + if(animCount <= 0) { + throw std::runtime_error("ModelAnimation::Unload() called on an object that was not loaded with any animations."); + } + + ::UnloadModelAnimations(this, animCount); + } /** * Update model animation pose From 7f2178b7ab7c0fe1a706f1be7a20d997ed7db7d9 Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Thu, 5 Mar 2026 19:12:24 +0530 Subject: [PATCH 4/8] Reverted adding animCount as member variable. Unload() only unloads one animation. Replaced UpdateBones() with Blend() which utilizes UpdateModelAnimationEx() --- include/ModelAnimation.hpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index d23dc3e4..9e229e01 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -13,7 +13,6 @@ namespace raylib { * Model animation */ class ModelAnimation : public ::ModelAnimation { - int animCount = 0; public: ModelAnimation(const ::ModelAnimation& model) { set(model); } @@ -34,9 +33,10 @@ class ModelAnimation : public ::ModelAnimation { * Load model animations from file */ static std::vector Load(const std::string& fileName) { - ::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &animCount); + int count = 0; + ::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count); - std::vector mats(modelAnimations, modelAnimations + animCount); + std::vector mats(modelAnimations, modelAnimations + count); RL_FREE(modelAnimations); @@ -73,29 +73,26 @@ class ModelAnimation : public ::ModelAnimation { * Unload animation data */ void Unload() { - if(animCount <= 0) { - throw std::runtime_error("ModelAnimation::Unload() called on an object that was not loaded with any animations."); - } - - ::UnloadModelAnimations(this, animCount); + ::UnloadModelAnimations(this, 1); } /** * Update model animation pose */ - ModelAnimation& Update(const ::Model& model, int frame) { + ModelAnimation& Update(const ::Model& model, float frame) { ::UpdateModelAnimation(model, *this, frame); return *this; } /** - * Update model animation mesh bone matrices (GPU skinning) + * Blend two animation poses */ - ModelAnimation& UpdateBones(const ::Model& model, int frame) { - ::UpdateModelAnimation(model, *this, frame); + ModelAnimation& Blend(const ::Model& model, float frameA, const ::ModelAnimation& animB, float frameB, float blend) { + ::UpdateModelAnimationEx(model, *this, frameA, animB, frameB, blend); return *this; } + /** * Check model animation skeleton match */ From 0847ecfaa552bef2bdd434337d6d3f9541e4afd3 Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Thu, 5 Mar 2026 19:16:47 +0530 Subject: [PATCH 5/8] Renamed UpdateModelAnimationEx() in Model.hpp to BlendAnimation() --- include/Model.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Model.hpp b/include/Model.hpp index 5e6597c0..93a1cbce 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -136,9 +136,9 @@ class Model : public ::Model { } /** - * Update model animation pose + * Blend two model animation poses */ - Model& UpdateAnimationsEx(const ::ModelAnimation& animA, float frameA, const ::ModelAnimation& animB, float frameB, float blend) { + Model& BlendAnimation(const ::ModelAnimation& animA, float frameA, const ::ModelAnimation& animB, float frameB, float blend) { ::UpdateModelAnimationEx(*this, animA, frameA, animB, frameB, blend); return *this; } From 355dfce59e44ff1bf4f9dcfc1a820e06c6d78f1b Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Fri, 6 Mar 2026 09:17:23 +0530 Subject: [PATCH 6/8] Updated Unload() to overload with animCount --- include/ModelAnimation.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 9e229e01..21a142aa 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -76,6 +76,10 @@ class ModelAnimation : public ::ModelAnimation { ::UnloadModelAnimations(this, 1); } + void Unload(int count) { + ::UnloadModelAnimations(this, count); + } + /** * Update model animation pose */ From e331ebf164d5b84b1be7a2beff1432be1b459e1f Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Fri, 6 Mar 2026 19:05:26 +0530 Subject: [PATCH 7/8] Added UnloadAnimations() as a static method --- include/ModelAnimation.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 21a142aa..c47fff5d 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -76,8 +76,8 @@ class ModelAnimation : public ::ModelAnimation { ::UnloadModelAnimations(this, 1); } - void Unload(int count) { - ::UnloadModelAnimations(this, count); + static void UnloadAnimations(ModelAnimation *modelAnimation, int count) { + ::UnloadModelAnimations(modelAnimation, count); } /** From c674194c47459953eb816e3fbd565b51e5e343b0 Mon Sep 17 00:00:00 2001 From: execphantasmagoria Date: Fri, 6 Mar 2026 19:12:45 +0530 Subject: [PATCH 8/8] Renamed UnloadAnimations to Unload for consistency --- include/ModelAnimation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index c47fff5d..6cbcd6a7 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -76,7 +76,7 @@ class ModelAnimation : public ::ModelAnimation { ::UnloadModelAnimations(this, 1); } - static void UnloadAnimations(ModelAnimation *modelAnimation, int count) { + static void Unload(ModelAnimation *modelAnimation, int count) { ::UnloadModelAnimations(modelAnimation, count); }