From b2afb8800bb033a04bb3ecdf0363068d56648ef1 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:54 -0500 Subject: Second Life viewer sources 1.15.0.2 --- linden/indra/llcharacter/llmotioncontroller.cpp | 122 +++++++++--------------- 1 file changed, 47 insertions(+), 75 deletions(-) (limited to 'linden/indra/llcharacter/llmotioncontroller.cpp') 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 @@ * * Copyright (c) 2001-2007, Linden Research, Inc. * + * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab * to you under the terms of the GNU General Public License, version 2.0 * ("GPL"), unless you have obtained a separate licensing agreement @@ -180,9 +181,9 @@ LLMotionController::~LLMotionController() //----------------------------------------------------------------------------- void LLMotionController::deleteAllMotions() { - mLoadingMotions.removeAllNodes(); + mLoadingMotions.clear(); mLoadedMotions.clear(); - mActiveMotions.removeAllNodes(); + mActiveMotions.clear(); for_each(mAllMotions.begin(), mAllMotions.end(), DeletePairedPointer()); mAllMotions.clear(); @@ -234,16 +235,16 @@ void LLMotionController::setTimeStep(F32 step) if (step != 0.f) { // make sure timestamps conform to new quantum - for( LLMotion* motionp = mActiveMotions.getFirstData(); - motionp != NULL; - motionp = mActiveMotions.getNextData() ) - { - motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step; - BOOL stopped = motionp->isStopped(); - motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step); - motionp->setStopped(stopped); - motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step; - } + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ++iter) + { + LLMotion* motionp = *iter; + motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step; + BOOL stopped = motionp->isStopped(); + motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step); + motionp->setStopped(stopped); + motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step; + } } } @@ -257,23 +258,6 @@ void LLMotionController::setTimeFactor(F32 time_factor) } //----------------------------------------------------------------------------- -// getFirstActiveMotion() -//----------------------------------------------------------------------------- -LLMotion* LLMotionController::getFirstActiveMotion() -{ - return mActiveMotions.getFirstData(); -} - -//----------------------------------------------------------------------------- -// getNextActiveMotion() -//----------------------------------------------------------------------------- -LLMotion* LLMotionController::getNextActiveMotion() -{ - return mActiveMotions.getNextData(); -} - - -//----------------------------------------------------------------------------- // setCharacter() //----------------------------------------------------------------------------- void LLMotionController::setCharacter(LLCharacter *character) @@ -300,17 +284,9 @@ void LLMotionController::removeMotion( const LLUUID& id) { stopMotionLocally(id, TRUE); - mLoadingMotions.deleteData(motionp); - std::deque::iterator motion_it; - for (motion_it = mLoadedMotions.begin(); motion_it != mLoadedMotions.end(); ++motion_it) - { - if(*motion_it == motionp) - { - mLoadedMotions.erase(motion_it); - break; - } - } - mActiveMotions.deleteData(motionp); + mLoadingMotions.erase(motionp); + mLoadedMotions.remove(motionp); + mActiveMotions.remove(motionp); mAllMotions.erase(id); delete motionp; } @@ -351,7 +327,7 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id ) delete motion; return NULL; case LLMotion::STATUS_HOLD: - mLoadingMotions.addData(motion); + mLoadingMotions.insert(motion); break; case LLMotion::STATUS_SUCCESS: // add motion to our list @@ -470,10 +446,11 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty memset(&last_joint_signature, 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); // iterate through active motions in chronological order - for(LLMotion* motionp = mActiveMotions.getFirstData(); - motionp != NULL; - motionp = mActiveMotions.getNextData()) + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ) { + motion_list_t::iterator curiter = iter++; + LLMotion* motionp = *curiter; if (motionp->getBlendType() != anim_type) { continue; @@ -487,9 +464,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty } else { - S32 i; // NUM_JOINT_SIGNATURE_STRIDES should be multiple of 4 - for (i = 0; i < NUM_JOINT_SIGNATURE_STRIDES; i++) + for (S32 i = 0; i < NUM_JOINT_SIGNATURE_STRIDES; i++) { U32 *current_signature = (U32*)&(mJointSignature[0][i * 4]); U32 test_signature = *(U32*)&(motionp->mJointSignature[0][i * 4]); @@ -745,16 +721,15 @@ void LLMotionController::updateMotion() } // query pending motions for completion - LLMotion* motionp; - - for ( motionp = mLoadingMotions.getFirstData(); - motionp != NULL; - motionp = mLoadingMotions.getNextData() ) + for (motion_set_t::iterator iter = mLoadingMotions.begin(); + iter != mLoadingMotions.end(); ) { + motion_set_t::iterator curiter = iter++; + LLMotion* motionp = *curiter; LLMotion::LLMotionInitStatus status = motionp->onInitialize(mCharacter); if (status == LLMotion::STATUS_SUCCESS) { - mLoadingMotions.removeCurrentData(); + mLoadingMotions.erase(curiter); // add motion to our loaded motion list addLoadedMotion(motionp); // this motion should be playing @@ -767,7 +742,7 @@ void LLMotionController::updateMotion() { llinfos << "Motion " << motionp->getID() << " init failed." << llendl; sRegistry.markBad(motionp->getID()); - mLoadingMotions.removeCurrentData(); + mLoadingMotions.erase(curiter); mAllMotions.erase(motionp->getID()); delete motionp; } @@ -804,7 +779,7 @@ void LLMotionController::updateMotion() //----------------------------------------------------------------------------- BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) { - if (mLoadingMotions.checkData(motion)) + if (mLoadingMotions.find(motion) != mLoadingMotions.end()) { // we want to start this motion, but we can't yet, so flag it as started motion->setStopped(FALSE); @@ -835,7 +810,8 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) motion->mSendStopTimestamp = F32_MAX; } - mActiveMotions.addData(motion); + mActiveMotions.remove(motion); // in case it is already in the active list + mActiveMotions.push_front(motion); motion->activate(); motion->onUpdate(0.f, mJointSignature[1]); @@ -849,7 +825,7 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) BOOL LLMotionController::deactivateMotion(LLMotion *motion) { motion->deactivate(); - mActiveMotions.removeData(motion); + mActiveMotions.remove(motion); return TRUE; } @@ -857,22 +833,17 @@ BOOL LLMotionController::deactivateMotion(LLMotion *motion) //----------------------------------------------------------------------------- // isMotionActive() //----------------------------------------------------------------------------- -BOOL LLMotionController::isMotionActive(LLMotion *motion) +bool LLMotionController::isMotionActive(LLMotion *motion) { - if (motion && motion->isActive()) - { - return TRUE; - } - - return FALSE; + return (motion && motion->isActive()); } //----------------------------------------------------------------------------- // isMotionLoading() //----------------------------------------------------------------------------- -BOOL LLMotionController::isMotionLoading(LLMotion* motion) +bool LLMotionController::isMotionLoading(LLMotion* motion) { - return mLoadingMotions.checkData(motion); + return (mLoadingMotions.find(motion) != mLoadingMotions.end()); } @@ -890,15 +861,15 @@ LLMotion *LLMotionController::findMotion(const LLUUID& id) //----------------------------------------------------------------------------- void LLMotionController::flushAllMotions() { - LLDynamicArray active_motions; - LLDynamicArray active_motion_times; - - for (LLMotion* motionp = mActiveMotions.getFirstData(); - motionp; - motionp = mActiveMotions.getNextData()) + std::vector > active_motions; + active_motions.reserve(mActiveMotions.size()); + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ) { - active_motions.put(motionp->getID()); - active_motion_times.put(mTime - motionp->mActivationTimestamp); + motion_list_t::iterator curiter = iter++; + LLMotion* motionp = *curiter; + F32 dtime = mTime - motionp->mActivationTimestamp; + active_motions.push_back(std::make_pair(motionp->getID(),dtime)); motionp->deactivate(); } @@ -910,9 +881,10 @@ void LLMotionController::flushAllMotions() mCharacter->removeAnimationData("Hand Pose"); // restart motions - for (S32 i = 0; i < active_motions.count(); i++) + for (std::vector >::iterator iter = active_motions.begin(); + iter != active_motions.end(); ++iter) { - startMotion(active_motions[i], active_motion_times[i]); + startMotion(iter->first, iter->second); } } -- cgit v1.1