From d0f115ae093e8268da2a3245d6cb2f3bcc544f1c Mon Sep 17 00:00:00 2001 From: Fawrsk Date: Thu, 5 Jan 2023 07:42:27 -0400 Subject: SL-18893 Cleanup for loops in llcharacter to use C++11 range based for loops (#42) --- indra/llcharacter/llkeyframemotionparam.cpp | 58 +++++++++++------------------ 1 file changed, 22 insertions(+), 36 deletions(-) (limited to 'indra/llcharacter/llkeyframemotionparam.cpp') diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index aba1c5db39..fce445fee7 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -64,13 +64,11 @@ LLKeyframeMotionParam::LLKeyframeMotionParam( const LLUUID &id) : LLMotion(id) //----------------------------------------------------------------------------- LLKeyframeMotionParam::~LLKeyframeMotionParam() { - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - motion_list_t& motionList = iter->second; - for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; delete paramMotion.mMotion; } motionList.clear(); @@ -90,13 +88,11 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch return STATUS_FAILURE; } - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - motion_list_t& motionList = iter->second; - for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; LLMotion* motion = paramMotion.mMotion; motion->onInitialize(character); @@ -139,13 +135,11 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch //----------------------------------------------------------------------------- BOOL LLKeyframeMotionParam::onActivate() { - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - motion_list_t& motionList = iter->second; - for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; paramMotion.mMotion->activate(mActivationTimestamp); } } @@ -162,23 +156,20 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) F32 weightFactor = 1.f / (F32)mParameterizedMotions.size(); // zero out all pose weights - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - motion_list_t& motionList = iter->second; - for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; // LL_INFOS() << "Weight for pose " << paramMotion.mMotion->getName() << " is " << paramMotion.mMotion->getPose()->getWeight() << LL_ENDL; paramMotion.mMotion->getPose()->setWeight(0.f); } } - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - const std::string& paramName = iter->first; + const std::string& paramName = motion_pair.first; F32* paramValue = (F32 *)mCharacter->getAnimationData(paramName); if (NULL == paramValue) // unexpected, but... { @@ -190,10 +181,9 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) 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) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; paramMotion.mMotion->onUpdate(time, joint_mask); F32 distToParam = paramMotion.mParam - *paramValue; @@ -280,13 +270,11 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLKeyframeMotionParam::onDeactivate() { - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - motion_list_t& motionList = iter->second; - for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; paramMotion.mMotion->onDeactivate(); } } @@ -318,13 +306,11 @@ BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char //----------------------------------------------------------------------------- void LLKeyframeMotionParam::setDefaultKeyframeMotion(char *name) { - for (motion_map_t::iterator iter = mParameterizedMotions.begin(); - iter != mParameterizedMotions.end(); ++iter) + for (motion_map_t::value_type motion_pair : mParameterizedMotions) { - motion_list_t& motionList = iter->second; - for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) + motion_list_t& motionList = motion_pair.second; + for (const ParameterizedMotion& paramMotion : motionList) { - const ParameterizedMotion& paramMotion = *iter2; if (paramMotion.mMotion->getName() == name) { mDefaultKeyframeMotion = paramMotion.mMotion; -- cgit v1.2.3 From 7419037ef6e8a5497283278baa8582b264d3aefa Mon Sep 17 00:00:00 2001 From: Fawrsk Date: Tue, 10 Jan 2023 05:43:27 -0400 Subject: SL-18893 Fixes for pull requests #38, #41, and #42 (#46) Eliminate unnecessary copies, and remove uses of auto --- indra/llcharacter/llkeyframemotionparam.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llcharacter/llkeyframemotionparam.cpp') diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index fce445fee7..c80aabe294 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -64,7 +64,7 @@ LLKeyframeMotionParam::LLKeyframeMotionParam( const LLUUID &id) : LLMotion(id) //----------------------------------------------------------------------------- LLKeyframeMotionParam::~LLKeyframeMotionParam() { - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { motion_list_t& motionList = motion_pair.second; for (const ParameterizedMotion& paramMotion : motionList) @@ -88,7 +88,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch return STATUS_FAILURE; } - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { motion_list_t& motionList = motion_pair.second; for (const ParameterizedMotion& paramMotion : motionList) @@ -135,7 +135,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch //----------------------------------------------------------------------------- BOOL LLKeyframeMotionParam::onActivate() { - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { motion_list_t& motionList = motion_pair.second; for (const ParameterizedMotion& paramMotion : motionList) @@ -156,7 +156,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) F32 weightFactor = 1.f / (F32)mParameterizedMotions.size(); // zero out all pose weights - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { motion_list_t& motionList = motion_pair.second; for (const ParameterizedMotion& paramMotion : motionList) @@ -167,7 +167,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) } - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { const std::string& paramName = motion_pair.first; F32* paramValue = (F32 *)mCharacter->getAnimationData(paramName); @@ -270,7 +270,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLKeyframeMotionParam::onDeactivate() { - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { motion_list_t& motionList = motion_pair.second; for (const ParameterizedMotion& paramMotion : motionList) @@ -306,7 +306,7 @@ BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char //----------------------------------------------------------------------------- void LLKeyframeMotionParam::setDefaultKeyframeMotion(char *name) { - for (motion_map_t::value_type motion_pair : mParameterizedMotions) + for (motion_map_t::value_type& motion_pair : mParameterizedMotions) { motion_list_t& motionList = motion_pair.second; for (const ParameterizedMotion& paramMotion : motionList) -- cgit v1.2.3