diff options
author | aap <aap@papnet.eu> | 2020-05-08 15:59:57 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-05-08 15:59:57 +0200 |
commit | 2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1 (patch) | |
tree | 25f43ed9e6a30b05603d3f1b75be3d3f8d2fee5f /src/animation/AnimBlendHierarchy.cpp | |
parent | Merge pull request #522 from Nick007J/miami (diff) | |
download | re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.tar re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.tar.gz re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.tar.bz2 re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.tar.lz re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.tar.xz re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.tar.zst re3-2eee4c51764d0d73986f2aae64fbaf4c0beeb9c1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/animation/AnimBlendHierarchy.cpp | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp index feeaca3d..7388352f 100644 --- a/src/animation/AnimBlendHierarchy.cpp +++ b/src/animation/AnimBlendHierarchy.cpp @@ -2,6 +2,9 @@ #include "AnimBlendSequence.h" #include "AnimBlendHierarchy.h" +#include "AnimManager.h" + +//--MIAMI: file done CAnimBlendHierarchy::CAnimBlendHierarchy(void) { @@ -15,9 +18,10 @@ CAnimBlendHierarchy::CAnimBlendHierarchy(void) void CAnimBlendHierarchy::Shutdown(void) { + CAnimManager::RemoveFromUncompressedCache(this); RemoveAnimSequences(); + totalLength = 0.0f; compressed = 0; - linkPtr = nil; } void @@ -30,15 +34,44 @@ void CAnimBlendHierarchy::CalcTotalTime(void) { int i, j; - float totalTime = 0.0f; + + totalLength = 0.0f; for(i = 0; i < numSequences; i++){ - float seqTime = 0.0f; - for(j = 0; j < sequences[i].numFrames; j++) - seqTime += sequences[i].GetKeyFrame(j)->deltaTime; - totalTime = Max(totalTime, seqTime); +#ifdef FIX_BUGS + if(sequences[i].numFrames == 0) + continue; +#endif + + totalLength = Max(totalLength, sequences[i].GetKeyFrame(sequences[i].numFrames-1)->deltaTime); + for(j = sequences[i].numFrames-1; j > 0; j--){ + KeyFrame *kf1 = sequences[i].GetKeyFrame(j); + KeyFrame *kf2 = sequences[i].GetKeyFrame(j-1); + kf1->deltaTime -= kf2->deltaTime; + } + } +} + +void +CAnimBlendHierarchy::CalcTotalTimeCompressed(void) +{ + int i, j; + + totalLength = 0.0f; + + for(i = 0; i < numSequences; i++){ +#ifdef FIX_BUGS + if(sequences[i].numFrames == 0) + continue; +#endif + + totalLength = Max(totalLength, sequences[i].GetKeyFrameCompressed(sequences[i].numFrames-1)->deltaTime/60.0f); + for(j = sequences[i].numFrames-1; j > 0; j--){ + KeyFrame *kf1 = sequences[i].GetKeyFrameCompressed(j); + KeyFrame *kf2 = sequences[i].GetKeyFrameCompressed(j-1); + kf1->deltaTime -= kf2->deltaTime; + } } - totalLength = totalTime; } void @@ -53,17 +86,19 @@ CAnimBlendHierarchy::RemoveQuaternionFlips(void) void CAnimBlendHierarchy::RemoveAnimSequences(void) { - if(sequences) - delete[] sequences; + delete[] sequences; + sequences = nil; numSequences = 0; } void CAnimBlendHierarchy::Uncompress(void) { - if(totalLength == 0.0f) - CalcTotalTime(); compressed = 0; + if(totalLength == 0.0f){ + RemoveQuaternionFlips(); + CalcTotalTime(); + } } void |