diff --git a/Source/Contents/Models/ModelAnimation.cpp b/Source/Contents/Models/ModelAnimation.cpp index 8bb45d90f..0c408fb1f 100644 --- a/Source/Contents/Models/ModelAnimation.cpp +++ b/Source/Contents/Models/ModelAnimation.cpp @@ -92,10 +92,10 @@ void LegacyRotationTrack::Sample(int frame, matrix& output) const { ModelRotationKey result; if (next == 0) { - InterpolateModelRotation(0.0f, keys[0], keys[1], 0, result); + result.Interpolate(0.0f, keys[0], keys[1], 0); } else { const float amount = static_cast((frame - a.frame)) / static_cast((b.frame - a.frame)); - InterpolateModelRotation(amount, a, b, 0, result); + result.Interpolate(amount, a, b, 0); } QuaternionMatrix(result, output); diff --git a/Source/Contents/Models/ModelAnimation.h b/Source/Contents/Models/ModelAnimation.h index 9fa2474f2..f0e88882d 100644 --- a/Source/Contents/Models/ModelAnimation.h +++ b/Source/Contents/Models/ModelAnimation.h @@ -44,6 +44,5 @@ public: void Sample(float frame, const matrix& base, matrix& output) const; }; void QuaternionMatrix(const ModelRotationKey& key, matrix& output); -void InterpolateModelRotation(float amount, const ModelRotationKey& first, const ModelRotationKey& second, int spins, ModelRotationKey& output); #endif diff --git a/Source/Contents/Models/ModelQuaternion.cpp b/Source/Contents/Models/ModelQuaternion.cpp index a0faca792..2cde7788d 100644 --- a/Source/Contents/Models/ModelQuaternion.cpp +++ b/Source/Contents/Models/ModelQuaternion.cpp @@ -37,7 +37,7 @@ void QuaternionMatrix(const ModelRotationKey& key, matrix& output) { // OFFSET: 0x00541B30 // FUNCTION: fn_01736 -void InterpolateModelRotation(float amount, const ModelRotationKey& first, const ModelRotationKey& second, int spins, ModelRotationKey& output) { +void ModelRotationKey::Interpolate(float amount, const ModelRotationKey& first, const ModelRotationKey& second, int spins) { const float dot = ((second.rotation[1] * first.rotation[1] + second.rotation[0] * first.rotation[0]) + first.rotation[2] * second.rotation[2]) + first.rotation[3] * second.rotation[3]; const bool flip = dot < 0.0f; @@ -62,8 +62,8 @@ void InterpolateModelRotation(float amount, const ModelRotationKey& first, const secondWeight = -secondWeight; } - output.rotation[0] = first.rotation[0] * firstWeight + second.rotation[0] * secondWeight; - output.rotation[1] = secondWeight * second.rotation[1] + firstWeight * first.rotation[1]; - output.rotation[2] = firstWeight * first.rotation[2] + secondWeight * second.rotation[2]; - output.rotation[3] = firstWeight * first.rotation[3] + secondWeight * second.rotation[3]; + this->rotation[0] = first.rotation[0] * firstWeight + second.rotation[0] * secondWeight; + this->rotation[1] = secondWeight * second.rotation[1] + firstWeight * first.rotation[1]; + this->rotation[2] = firstWeight * first.rotation[2] + secondWeight * second.rotation[2]; + this->rotation[3] = firstWeight * first.rotation[3] + secondWeight * second.rotation[3]; } diff --git a/Source/Resource/Models/ModelResource.h b/Source/Resource/Models/ModelResource.h index 51c1a7b5a..7a09e6c10 100644 --- a/Source/Resource/Models/ModelResource.h +++ b/Source/Resource/Models/ModelResource.h @@ -29,6 +29,8 @@ struct ModelScaleKey { }; struct ModelRotationKey { + void Interpolate(float amount, const ModelRotationKey& first, const ModelRotationKey& second, int spins); + /* 0000 */ int frame; /* 0004 */ float rotation[4]; };