diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-09-23 01:53:11 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-09-23 01:53:11 +0000 |
commit | afe61eb994377e25d60d0a0893510a693149c6be (patch) | |
tree | 80c6e33cd664e5c8b1c5f55c3b7b49c081dd590a /indra/llcharacter | |
parent | 2945882258ad1befe8e8094c0a1a655e4ddbcd30 (diff) |
QAR-849 merge maint-viewer-10-merge 96838-97237 -> release
Diffstat (limited to 'indra/llcharacter')
-rw-r--r-- | indra/llcharacter/llbvhloader.cpp | 45 | ||||
-rw-r--r-- | indra/llcharacter/llmotioncontroller.cpp | 5 |
2 files changed, 41 insertions, 9 deletions
diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp index 54b3ec98eb..b34328ce25 100644 --- a/indra/llcharacter/llbvhloader.cpp +++ b/indra/llcharacter/llbvhloader.cpp @@ -1133,6 +1133,8 @@ void LLBVHLoader::optimize() F32 rot_threshold = ROTATION_KEYFRAME_THRESHOLD / llmax((F32)joint->mChildTreeMaxDepth * 0.33f, 1.f); + double diff_max = 0; + KeyVector::iterator ki_max = ki; for (; ki != joint->mKeys.end(); ++ki) { if (ki_prev == ki_last_good_pos) @@ -1193,30 +1195,55 @@ void LLBVHLoader::optimize() F32 x_delta; F32 y_delta; F32 rot_test; - + + // Test if the rotation has changed significantly since the very first frame. If false + // for all frames, then we'll just throw out this joint's rotation entirely. x_delta = dist_vec(LLVector3::x_axis * first_frame_rot, LLVector3::x_axis * test_rot); y_delta = dist_vec(LLVector3::y_axis * first_frame_rot, LLVector3::y_axis * test_rot); rot_test = x_delta + y_delta; - if (rot_test > ROTATION_MOTION_THRESHOLD) { rot_changed = TRUE; } - x_delta = dist_vec(LLVector3::x_axis * interp_rot, LLVector3::x_axis * test_rot); y_delta = dist_vec(LLVector3::y_axis * interp_rot, LLVector3::y_axis * test_rot); rot_test = x_delta + y_delta; - if (rot_test < rot_threshold) - { - ki_prev->mIgnoreRot = TRUE; - numRotFramesConsidered++; - } - else + // Draw a line between the last good keyframe and current. Test the distance between the last frame (current-1, i.e. ki_prev) + // and the line. If it's greater than some threshold, then it represents a significant frame and we want to include it. + if (rot_test >= rot_threshold || + (ki+1 == joint->mKeys.end() && numRotFramesConsidered > 2)) { + // Add the current test keyframe (which is technically the previous key, i.e. ki_prev). numRotFramesConsidered = 2; ki_last_good_rot = ki_prev; joint->mNumRotKeys++; + + // Add another keyframe between the last good keyframe and current, at whatever point was the most "significant" (i.e. + // had the largest deviation from the earlier tests). Note that a more robust approach would be test all intermediate + // keyframes against the line between the last good keyframe and current, but we're settling for this other method + // because it's significantly faster. + if (diff_max > 0) + { + if (ki_max->mIgnoreRot == TRUE) + { + ki_max->mIgnoreRot = FALSE; + joint->mNumRotKeys++; + } + diff_max = 0; + } + } + else + { + // This keyframe isn't significant enough, throw it away. + ki_prev->mIgnoreRot = TRUE; + numRotFramesConsidered++; + // Store away the keyframe that has the largest deviation from the interpolated line, for insertion later. + if (rot_test > diff_max) + { + diff_max = rot_test; + ki_max = ki; + } } } diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index 3cb4da4e3a..051f2d625c 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -783,6 +783,11 @@ void LLMotionController::updateLoadingMotions() llinfos << "Motion " << motionp->getID() << " init failed." << llendl; sRegistry.markBad(motionp->getID()); mLoadingMotions.erase(curiter); + motion_set_t::iterator found_it = mDeprecatedMotions.find(motionp); + if (found_it != mDeprecatedMotions.end()) + { + mDeprecatedMotions.erase(found_it); + } mAllMotions.erase(motionp->getID()); delete motionp; } |