diff options
Diffstat (limited to 'src/animation/AnimBlendHierarchy.cpp')
-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 |