diff options
Diffstat (limited to 'indra/llcharacter')
-rw-r--r-- | indra/llcharacter/llcharacter.h | 2 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotion.cpp | 126 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotion.h | 15 | ||||
-rw-r--r-- | indra/llcharacter/llmotioncontroller.cpp | 118 | ||||
-rw-r--r-- | indra/llcharacter/llmotioncontroller.h | 18 | ||||
-rw-r--r-- | indra/llcharacter/llpose.cpp | 44 | ||||
-rw-r--r-- | indra/llcharacter/llpose.h | 6 |
7 files changed, 169 insertions, 160 deletions
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index 0ed22f81f7..44fb6d0833 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -108,7 +108,7 @@ public: // updates all visual parameters for this character virtual void updateVisualParams(); - virtual void addDebugText( const char* text ) = 0; + virtual void addDebugText( const std::string& text ) = 0; virtual const LLUUID& getID() = 0; //------------------------------------------------------------------------- diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 0aeefb1a21..7c8a7160e7 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -29,7 +29,7 @@ // Static Definitions //----------------------------------------------------------------------------- LLVFS* LLKeyframeMotion::sVFS = NULL; -LLKeyframeDataCache::LLKeyframeDataMap LLKeyframeDataCache::sKeyframeDataMap; +LLKeyframeDataCache::keyframe_data_map_t LLKeyframeDataCache::sKeyframeDataMap; //----------------------------------------------------------------------------- // Globals @@ -45,8 +45,20 @@ static F32 MIN_ACCELERATION_SQUARED = 0.0005f * 0.0005f; static F32 MAX_CONSTRAINTS = 10; //----------------------------------------------------------------------------- -// JointMotionList::dumpDiagInfo() +// JointMotionList //----------------------------------------------------------------------------- +LLKeyframeMotion::JointMotionList::JointMotionList() + : mNumJointMotions(0), + mJointMotionArray(NULL) +{ +} + +LLKeyframeMotion::JointMotionList::~JointMotionList() +{ + for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); + delete [] mJointMotionArray; +} + U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() { S32 total_size = sizeof(JointMotionList); @@ -415,7 +427,7 @@ LLKeyframeMotion::~LLKeyframeMotion() { delete [] mJointStates; } - mConstraints.deleteAllData(); + for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); } //----------------------------------------------------------------------------- @@ -550,8 +562,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact BOOL LLKeyframeMotion::setupPose() { // add all valid joint states to the pose - U32 jm; - for (jm=0; jm<mJointMotionList->mNumJointMotions; jm++) + for (U32 jm=0; jm<mJointMotionList->mNumJointMotions; jm++) { if ( mJointStates[jm].getJoint() ) { @@ -560,16 +571,16 @@ BOOL LLKeyframeMotion::setupPose() } // initialize joint constraints - for (JointConstraintSharedData* shared_constraintp = mJointMotionList->mConstraints.getFirstData(); - shared_constraintp; - shared_constraintp = mJointMotionList->mConstraints.getNextData()) - { - JointConstraint* constraintp = new JointConstraint(shared_constraintp); - initializeConstraint(constraintp); - mConstraints.addData(constraintp); - } + for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin(); + iter != mJointMotionList->mConstraints.end(); ++iter) + { + JointConstraintSharedData* shared_constraintp = *iter; + JointConstraint* constraintp = new JointConstraint(shared_constraintp); + initializeConstraint(constraintp); + mConstraints.push_front(constraintp); + } - if (mJointMotionList->mConstraints.getLength()) + if (mJointMotionList->mConstraints.size()) { mPelvisp = mCharacter->getJoint("mPelvis"); if (!mPelvisp) @@ -692,21 +703,21 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask) if (mCharacter->getSkeletonSerialNum() != mLastSkeletonSerialNum) { mLastSkeletonSerialNum = mCharacter->getSkeletonSerialNum(); - for (JointConstraint* constraintp = mConstraints.getFirstData(); - constraintp; - constraintp = mConstraints.getNextData()) - { - initializeConstraint(constraintp); - } + for (constraint_list_t::iterator iter = mConstraints.begin(); + iter != mConstraints.end(); ++iter) + { + JointConstraint* constraintp = *iter; + initializeConstraint(constraintp); + } } // apply constraints - for (JointConstraint* constraintp = mConstraints.getFirstData(); - constraintp; - constraintp = mConstraints.getNextData()) - { - applyConstraint(constraintp, time, joint_mask); - } + for (constraint_list_t::iterator iter = mConstraints.begin(); + iter != mConstraints.end(); ++iter) + { + JointConstraint* constraintp = *iter; + applyConstraint(constraintp, time, joint_mask); + } } //----------------------------------------------------------------------------- @@ -714,12 +725,12 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLKeyframeMotion::onDeactivate() { - for (JointConstraint* constraintp = mConstraints.getFirstData(); - constraintp; - constraintp = mConstraints.getNextData()) - { - deactivateConstraint(constraintp); - } + for (constraint_list_t::iterator iter = mConstraints.begin(); + iter != mConstraints.end(); ++iter) + { + JointConstraint* constraintp = *iter; + deactivateConstraint(constraintp); + } } //----------------------------------------------------------------------------- @@ -1586,7 +1597,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - mJointMotionList->mConstraints.addData(constraintp); + mJointMotionList->mConstraints.push_front(constraintp); constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; @@ -1694,10 +1705,19 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const } } - success &= dp.packS32(mJointMotionList->mConstraints.getLength(), "num_constraints"); - for (JointConstraintSharedData* shared_constraintp = mJointMotionList->mConstraints.getFirstData(); - shared_constraintp; - shared_constraintp = mJointMotionList->mConstraints.getNextData()) + success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints"); + for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin(); + iter != mJointMotionList->mConstraints.end(); ++iter) + { + JointConstraintSharedData* shared_constraintp = *iter; + success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); + success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); + char volume_name[16]; /* Flawfinder: ignore */ + snprintf(volume_name, sizeof(volume_name), "%s", /* Flawfinder: ignore */ + mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str()); + success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "source_volume"); + success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset"); + if (shared_constraintp->mConstraintTargetType == TYPE_GROUND) { success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); @@ -1708,7 +1728,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset"); if (shared_constraintp->mConstraintTargetType == TYPE_GROUND) { - snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */ + snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */ } else { @@ -1723,6 +1743,19 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); } + else + { + snprintf(volume_name, sizeof(volume_name),"%s", /* Flawfinder: ignore */ + mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str()); + } + success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "target_volume"); + success &= dp.packVector3(shared_constraintp->mTargetConstraintOffset, "target_offset"); + success &= dp.packVector3(shared_constraintp->mTargetConstraintDir, "target_dir"); + success &= dp.packF32(shared_constraintp->mEaseInStartTime, "ease_in_start"); + success &= dp.packF32(shared_constraintp->mEaseInStopTime, "ease_in_stop"); + success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); + success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); + } return success; } @@ -1813,7 +1846,8 @@ void LLKeyframeMotion::setEaseOut(F32 ease_in) //----------------------------------------------------------------------------- void LLKeyframeMotion::flushKeyframeCache() { - LLKeyframeDataCache::clear(); + // TODO: Make this safe to do +// LLKeyframeDataCache::clear(); } //----------------------------------------------------------------------------- @@ -2022,8 +2056,8 @@ void LLKeyframeDataCache::dumpDiagInfo() llinfos << "-----------------------------------------------------" << llendl; // print each loaded mesh, and it's memory usage - LLKeyframeDataMap::iterator map_it; - for (map_it = sKeyframeDataMap.begin(); map_it != sKeyframeDataMap.end(); ++map_it) + for (keyframe_data_map_t::iterator map_it = sKeyframeDataMap.begin(); + map_it != sKeyframeDataMap.end(); ++map_it) { U32 joint_motion_kb; @@ -2057,12 +2091,12 @@ void LLKeyframeDataCache::addKeyframeData(const LLUUID& id, LLKeyframeMotion::Jo //-------------------------------------------------------------------- void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) { - LLKeyframeMotion::JointMotionList* joint_motion_listp = getKeyframeData(id); - if (joint_motion_listp) + keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id); + if (found_data != sKeyframeDataMap.end()) { - delete joint_motion_listp; + delete found_data->second; + sKeyframeDataMap.erase(found_data); } - sKeyframeDataMap.erase(id); } //-------------------------------------------------------------------- @@ -2070,7 +2104,7 @@ void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) //-------------------------------------------------------------------- LLKeyframeMotion::JointMotionList* LLKeyframeDataCache::getKeyframeData(const LLUUID& id) { - LLKeyframeDataMap::iterator found_data = sKeyframeDataMap.find(id); + keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id); if (found_data == sKeyframeDataMap.end()) { return NULL; diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index daa501af89..9b8c04ac92 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -16,7 +16,6 @@ #include <string> #include "llassetstorage.h" -#include "llassoclist.h" #include "llbboxlocal.h" #include "llhandmotion.h" #include "lljointstate.h" @@ -386,11 +385,12 @@ public: LLJoint::JointPriority mBasePriority; LLHandMotion::eHandPose mHandPose; LLJoint::JointPriority mMaxPriority; - LLLinkedList<JointConstraintSharedData> mConstraints; + typedef std::list<JointConstraintSharedData*> constraint_list_t; + constraint_list_t mConstraints; LLBBoxLocal mPelvisBBox; public: - JointMotionList() : mNumJointMotions(0), mJointMotionArray(NULL) {}; - ~JointMotionList() { mConstraints.deleteAllData(); delete [] mJointMotionArray; } + JointMotionList(); + ~JointMotionList(); U32 dumpDiagInfo(); }; @@ -406,7 +406,8 @@ protected: LLJoint* mPelvisp; LLCharacter* mCharacter; std::string mEmoteName; - LLLinkedList<JointConstraint> mConstraints; + typedef std::list<JointConstraint*> constraint_list_t; + constraint_list_t mConstraints; U32 mLastSkeletonSerialNum; F32 mLastUpdateTime; F32 mLastLoopedTime; @@ -420,8 +421,8 @@ public: LLKeyframeDataCache(){}; ~LLKeyframeDataCache(); - typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> LLKeyframeDataMap; - static LLKeyframeDataMap sKeyframeDataMap; + typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; + static keyframe_data_map_t sKeyframeDataMap; static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*); static LLKeyframeMotion::JointMotionList* getKeyframeData(const LLUUID& id); diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index 2856803c4b..c0b072c357 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -161,9 +161,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(); @@ -215,16 +215,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; + } } } @@ -238,23 +238,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) @@ -281,17 +264,9 @@ void LLMotionController::removeMotion( const LLUUID& id) { stopMotionLocally(id, TRUE); - mLoadingMotions.deleteData(motionp); - std::deque<LLMotion*>::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; } @@ -332,7 +307,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 @@ -451,10 +426,10 @@ 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(); ++iter) { + LLMotion* motionp = *iter; if (motionp->getBlendType() != anim_type) { continue; @@ -468,9 +443,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]); @@ -726,16 +700,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 @@ -748,7 +721,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; } @@ -785,7 +758,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); @@ -816,7 +789,7 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) motion->mSendStopTimestamp = F32_MAX; } - mActiveMotions.addData(motion); + mActiveMotions.push_front(motion); motion->activate(); motion->onUpdate(0.f, mJointSignature[1]); @@ -830,7 +803,7 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) BOOL LLMotionController::deactivateMotion(LLMotion *motion) { motion->deactivate(); - mActiveMotions.removeData(motion); + mActiveMotions.remove(motion); return TRUE; } @@ -838,22 +811,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()); } @@ -871,15 +839,14 @@ LLMotion *LLMotionController::findMotion(const LLUUID& id) //----------------------------------------------------------------------------- void LLMotionController::flushAllMotions() { - LLDynamicArray<LLUUID> active_motions; - LLDynamicArray<F32> active_motion_times; - - for (LLMotion* motionp = mActiveMotions.getFirstData(); - motionp; - motionp = mActiveMotions.getNextData()) + std::vector<std::pair<LLUUID,F32> > active_motions; + active_motions.reserve(mActiveMotions.size()); + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ++iter) { - active_motions.put(motionp->getID()); - active_motion_times.put(mTime - motionp->mActivationTimestamp); + LLMotion* motionp = *iter; + F32 dtime = mTime - motionp->mActivationTimestamp; + active_motions.push_back(std::make_pair(motionp->getID(),dtime)); motionp->deactivate(); } @@ -891,9 +858,10 @@ void LLMotionController::flushAllMotions() mCharacter->removeAnimationData("Hand Pose"); // restart motions - for (S32 i = 0; i < active_motions.count(); i++) + for (std::vector<std::pair<LLUUID,F32> >::iterator iter = active_motions.begin(); + iter != active_motions.end(); ++iter) { - startMotion(active_motions[i], active_motion_times[i]); + startMotion(iter->first, iter->second); } } diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h index d43d6d9a8f..a19e704643 100644 --- a/indra/llcharacter/llmotioncontroller.h +++ b/indra/llcharacter/llmotioncontroller.h @@ -16,7 +16,6 @@ #include <map> #include <deque> -#include "linked_lists.h" #include "lluuidhashmap.h" #include "llmotion.h" #include "llpose.h" @@ -90,6 +89,10 @@ protected: class LLMotionController { public: + typedef std::list<LLMotion*> motion_list_t; + typedef std::set<LLMotion*> motion_set_t; + +public: // Constructor LLMotionController(); @@ -145,12 +148,11 @@ public: void setTimeFactor(F32 time_factor); F32 getTimeFactor() { return mTimeFactor; } - LLMotion* getFirstActiveMotion(); - LLMotion* getNextActiveMotion(); + motion_list_t& getActiveMotions() { return mActiveMotions; } //protected: - BOOL isMotionActive( LLMotion *motion ); - BOOL isMotionLoading( LLMotion *motion ); + bool isMotionActive( LLMotion *motion ); + bool isMotionLoading( LLMotion *motion ); LLMotion *findMotion( const LLUUID& id ); protected: @@ -180,9 +182,9 @@ protected: std::map<LLUUID, LLMotion*> mAllMotions; - LLLinkedList<LLMotion> mLoadingMotions; - std::deque<LLMotion*> mLoadedMotions; - LLLinkedList<LLMotion> mActiveMotions; + motion_set_t mLoadingMotions; + motion_list_t mLoadedMotions; + motion_list_t mActiveMotions; LLFrameTimer mTimer; F32 mTime; diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp index ff56dba585..e1b24d62cb 100644 --- a/indra/llcharacter/llpose.cpp +++ b/indra/llcharacter/llpose.cpp @@ -15,6 +15,7 @@ #include "llmotion.h" #include "llmath.h" +#include "llstl.h" //----------------------------------------------------------------------------- // Static @@ -438,7 +439,7 @@ LLPoseBlender::LLPoseBlender() LLPoseBlender::~LLPoseBlender() { - mJointStateBlenderPool.deleteAllData(); + for_each(mJointStateBlenderPool.begin(), mJointStateBlenderPool.end(), DeletePairedPointer()); } //----------------------------------------------------------------------------- @@ -452,15 +453,16 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) { LLJoint *jointp = jsp->getJoint(); LLJointStateBlender* joint_blender; - if (!mJointStateBlenderPool.checkData(jointp)) + if (mJointStateBlenderPool.find(jointp) == mJointStateBlenderPool.end()) { // this is the first time we are animating this joint // so create new jointblender and add it to our pool joint_blender = new LLJointStateBlender(); - mJointStateBlenderPool.addData(jointp, joint_blender); - } else + mJointStateBlenderPool[jointp] = joint_blender; + } + else { - joint_blender = mJointStateBlenderPool.getData(jointp); + joint_blender = mJointStateBlenderPool[jointp]; } if (jsp->getPriority() == LLJoint::USE_MOTION_PRIORITY) @@ -473,9 +475,9 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) } // add it to our list of active blenders - if(!mActiveBlenders.checkData(joint_blender)) + if (std::find(mActiveBlenders.begin(), mActiveBlenders.end(), joint_blender) == mActiveBlenders.end()) { - mActiveBlenders.addData(joint_blender); + mActiveBlenders.push_front(joint_blender); } } return TRUE; @@ -486,15 +488,15 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) //----------------------------------------------------------------------------- void LLPoseBlender::blendAndApply() { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; jsbp->blendJointStates(); } // we're done now so there are no more active blenders for this frame - mActiveBlenders.removeAllNodes(); + mActiveBlenders.clear(); } //----------------------------------------------------------------------------- @@ -502,10 +504,10 @@ void LLPoseBlender::blendAndApply() //----------------------------------------------------------------------------- void LLPoseBlender::blendAndCache(BOOL reset_cached_joints) { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; if (reset_cached_joints) { jsbp->resetCachedJoint(); @@ -519,10 +521,10 @@ void LLPoseBlender::blendAndCache(BOOL reset_cached_joints) //----------------------------------------------------------------------------- void LLPoseBlender::interpolate(F32 u) { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; jsbp->interpolate(u); } } @@ -532,13 +534,13 @@ void LLPoseBlender::interpolate(F32 u) //----------------------------------------------------------------------------- void LLPoseBlender::clearBlenders() { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; jsbp->clear(); } - mActiveBlenders.removeAllNodes(); + mActiveBlenders.clear(); } diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index e286c14e21..5d17bd8458 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -87,8 +87,10 @@ class LLMotion; class LLPoseBlender { protected: - LLMap<LLJoint*,LLJointStateBlender*> mJointStateBlenderPool; - LLLinkedList<LLJointStateBlender> mActiveBlenders; + typedef std::list<LLJointStateBlender*> blender_list_t; + typedef std::map<LLJoint*,LLJointStateBlender*> blender_map_t; + blender_map_t mJointStateBlenderPool; + blender_list_t mActiveBlenders; S32 mNextPoseSlot; LLPose mBlendedPose; |