diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-03-11 01:47:36 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-03-11 01:47:36 +0000 |
commit | 377ae59c21215473cf05e3cb8a86eb14c9e7715c (patch) | |
tree | a8cb48901c3c30bc1c2ddfd5d8b2d0cab7c6c95d /indra/llcharacter | |
parent | 9d12bd5e273b8cb032e25574461a8b4528d96343 (diff) |
merge Branch_1-19-1-Viewer -r 80930 : 81609 -> release
DEV-11202: Unhandled Excpetion in pipeline.cpp.
Merged over updated windlight ui help text from windlight14.
Reverting a const change in a virtual that was not propagated to all overrides.
DEV-10957 stop and pause Media and music buttons do not work
DEV-10762 Displayed page in the client browser disappears when crossing property boundaries.
DEV-11220 replace misspellings in alerts.xml parameters of 'messsage'
DEV-11221 fix a misspelling of 'participants' in floater_chat_history.xml tooltip
DEV-11193 clean up some viewer strings related to Windlight help text
svn merge -r81144:81147 svn+ssh://svn/svn/linden/branches/1-19-1-viewer-threads
DEV-11110 Media browser history dropdown does not save items across sessions
Ran the xuiparse -process tool on all en-us xml files. This does NOT change any data, merely reorders attributes and cleans up tab/spacing.
DEV-11349 XML CLEANUP: fix duplicate sibling names in en-us xui files
DEV-11348 Change to llmimetypes.cpp broke Media Type dropdown
dev-10623 "parcels that played movies no longer work in combo-merge-ui"
DEV-11379 - crash in LLTabContainer::draw()
DEV-11377 Elminiate dangerous LLLinkedList and LLDoubleLinkedList from newview
DEV-11158 sculpties on the top10 crash list
DEV-11404 "Send Current URL to Parcel" does not set the MIME type
merge 80958:80959 maint-ui-9-qa, DEV-11105 -- Searching for people with 3 characters like "j l" hurts the database.
DEV-10489: no draw distance cheating
DEV-879: water noise frequency
DEV-10764: macbook air support
DEV-10878: Linux Intel945 support
DEV-7551: featuretable adjustments for framerate.
DEV-11426 Enormous mini-map.
DEV-11505 - Crash in gunzip_file.
Removed final LinkedList, SkipMap, and AssocList templates from the Viewer!
DEV-11115 truncated word in the Advanced Water Editor's modal help dialog
Diffstat (limited to 'indra/llcharacter')
-rw-r--r-- | indra/llcharacter/llcharacter.cpp | 26 | ||||
-rw-r--r-- | indra/llcharacter/llcharacter.h | 5 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotion.cpp | 237 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotion.h | 10 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotionparam.cpp | 149 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotionparam.h | 16 | ||||
-rw-r--r-- | indra/llcharacter/llpose.h | 2 | ||||
-rw-r--r-- | indra/llcharacter/llstatemachine.h | 1 |
8 files changed, 210 insertions, 236 deletions
diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index ff05b25fe9..ccc666e74d 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -241,33 +241,15 @@ void LLCharacter::dumpCharacter( LLJoint* joint ) //----------------------------------------------------------------------------- void LLCharacter::setAnimationData(std::string name, void *data) { - if(mAnimationData.getValue(name)) - { - *mAnimationData[name] = data; - } - else - { - mAnimationData.addToHead(name, data); - } + mAnimationData[name] = data; } //----------------------------------------------------------------------------- // getAnimationData() //----------------------------------------------------------------------------- -void * LLCharacter::getAnimationData(std::string name) +void* LLCharacter::getAnimationData(std::string name) { - void **result = mAnimationData.getValue(name); - void *return_value; // Necessary to suppress VC6 warning. JC - if (!result) - { - return_value = NULL; - } - else - { - return_value = *result; - } - - return return_value; + return get_if_there(mAnimationData, name, (void*)NULL); } //----------------------------------------------------------------------------- @@ -275,7 +257,7 @@ void * LLCharacter::getAnimationData(std::string name) //----------------------------------------------------------------------------- void LLCharacter::removeAnimationData(std::string name) { - mAnimationData.remove(name); + mAnimationData.erase(name); } //----------------------------------------------------------------------------- diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index eb001d5fc7..a5719b0685 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -39,9 +39,7 @@ #include "lljoint.h" #include "llmotioncontroller.h" -#include "llassoclist.h" #include "llvisualparam.h" -#include "linked_lists.h" #include "string_table.h" #include "llmemory.h" #include "llthread.h" @@ -255,7 +253,8 @@ public: protected: LLMotionController mMotionController; - LLAssocList<std::string, void *> mAnimationData; + typedef std::map<std::string, void *> animation_data_map_t; + animation_data_map_t mAnimationData; F32 mPreferredPelvisHeight; ESex mSex; diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 1d00f18f2d..91d96904ba 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -122,6 +122,7 @@ U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // ScaleCurve::ScaleCurve() //----------------------------------------------------------------------------- @@ -136,7 +137,7 @@ LLKeyframeMotion::ScaleCurve::ScaleCurve() //----------------------------------------------------------------------------- LLKeyframeMotion::ScaleCurve::~ScaleCurve() { - mKeys.deleteAllData(); + mKeys.clear(); mNumKeys = 0; } @@ -146,43 +147,42 @@ LLKeyframeMotion::ScaleCurve::~ScaleCurve() LLVector3 LLKeyframeMotion::ScaleCurve::getValue(F32 time, F32 duration) { LLVector3 value; - F32 index_before, index_after; - ScaleKey* scale_before; - ScaleKey* scale_after; - mKeys.getInterval(time, index_before, index_after, scale_before, scale_after); - if (scale_before) + if (mKeys.empty()) { - if (!scale_after) - { - scale_after = &mLoopInKey; - index_after = duration; - } - - if (index_after == index_before) - { - value = scale_after->mScale; - } - else - { - F32 u = (time - index_before) / (index_after - index_before); - value = interp(u, *scale_before, *scale_after); - } + value.clearVec(); + return value; + } + + key_map_t::iterator right = mKeys.lower_bound(time); + if (right == mKeys.end()) + { + // Past last key + --right; + value = right->second.mScale; + } + else if (right == mKeys.begin() || right->first == time) + { + // Before first key or exactly on a key + value = right->second.mScale; } else { - // before first key - if (scale_after) - { - value = scale_after->mScale; - } - // no keys? - else + // Between two keys + key_map_t::iterator left = right; --left; + F32 index_before = left->first; + F32 index_after = right->first; + ScaleKey& scale_before = left->second; + ScaleKey& scale_after = right->second; + if (right == mKeys.end()) { - value.clearVec(); + scale_after = mLoopInKey; + index_after = duration; } - } + F32 u = (time - index_before) / (index_after - index_before); + value = interp(u, scale_before, scale_after); + } return value; } @@ -217,7 +217,7 @@ LLKeyframeMotion::RotationCurve::RotationCurve() //----------------------------------------------------------------------------- LLKeyframeMotion::RotationCurve::~RotationCurve() { - mKeys.deleteAllData(); + mKeys.clear(); mNumKeys = 0; } @@ -227,44 +227,42 @@ LLKeyframeMotion::RotationCurve::~RotationCurve() LLQuaternion LLKeyframeMotion::RotationCurve::getValue(F32 time, F32 duration) { LLQuaternion value; - F32 index_before, index_after; - RotationKey* rot_before; - RotationKey* rot_after; - - mKeys.getInterval(time, index_before, index_after, rot_before, rot_after); - if (rot_before) + if (mKeys.empty()) { - if (!rot_after) - { - rot_after = &mLoopInKey; - index_after = duration; - } - - if (index_after == index_before) - { - value = rot_after->mRotation; - } - else - { - F32 u = (time - index_before) / (index_after - index_before); - value = interp(u, *rot_before, *rot_after); - } + value = LLQuaternion::DEFAULT; + return value; + } + + key_map_t::iterator right = mKeys.lower_bound(time); + if (right == mKeys.end()) + { + // Past last key + --right; + value = right->second.mRotation; + } + else if (right == mKeys.begin() || right->first == time) + { + // Before first key or exactly on a key + value = right->second.mRotation; } else { - // before first key - if (rot_after) + // Between two keys + key_map_t::iterator left = right; --left; + F32 index_before = left->first; + F32 index_after = right->first; + RotationKey& rot_before = left->second; + RotationKey& rot_after = right->second; + if (right == mKeys.end()) { - value = rot_after->mRotation; - } - // no keys? - else - { - value = LLQuaternion::DEFAULT; + rot_after = mLoopInKey; + index_after = duration; } - } + F32 u = (time - index_before) / (index_after - index_before); + value = interp(u, rot_before, rot_after); + } return value; } @@ -300,7 +298,7 @@ LLKeyframeMotion::PositionCurve::PositionCurve() //----------------------------------------------------------------------------- LLKeyframeMotion::PositionCurve::~PositionCurve() { - mKeys.deleteAllData(); + mKeys.clear(); mNumKeys = 0; } @@ -310,46 +308,45 @@ LLKeyframeMotion::PositionCurve::~PositionCurve() LLVector3 LLKeyframeMotion::PositionCurve::getValue(F32 time, F32 duration) { LLVector3 value; - F32 index_before, index_after; - PositionKey* pos_before; - PositionKey* pos_after; - mKeys.getInterval(time, index_before, index_after, pos_before, pos_after); - - if (pos_before) + if (mKeys.empty()) { - if (!pos_after) - { - pos_after = &mLoopInKey; - index_after = duration; - } - - if (index_after == index_before) - { - value = pos_after->mPosition; - } - else - { - F32 u = (time - index_before) / (index_after - index_before); - value = interp(u, *pos_before, *pos_after); - } + value.clearVec(); + return value; + } + + key_map_t::iterator right = mKeys.lower_bound(time); + if (right == mKeys.end()) + { + // Past last key + --right; + value = right->second.mPosition; + } + else if (right == mKeys.begin() || right->first == time) + { + // Before first key or exactly on a key + value = right->second.mPosition; } else { - // before first key - if (pos_after) - { - value = pos_after->mPosition; - } - // no keys? - else + // Between two keys + key_map_t::iterator left = right; --left; + F32 index_before = left->first; + F32 index_after = right->first; + PositionKey& pos_before = left->second; + PositionKey& pos_after = right->second; + if (right == mKeys.end()) { - value.clearVec(); + pos_after = mLoopInKey; + index_after = duration; } + + F32 u = (time - index_before) / (index_after - index_before); + value = interp(u, pos_before, pos_after); } llassert(value.isFinite()); - + return value; } @@ -1404,8 +1401,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) time = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); } - RotationKey *rot_key = new RotationKey; - rot_key->mTime = time; + RotationKey rot_key; + rot_key.mTime = time; LLVector3 rot_angles; U16 x, y, z; @@ -1416,7 +1413,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) success = dp.unpackVector3(rot_angles, "rot_angles"); LLQuaternion::Order ro = StringToOrder("ZYX"); - rot_key->mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro); + rot_key.mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro); } else { @@ -1428,13 +1425,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) rot_vec.mV[VX] = U16_to_F32(x, -1.f, 1.f); rot_vec.mV[VY] = U16_to_F32(y, -1.f, 1.f); rot_vec.mV[VZ] = U16_to_F32(z, -1.f, 1.f); - rot_key->mRotation.unpackFromVector3(rot_vec); + rot_key.mRotation.unpackFromVector3(rot_vec); } if (!success) { llwarns << "can't read rotation key (" << k << ")" << llendl; - delete rot_key; return FALSE; } @@ -1464,14 +1460,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) for (S32 k = 0; k < joint_motion->mPositionCurve.mNumKeys; k++) { U16 time_short; - PositionKey* pos_key = new PositionKey; + PositionKey pos_key; if (old_version) { - if (!dp.unpackF32(pos_key->mTime, "time")) + if (!dp.unpackF32(pos_key.mTime, "time")) { llwarns << "can't read position key (" << k << ")" << llendl; - delete pos_key; return FALSE; } } @@ -1480,18 +1475,17 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (!dp.unpackU16(time_short, "time")) { llwarns << "can't read position key (" << k << ")" << llendl; - delete pos_key; return FALSE; } - pos_key->mTime = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); + pos_key.mTime = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); } BOOL success = TRUE; if (old_version) { - success = dp.unpackVector3(pos_key->mPosition, "pos"); + success = dp.unpackVector3(pos_key.mPosition, "pos"); } else { @@ -1501,23 +1495,22 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) success &= dp.unpackU16(y, "pos_y"); success &= dp.unpackU16(z, "pos_z"); - pos_key->mPosition.mV[VX] = U16_to_F32(x, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); - pos_key->mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); - pos_key->mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + pos_key.mPosition.mV[VX] = U16_to_F32(x, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + pos_key.mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + pos_key.mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); } if (!success) { llwarns << "can't read position key (" << k << ")" << llendl; - delete pos_key; return FALSE; } - pCurve->mKeys[pos_key->mTime] = pos_key; + pCurve->mKeys[pos_key.mTime] = pos_key; if (is_pelvis) { - mJointMotionList->mPelvisBBox.addPoint(pos_key->mPosition); + mJointMotionList->mPelvisBBox.addPoint(pos_key.mPosition); } } @@ -1724,14 +1717,14 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packS32(joint_motionp->mPriority, "joint_priority"); success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys"); - for (RotationKey* rot_keyp = joint_motionp->mRotationCurve.mKeys.getFirstData(); - rot_keyp; - rot_keyp = joint_motionp->mRotationCurve.mKeys.getNextData()) + for (RotationCurve::key_map_t::iterator iter = joint_motionp->mRotationCurve.mKeys.begin(); + iter != joint_motionp->mRotationCurve.mKeys.end(); ++iter) { - U16 time_short = F32_to_U16(rot_keyp->mTime, 0.f, mJointMotionList->mDuration); + RotationKey& rot_key = iter->second; + U16 time_short = F32_to_U16(rot_key.mTime, 0.f, mJointMotionList->mDuration); success &= dp.packU16(time_short, "time"); - LLVector3 rot_angles = rot_keyp->mRotation.packToVector3(); + LLVector3 rot_angles = rot_key.mRotation.packToVector3(); U16 x, y, z; rot_angles.quantize16(-1.f, 1.f, -1.f, 1.f); @@ -1744,18 +1737,18 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const } success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys"); - for (PositionKey* pos_keyp = joint_motionp->mPositionCurve.mKeys.getFirstData(); - pos_keyp; - pos_keyp = joint_motionp->mPositionCurve.mKeys.getNextData()) + for (PositionCurve::key_map_t::iterator iter = joint_motionp->mPositionCurve.mKeys.begin(); + iter != joint_motionp->mPositionCurve.mKeys.end(); ++iter) { - U16 time_short = F32_to_U16(pos_keyp->mTime, 0.f, mJointMotionList->mDuration); + PositionKey& pos_key = iter->second; + U16 time_short = F32_to_U16(pos_key.mTime, 0.f, mJointMotionList->mDuration); success &= dp.packU16(time_short, "time"); U16 x, y, z; - pos_keyp->mPosition.quantize16(-LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); - x = F32_to_U16(pos_keyp->mPosition.mV[VX], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); - y = F32_to_U16(pos_keyp->mPosition.mV[VY], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); - z = F32_to_U16(pos_keyp->mPosition.mV[VZ], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + pos_key.mPosition.quantize16(-LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + x = F32_to_U16(pos_key.mPosition.mV[VX], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + y = F32_to_U16(pos_key.mPosition.mV[VY], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + z = F32_to_U16(pos_key.mPosition.mV[VZ], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); success &= dp.packU16(x, "pos_x"); success &= dp.packU16(y, "pos_y"); success &= dp.packU16(z, "pos_z"); diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 8d6ebbf4b7..c383e5e99e 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -43,7 +43,6 @@ #include "llhandmotion.h" #include "lljointstate.h" #include "llmotion.h" -#include "llptrskipmap.h" #include "llquaternion.h" #include "v3dmath.h" #include "v3math.h" @@ -338,7 +337,8 @@ public: InterpolationType mInterpolationType; S32 mNumKeys; - LLPtrSkipMap<F32, ScaleKey*> mKeys; + typedef std::map<F32, ScaleKey> key_map_t; + key_map_t mKeys; ScaleKey mLoopInKey; ScaleKey mLoopOutKey; }; @@ -356,7 +356,8 @@ public: InterpolationType mInterpolationType; S32 mNumKeys; - LLPtrSkipMap<F32, RotationKey*> mKeys; + typedef std::map<F32, RotationKey> key_map_t; + key_map_t mKeys; RotationKey mLoopInKey; RotationKey mLoopOutKey; }; @@ -374,7 +375,8 @@ public: InterpolationType mInterpolationType; S32 mNumKeys; - LLPtrSkipMap<F32, PositionKey*> mKeys; + typedef std::map<F32, PositionKey> key_map_t; + key_map_t mKeys; PositionKey mLoopInKey; PositionKey mLoopOutKey; }; diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index f54d1f4a83..30edc29c6e 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -48,14 +48,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -// sortFunc() -//----------------------------------------------------------------------------- -BOOL LLKeyframeMotionParam::sortFunc(ParameterizedMotion *new_motion, ParameterizedMotion *tested_motion) -{ - return (new_motion->second < tested_motion->second); -} - -//----------------------------------------------------------------------------- // LLKeyframeMotionParam() // Class Constructor //----------------------------------------------------------------------------- @@ -77,17 +69,18 @@ LLKeyframeMotionParam::LLKeyframeMotionParam( const LLUUID &id) : LLMotion(id) //----------------------------------------------------------------------------- LLKeyframeMotionParam::~LLKeyframeMotionParam() { - for (U32 i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { - delete paramMotion->first; + const ParameterizedMotion& paramMotion = *iter2; + delete paramMotion.first; // note - deletes the structure; ParameterizedMotion pair remains intact } - delete motionList; + motionList.clear(); } - - mParameterizedMotions.removeAll(); + mParameterizedMotions.clear(); } //----------------------------------------------------------------------------- @@ -102,36 +95,39 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch return STATUS_FAILURE; } - for (U32 i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { - paramMotion->first->onInitialize(character); + const ParameterizedMotion& paramMotion = *iter2; - if (paramMotion->first->getDuration() > mEaseInDuration) + paramMotion.first->onInitialize(character); + + if (paramMotion.first->getDuration() > mEaseInDuration) { - mEaseInDuration = paramMotion->first->getEaseInDuration(); + mEaseInDuration = paramMotion.first->getEaseInDuration(); } - if (paramMotion->first->getEaseOutDuration() > mEaseOutDuration) + if (paramMotion.first->getEaseOutDuration() > mEaseOutDuration) { - mEaseOutDuration = paramMotion->first->getEaseOutDuration(); + mEaseOutDuration = paramMotion.first->getEaseOutDuration(); } - if (paramMotion->first->getDuration() > mDuration) + if (paramMotion.first->getDuration() > mDuration) { - mDuration = paramMotion->first->getDuration(); + mDuration = paramMotion.first->getDuration(); } - if (paramMotion->first->getPriority() > mPriority) + if (paramMotion.first->getPriority() > mPriority) { - mPriority = paramMotion->first->getPriority(); + mPriority = paramMotion.first->getPriority(); } - LLPose *pose = paramMotion->first->getPose(); + LLPose *pose = paramMotion.first->getPose(); - mPoseBlender.addMotion(paramMotion->first); + mPoseBlender.addMotion(paramMotion.first); for (LLJointState *jsp = pose->getFirstJointState(); jsp; jsp = pose->getNextJointState()) { LLPose *blendedPose = mPoseBlender.getBlendedPose(); @@ -148,12 +144,14 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch //----------------------------------------------------------------------------- BOOL LLKeyframeMotionParam::onActivate() { - for (U32 i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { - paramMotion->first->activate(); + const ParameterizedMotion& paramMotion = *iter2; + paramMotion.first->activate(); } } return TRUE; @@ -165,46 +163,48 @@ BOOL LLKeyframeMotionParam::onActivate() //----------------------------------------------------------------------------- BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) { - F32 weightFactor = 1.f / (F32)mParameterizedMotions.length(); - U32 i; + F32 weightFactor = 1.f / (F32)mParameterizedMotions.size(); // zero out all pose weights - for (i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { -// llinfos << "Weight for pose " << paramMotion->first->getName() << " is " << paramMotion->first->getPose()->getWeight() << llendl; - paramMotion->first->getPose()->setWeight(0.f); + const ParameterizedMotion& paramMotion = *iter2; +// llinfos << "Weight for pose " << paramMotion.first->getName() << " is " << paramMotion.first->getPose()->getWeight() << llendl; + paramMotion.first->getPose()->setWeight(0.f); } } - for (i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - std::string *paramName = mParameterizedMotions.getIndexAt(i); - F32* paramValue = (F32 *)mCharacter->getAnimationData(*paramName); - ParameterizedMotion* firstMotion = NULL; - ParameterizedMotion* secondMotion = NULL; - + const std::string& paramName = iter->first; + F32* paramValue = (F32 *)mCharacter->getAnimationData(paramName); if (NULL == paramValue) // unexpected, but... { llwarns << "paramValue == NULL" << llendl; continue; } - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + const ParameterizedMotion* firstMotion = NULL; + const ParameterizedMotion* secondMotion = NULL; + + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { - paramMotion->first->onUpdate(time, joint_mask); + const ParameterizedMotion& paramMotion = *iter2; + paramMotion.first->onUpdate(time, joint_mask); - F32 distToParam = paramMotion->second - *paramValue; + F32 distToParam = paramMotion.second - *paramValue; if ( distToParam <= 0.f) { // keep track of the motion closest to the parameter value - firstMotion = paramMotion; + firstMotion = ¶mMotion; } else { @@ -212,13 +212,13 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) // so store the first motion we find as the second one we want to blend... if (firstMotion && !secondMotion ) { - secondMotion = paramMotion; + secondMotion = ¶mMotion; } //...or, if we've seen no other motion so far, make sure we blend to this only else if (!firstMotion) { - firstMotion = paramMotion; - secondMotion = paramMotion; + firstMotion = ¶mMotion; + secondMotion = ¶mMotion; } } } @@ -283,12 +283,14 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLKeyframeMotionParam::onDeactivate() { - for (U32 i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { - paramMotion->first->onDeactivate(); + const ParameterizedMotion& paramMotion = *iter2; + paramMotion.first->onDeactivate(); } } } @@ -307,23 +309,8 @@ BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char newMotion->setName(name); - // make sure a list of motions exists for this parameter - LLLinkedList< ParameterizedMotion > *motionList; - if (mParameterizedMotions.getValue(param)) - { - motionList = *mParameterizedMotions.getValue(param); - } - else - { - motionList = new LLLinkedList< ParameterizedMotion >; - motionList->setInsertBefore(sortFunc); - mParameterizedMotions.addToHead(param, motionList); - } - // now add motion to this list - ParameterizedMotion *parameterizedMotion = new ParameterizedMotion(newMotion, value); - - motionList->addDataSorted(parameterizedMotion); + mParameterizedMotions[param].insert(ParameterizedMotion(newMotion, value)); return TRUE; } @@ -334,14 +321,16 @@ BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char //----------------------------------------------------------------------------- void LLKeyframeMotionParam::setDefaultKeyframeMotion(char *name) { - for (U32 i = 0; i < mParameterizedMotions.length(); i++) + for (motion_map_t::iterator iter = mParameterizedMotions.begin(); + iter != mParameterizedMotions.end(); ++iter) { - LLLinkedList< ParameterizedMotion > *motionList = *mParameterizedMotions.getValueAt(i); - for (ParameterizedMotion* paramMotion = motionList->getFirstData(); paramMotion; paramMotion = motionList->getNextData()) + motion_list_t& motionList = iter->second; + for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { - if (paramMotion->first->getName() == name) + const ParameterizedMotion& paramMotion = *iter2; + if (paramMotion.first->getName() == name) { - mDefaultKeyframeMotion = paramMotion->first; + mDefaultKeyframeMotion = paramMotion.first; } } } diff --git a/indra/llcharacter/llkeyframemotionparam.h b/indra/llcharacter/llkeyframemotionparam.h index 39a02aea25..305207eb09 100644 --- a/indra/llcharacter/llkeyframemotionparam.h +++ b/indra/llcharacter/llkeyframemotionparam.h @@ -143,8 +143,20 @@ protected: // Member Data //------------------------------------------------------------------------- - typedef LLLinkedList < ParameterizedMotion > motion_list_t; - LLAssocList <std::string, motion_list_t* > mParameterizedMotions; + struct compare_motions + { + bool operator() (const ParameterizedMotion& a, const ParameterizedMotion& b) const + { + if (a.second != b.second) + return (a.second < b.second); + else + return a.first < b.first; + } + }; + + typedef std::set < ParameterizedMotion, compare_motions > motion_list_t; + typedef std::map <std::string, motion_list_t > motion_map_t; + motion_map_t mParameterizedMotions; LLMotion* mDefaultKeyframeMotion; LLCharacter* mCharacter; LLPoseBlender mPoseBlender; diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index 5ba579a167..0c71fd77b3 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -37,10 +37,8 @@ //----------------------------------------------------------------------------- #include <string> -#include "linked_lists.h" #include "llmap.h" #include "lljointstate.h" -#include "llassoclist.h" #include "lljoint.h" #include <map> diff --git a/indra/llcharacter/llstatemachine.h b/indra/llcharacter/llstatemachine.h index 6983729147..c19a926dbb 100644 --- a/indra/llcharacter/llstatemachine.h +++ b/indra/llcharacter/llstatemachine.h @@ -34,7 +34,6 @@ #include <string> -#include "llassoclist.h" #include "llerror.h" #include <map> |