aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcharacter
diff options
context:
space:
mode:
authorJacek Antonelli2008-12-01 17:39:58 -0600
committerJacek Antonelli2008-12-01 17:40:06 -0600
commit7abecb48babe6a6f09bf6692ba55076546cfced9 (patch)
tree8d18a88513fb97adf32c10aae78f4be1984942db /linden/indra/llcharacter
parentSecond Life viewer sources 1.21.6 (diff)
downloadmeta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.zip
meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.gz
meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.bz2
meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.xz
Second Life viewer sources 1.22.0-RC
Diffstat (limited to 'linden/indra/llcharacter')
-rw-r--r--linden/indra/llcharacter/llbvhloader.cpp45
-rw-r--r--linden/indra/llcharacter/lleditingmotion.cpp4
-rw-r--r--linden/indra/llcharacter/llmotioncontroller.cpp5
3 files changed, 43 insertions, 11 deletions
diff --git a/linden/indra/llcharacter/llbvhloader.cpp b/linden/indra/llcharacter/llbvhloader.cpp
index cd1f492..938f47d 100644
--- a/linden/indra/llcharacter/llbvhloader.cpp
+++ b/linden/indra/llcharacter/llbvhloader.cpp
@@ -1133,6 +1133,8 @@ void LLBVHLoader::optimize()
1133 1133
1134 F32 rot_threshold = ROTATION_KEYFRAME_THRESHOLD / llmax((F32)joint->mChildTreeMaxDepth * 0.33f, 1.f); 1134 F32 rot_threshold = ROTATION_KEYFRAME_THRESHOLD / llmax((F32)joint->mChildTreeMaxDepth * 0.33f, 1.f);
1135 1135
1136 double diff_max = 0;
1137 KeyVector::iterator ki_max = ki;
1136 for (; ki != joint->mKeys.end(); ++ki) 1138 for (; ki != joint->mKeys.end(); ++ki)
1137 { 1139 {
1138 if (ki_prev == ki_last_good_pos) 1140 if (ki_prev == ki_last_good_pos)
@@ -1193,30 +1195,55 @@ void LLBVHLoader::optimize()
1193 F32 x_delta; 1195 F32 x_delta;
1194 F32 y_delta; 1196 F32 y_delta;
1195 F32 rot_test; 1197 F32 rot_test;
1196 1198
1199 // Test if the rotation has changed significantly since the very first frame. If false
1200 // for all frames, then we'll just throw out this joint's rotation entirely.
1197 x_delta = dist_vec(LLVector3::x_axis * first_frame_rot, LLVector3::x_axis * test_rot); 1201 x_delta = dist_vec(LLVector3::x_axis * first_frame_rot, LLVector3::x_axis * test_rot);
1198 y_delta = dist_vec(LLVector3::y_axis * first_frame_rot, LLVector3::y_axis * test_rot); 1202 y_delta = dist_vec(LLVector3::y_axis * first_frame_rot, LLVector3::y_axis * test_rot);
1199 rot_test = x_delta + y_delta; 1203 rot_test = x_delta + y_delta;
1200
1201 if (rot_test > ROTATION_MOTION_THRESHOLD) 1204 if (rot_test > ROTATION_MOTION_THRESHOLD)
1202 { 1205 {
1203 rot_changed = TRUE; 1206 rot_changed = TRUE;
1204 } 1207 }
1205
1206 x_delta = dist_vec(LLVector3::x_axis * interp_rot, LLVector3::x_axis * test_rot); 1208 x_delta = dist_vec(LLVector3::x_axis * interp_rot, LLVector3::x_axis * test_rot);
1207 y_delta = dist_vec(LLVector3::y_axis * interp_rot, LLVector3::y_axis * test_rot); 1209 y_delta = dist_vec(LLVector3::y_axis * interp_rot, LLVector3::y_axis * test_rot);
1208 rot_test = x_delta + y_delta; 1210 rot_test = x_delta + y_delta;
1209 1211
1210 if (rot_test < rot_threshold) 1212 // Draw a line between the last good keyframe and current. Test the distance between the last frame (current-1, i.e. ki_prev)
1211 { 1213 // and the line. If it's greater than some threshold, then it represents a significant frame and we want to include it.
1212 ki_prev->mIgnoreRot = TRUE; 1214 if (rot_test >= rot_threshold ||
1213 numRotFramesConsidered++; 1215 (ki+1 == joint->mKeys.end() && numRotFramesConsidered > 2))
1214 }
1215 else
1216 { 1216 {
1217 // Add the current test keyframe (which is technically the previous key, i.e. ki_prev).
1217 numRotFramesConsidered = 2; 1218 numRotFramesConsidered = 2;
1218 ki_last_good_rot = ki_prev; 1219 ki_last_good_rot = ki_prev;
1219 joint->mNumRotKeys++; 1220 joint->mNumRotKeys++;
1221
1222 // Add another keyframe between the last good keyframe and current, at whatever point was the most "significant" (i.e.
1223 // had the largest deviation from the earlier tests). Note that a more robust approach would be test all intermediate
1224 // keyframes against the line between the last good keyframe and current, but we're settling for this other method
1225 // because it's significantly faster.
1226 if (diff_max > 0)
1227 {
1228 if (ki_max->mIgnoreRot == TRUE)
1229 {
1230 ki_max->mIgnoreRot = FALSE;
1231 joint->mNumRotKeys++;
1232 }
1233 diff_max = 0;
1234 }
1235 }
1236 else
1237 {
1238 // This keyframe isn't significant enough, throw it away.
1239 ki_prev->mIgnoreRot = TRUE;
1240 numRotFramesConsidered++;
1241 // Store away the keyframe that has the largest deviation from the interpolated line, for insertion later.
1242 if (rot_test > diff_max)
1243 {
1244 diff_max = rot_test;
1245 ki_max = ki;
1246 }
1220 } 1247 }
1221 } 1248 }
1222 1249
diff --git a/linden/indra/llcharacter/lleditingmotion.cpp b/linden/indra/llcharacter/lleditingmotion.cpp
index b7539ee..3590097 100644
--- a/linden/indra/llcharacter/lleditingmotion.cpp
+++ b/linden/indra/llcharacter/lleditingmotion.cpp
@@ -190,7 +190,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
190 { 190 {
191 LLVector3 tmp = mCharacter->getCharacterPosition() ; 191 LLVector3 tmp = mCharacter->getCharacterPosition() ;
192 llerrs << "Non finite focus point in editing motion. focus point: " << focus_pt << " and character position: " << 192 llerrs << "Non finite focus point in editing motion. focus point: " << focus_pt << " and character position: " <<
193 tmp << " and pointAtPt: " << pointAtPt << llendl; 193 tmp << " and pointAtPt: " << *pointAtPt << llendl;
194 } 194 }
195 195
196 // propagate joint positions to kinematic chain 196 // propagate joint positions to kinematic chain
@@ -226,7 +226,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
226 if (!target.isFinite()) 226 if (!target.isFinite())
227 { 227 {
228 llerrs << "Non finite target in editing motion with target distance of " << target_dist << 228 llerrs << "Non finite target in editing motion with target distance of " << target_dist <<
229 " and focus point " << focus_pt << " and pointAtPt: " << pointAtPt << llendl; 229 " and focus point " << focus_pt << " and pointAtPt: " << *pointAtPt << llendl;
230 } 230 }
231 231
232 mTarget.setPosition( target + mParentJoint.getPosition()); 232 mTarget.setPosition( target + mParentJoint.getPosition());
diff --git a/linden/indra/llcharacter/llmotioncontroller.cpp b/linden/indra/llcharacter/llmotioncontroller.cpp
index 90a3d74..fadf1a5 100644
--- a/linden/indra/llcharacter/llmotioncontroller.cpp
+++ b/linden/indra/llcharacter/llmotioncontroller.cpp
@@ -783,6 +783,11 @@ void LLMotionController::updateLoadingMotions()
783 llinfos << "Motion " << motionp->getID() << " init failed." << llendl; 783 llinfos << "Motion " << motionp->getID() << " init failed." << llendl;
784 sRegistry.markBad(motionp->getID()); 784 sRegistry.markBad(motionp->getID());
785 mLoadingMotions.erase(curiter); 785 mLoadingMotions.erase(curiter);
786 motion_set_t::iterator found_it = mDeprecatedMotions.find(motionp);
787 if (found_it != mDeprecatedMotions.end())
788 {
789 mDeprecatedMotions.erase(found_it);
790 }
786 mAllMotions.erase(motionp->getID()); 791 mAllMotions.erase(motionp->getID());
787 delete motionp; 792 delete motionp;
788 } 793 }