diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llcharacter/llmotioncontroller.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llcharacter/llmotioncontroller.cpp')
-rw-r--r-- | linden/indra/llcharacter/llmotioncontroller.cpp | 122 |
1 files changed, 47 insertions, 75 deletions
diff --git a/linden/indra/llcharacter/llmotioncontroller.cpp b/linden/indra/llcharacter/llmotioncontroller.cpp index 3e1456b..5545841 100644 --- a/linden/indra/llcharacter/llmotioncontroller.cpp +++ b/linden/indra/llcharacter/llmotioncontroller.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 5 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -180,9 +181,9 @@ LLMotionController::~LLMotionController() | |||
180 | //----------------------------------------------------------------------------- | 181 | //----------------------------------------------------------------------------- |
181 | void LLMotionController::deleteAllMotions() | 182 | void LLMotionController::deleteAllMotions() |
182 | { | 183 | { |
183 | mLoadingMotions.removeAllNodes(); | 184 | mLoadingMotions.clear(); |
184 | mLoadedMotions.clear(); | 185 | mLoadedMotions.clear(); |
185 | mActiveMotions.removeAllNodes(); | 186 | mActiveMotions.clear(); |
186 | 187 | ||
187 | for_each(mAllMotions.begin(), mAllMotions.end(), DeletePairedPointer()); | 188 | for_each(mAllMotions.begin(), mAllMotions.end(), DeletePairedPointer()); |
188 | mAllMotions.clear(); | 189 | mAllMotions.clear(); |
@@ -234,16 +235,16 @@ void LLMotionController::setTimeStep(F32 step) | |||
234 | if (step != 0.f) | 235 | if (step != 0.f) |
235 | { | 236 | { |
236 | // make sure timestamps conform to new quantum | 237 | // make sure timestamps conform to new quantum |
237 | for( LLMotion* motionp = mActiveMotions.getFirstData(); | 238 | for (motion_list_t::iterator iter = mActiveMotions.begin(); |
238 | motionp != NULL; | 239 | iter != mActiveMotions.end(); ++iter) |
239 | motionp = mActiveMotions.getNextData() ) | 240 | { |
240 | { | 241 | LLMotion* motionp = *iter; |
241 | motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step; | 242 | motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step; |
242 | BOOL stopped = motionp->isStopped(); | 243 | BOOL stopped = motionp->isStopped(); |
243 | motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step); | 244 | motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step); |
244 | motionp->setStopped(stopped); | 245 | motionp->setStopped(stopped); |
245 | motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step; | 246 | motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step; |
246 | } | 247 | } |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
@@ -257,23 +258,6 @@ void LLMotionController::setTimeFactor(F32 time_factor) | |||
257 | } | 258 | } |
258 | 259 | ||
259 | //----------------------------------------------------------------------------- | 260 | //----------------------------------------------------------------------------- |
260 | // getFirstActiveMotion() | ||
261 | //----------------------------------------------------------------------------- | ||
262 | LLMotion* LLMotionController::getFirstActiveMotion() | ||
263 | { | ||
264 | return mActiveMotions.getFirstData(); | ||
265 | } | ||
266 | |||
267 | //----------------------------------------------------------------------------- | ||
268 | // getNextActiveMotion() | ||
269 | //----------------------------------------------------------------------------- | ||
270 | LLMotion* LLMotionController::getNextActiveMotion() | ||
271 | { | ||
272 | return mActiveMotions.getNextData(); | ||
273 | } | ||
274 | |||
275 | |||
276 | //----------------------------------------------------------------------------- | ||
277 | // setCharacter() | 261 | // setCharacter() |
278 | //----------------------------------------------------------------------------- | 262 | //----------------------------------------------------------------------------- |
279 | void LLMotionController::setCharacter(LLCharacter *character) | 263 | void LLMotionController::setCharacter(LLCharacter *character) |
@@ -300,17 +284,9 @@ void LLMotionController::removeMotion( const LLUUID& id) | |||
300 | { | 284 | { |
301 | stopMotionLocally(id, TRUE); | 285 | stopMotionLocally(id, TRUE); |
302 | 286 | ||
303 | mLoadingMotions.deleteData(motionp); | 287 | mLoadingMotions.erase(motionp); |
304 | std::deque<LLMotion*>::iterator motion_it; | 288 | mLoadedMotions.remove(motionp); |
305 | for (motion_it = mLoadedMotions.begin(); motion_it != mLoadedMotions.end(); ++motion_it) | 289 | mActiveMotions.remove(motionp); |
306 | { | ||
307 | if(*motion_it == motionp) | ||
308 | { | ||
309 | mLoadedMotions.erase(motion_it); | ||
310 | break; | ||
311 | } | ||
312 | } | ||
313 | mActiveMotions.deleteData(motionp); | ||
314 | mAllMotions.erase(id); | 290 | mAllMotions.erase(id); |
315 | delete motionp; | 291 | delete motionp; |
316 | } | 292 | } |
@@ -351,7 +327,7 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id ) | |||
351 | delete motion; | 327 | delete motion; |
352 | return NULL; | 328 | return NULL; |
353 | case LLMotion::STATUS_HOLD: | 329 | case LLMotion::STATUS_HOLD: |
354 | mLoadingMotions.addData(motion); | 330 | mLoadingMotions.insert(motion); |
355 | break; | 331 | break; |
356 | case LLMotion::STATUS_SUCCESS: | 332 | case LLMotion::STATUS_SUCCESS: |
357 | // add motion to our list | 333 | // add motion to our list |
@@ -470,10 +446,11 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
470 | memset(&last_joint_signature, 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); | 446 | memset(&last_joint_signature, 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); |
471 | 447 | ||
472 | // iterate through active motions in chronological order | 448 | // iterate through active motions in chronological order |
473 | for(LLMotion* motionp = mActiveMotions.getFirstData(); | 449 | for (motion_list_t::iterator iter = mActiveMotions.begin(); |
474 | motionp != NULL; | 450 | iter != mActiveMotions.end(); ) |
475 | motionp = mActiveMotions.getNextData()) | ||
476 | { | 451 | { |
452 | motion_list_t::iterator curiter = iter++; | ||
453 | LLMotion* motionp = *curiter; | ||
477 | if (motionp->getBlendType() != anim_type) | 454 | if (motionp->getBlendType() != anim_type) |
478 | { | 455 | { |
479 | continue; | 456 | continue; |
@@ -487,9 +464,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
487 | } | 464 | } |
488 | else | 465 | else |
489 | { | 466 | { |
490 | S32 i; | ||
491 | // NUM_JOINT_SIGNATURE_STRIDES should be multiple of 4 | 467 | // NUM_JOINT_SIGNATURE_STRIDES should be multiple of 4 |
492 | for (i = 0; i < NUM_JOINT_SIGNATURE_STRIDES; i++) | 468 | for (S32 i = 0; i < NUM_JOINT_SIGNATURE_STRIDES; i++) |
493 | { | 469 | { |
494 | U32 *current_signature = (U32*)&(mJointSignature[0][i * 4]); | 470 | U32 *current_signature = (U32*)&(mJointSignature[0][i * 4]); |
495 | U32 test_signature = *(U32*)&(motionp->mJointSignature[0][i * 4]); | 471 | U32 test_signature = *(U32*)&(motionp->mJointSignature[0][i * 4]); |
@@ -745,16 +721,15 @@ void LLMotionController::updateMotion() | |||
745 | } | 721 | } |
746 | 722 | ||
747 | // query pending motions for completion | 723 | // query pending motions for completion |
748 | LLMotion* motionp; | 724 | for (motion_set_t::iterator iter = mLoadingMotions.begin(); |
749 | 725 | iter != mLoadingMotions.end(); ) | |
750 | for ( motionp = mLoadingMotions.getFirstData(); | ||
751 | motionp != NULL; | ||
752 | motionp = mLoadingMotions.getNextData() ) | ||
753 | { | 726 | { |
727 | motion_set_t::iterator curiter = iter++; | ||
728 | LLMotion* motionp = *curiter; | ||
754 | LLMotion::LLMotionInitStatus status = motionp->onInitialize(mCharacter); | 729 | LLMotion::LLMotionInitStatus status = motionp->onInitialize(mCharacter); |
755 | if (status == LLMotion::STATUS_SUCCESS) | 730 | if (status == LLMotion::STATUS_SUCCESS) |
756 | { | 731 | { |
757 | mLoadingMotions.removeCurrentData(); | 732 | mLoadingMotions.erase(curiter); |
758 | // add motion to our loaded motion list | 733 | // add motion to our loaded motion list |
759 | addLoadedMotion(motionp); | 734 | addLoadedMotion(motionp); |
760 | // this motion should be playing | 735 | // this motion should be playing |
@@ -767,7 +742,7 @@ void LLMotionController::updateMotion() | |||
767 | { | 742 | { |
768 | llinfos << "Motion " << motionp->getID() << " init failed." << llendl; | 743 | llinfos << "Motion " << motionp->getID() << " init failed." << llendl; |
769 | sRegistry.markBad(motionp->getID()); | 744 | sRegistry.markBad(motionp->getID()); |
770 | mLoadingMotions.removeCurrentData(); | 745 | mLoadingMotions.erase(curiter); |
771 | mAllMotions.erase(motionp->getID()); | 746 | mAllMotions.erase(motionp->getID()); |
772 | delete motionp; | 747 | delete motionp; |
773 | } | 748 | } |
@@ -804,7 +779,7 @@ void LLMotionController::updateMotion() | |||
804 | //----------------------------------------------------------------------------- | 779 | //----------------------------------------------------------------------------- |
805 | BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) | 780 | BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) |
806 | { | 781 | { |
807 | if (mLoadingMotions.checkData(motion)) | 782 | if (mLoadingMotions.find(motion) != mLoadingMotions.end()) |
808 | { | 783 | { |
809 | // we want to start this motion, but we can't yet, so flag it as started | 784 | // we want to start this motion, but we can't yet, so flag it as started |
810 | motion->setStopped(FALSE); | 785 | motion->setStopped(FALSE); |
@@ -835,7 +810,8 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) | |||
835 | motion->mSendStopTimestamp = F32_MAX; | 810 | motion->mSendStopTimestamp = F32_MAX; |
836 | } | 811 | } |
837 | 812 | ||
838 | mActiveMotions.addData(motion); | 813 | mActiveMotions.remove(motion); // in case it is already in the active list |
814 | mActiveMotions.push_front(motion); | ||
839 | 815 | ||
840 | motion->activate(); | 816 | motion->activate(); |
841 | motion->onUpdate(0.f, mJointSignature[1]); | 817 | motion->onUpdate(0.f, mJointSignature[1]); |
@@ -849,7 +825,7 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) | |||
849 | BOOL LLMotionController::deactivateMotion(LLMotion *motion) | 825 | BOOL LLMotionController::deactivateMotion(LLMotion *motion) |
850 | { | 826 | { |
851 | motion->deactivate(); | 827 | motion->deactivate(); |
852 | mActiveMotions.removeData(motion); | 828 | mActiveMotions.remove(motion); |
853 | 829 | ||
854 | return TRUE; | 830 | return TRUE; |
855 | } | 831 | } |
@@ -857,22 +833,17 @@ BOOL LLMotionController::deactivateMotion(LLMotion *motion) | |||
857 | //----------------------------------------------------------------------------- | 833 | //----------------------------------------------------------------------------- |
858 | // isMotionActive() | 834 | // isMotionActive() |
859 | //----------------------------------------------------------------------------- | 835 | //----------------------------------------------------------------------------- |
860 | BOOL LLMotionController::isMotionActive(LLMotion *motion) | 836 | bool LLMotionController::isMotionActive(LLMotion *motion) |
861 | { | 837 | { |
862 | if (motion && motion->isActive()) | 838 | return (motion && motion->isActive()); |
863 | { | ||
864 | return TRUE; | ||
865 | } | ||
866 | |||
867 | return FALSE; | ||
868 | } | 839 | } |
869 | 840 | ||
870 | //----------------------------------------------------------------------------- | 841 | //----------------------------------------------------------------------------- |
871 | // isMotionLoading() | 842 | // isMotionLoading() |
872 | //----------------------------------------------------------------------------- | 843 | //----------------------------------------------------------------------------- |
873 | BOOL LLMotionController::isMotionLoading(LLMotion* motion) | 844 | bool LLMotionController::isMotionLoading(LLMotion* motion) |
874 | { | 845 | { |
875 | return mLoadingMotions.checkData(motion); | 846 | return (mLoadingMotions.find(motion) != mLoadingMotions.end()); |
876 | } | 847 | } |
877 | 848 | ||
878 | 849 | ||
@@ -890,15 +861,15 @@ LLMotion *LLMotionController::findMotion(const LLUUID& id) | |||
890 | //----------------------------------------------------------------------------- | 861 | //----------------------------------------------------------------------------- |
891 | void LLMotionController::flushAllMotions() | 862 | void LLMotionController::flushAllMotions() |
892 | { | 863 | { |
893 | LLDynamicArray<LLUUID> active_motions; | 864 | std::vector<std::pair<LLUUID,F32> > active_motions; |
894 | LLDynamicArray<F32> active_motion_times; | 865 | active_motions.reserve(mActiveMotions.size()); |
895 | 866 | for (motion_list_t::iterator iter = mActiveMotions.begin(); | |
896 | for (LLMotion* motionp = mActiveMotions.getFirstData(); | 867 | iter != mActiveMotions.end(); ) |
897 | motionp; | ||
898 | motionp = mActiveMotions.getNextData()) | ||
899 | { | 868 | { |
900 | active_motions.put(motionp->getID()); | 869 | motion_list_t::iterator curiter = iter++; |
901 | active_motion_times.put(mTime - motionp->mActivationTimestamp); | 870 | LLMotion* motionp = *curiter; |
871 | F32 dtime = mTime - motionp->mActivationTimestamp; | ||
872 | active_motions.push_back(std::make_pair(motionp->getID(),dtime)); | ||
902 | motionp->deactivate(); | 873 | motionp->deactivate(); |
903 | } | 874 | } |
904 | 875 | ||
@@ -910,9 +881,10 @@ void LLMotionController::flushAllMotions() | |||
910 | mCharacter->removeAnimationData("Hand Pose"); | 881 | mCharacter->removeAnimationData("Hand Pose"); |
911 | 882 | ||
912 | // restart motions | 883 | // restart motions |
913 | for (S32 i = 0; i < active_motions.count(); i++) | 884 | for (std::vector<std::pair<LLUUID,F32> >::iterator iter = active_motions.begin(); |
885 | iter != active_motions.end(); ++iter) | ||
914 | { | 886 | { |
915 | startMotion(active_motions[i], active_motion_times[i]); | 887 | startMotion(iter->first, iter->second); |
916 | } | 888 | } |
917 | } | 889 | } |
918 | 890 | ||