diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2023-06-01 09:56:41 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2023-06-01 09:56:41 -0400 |
commit | 7d05ade3f10563e8c202106e00cb3d273ab13338 (patch) | |
tree | 349ecda36a5a561d6e564e2cc3db39121fd8946b /indra/llappearance/llavatarappearance.cpp | |
parent | ed92f1d8034dcaa84f808b3267c772202e7ce113 (diff) | |
parent | 5a70639b7992842a9f74ec81b11bac56608b8f2e (diff) |
SL-18330: Merge branch 'main' of secondlife/viewer into xcode-14.3
Diffstat (limited to 'indra/llappearance/llavatarappearance.cpp')
-rw-r--r-- | indra/llappearance/llavatarappearance.cpp | 136 |
1 files changed, 39 insertions, 97 deletions
diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp index c1336fd612..7946a3e705 100644 --- a/indra/llappearance/llavatarappearance.cpp +++ b/indra/llappearance/llavatarappearance.cpp @@ -214,12 +214,10 @@ void LLAvatarAppearance::initInstance() mRoot = createAvatarJoint(); mRoot->setName( "mRoot" ); - for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = sAvatarDictionary->getMeshEntries().begin(); - iter != sAvatarDictionary->getMeshEntries().end(); - ++iter) + for (const LLAvatarAppearanceDictionary::MeshEntries::value_type& mesh_pair : sAvatarDictionary->getMeshEntries()) { - const EMeshIndex mesh_index = iter->first; - const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = iter->second; + const EMeshIndex mesh_index = mesh_pair.first; + const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = mesh_pair.second; LLAvatarJoint* joint = createAvatarJoint(); joint->setName(mesh_dict->mName); joint->setMeshID(mesh_index); @@ -260,21 +258,16 @@ void LLAvatarAppearance::initInstance() //------------------------------------------------------------------------- // associate baked textures with meshes //------------------------------------------------------------------------- - for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = sAvatarDictionary->getMeshEntries().begin(); - iter != sAvatarDictionary->getMeshEntries().end(); - ++iter) + for (const LLAvatarAppearanceDictionary::MeshEntries::value_type& mesh_pair : sAvatarDictionary->getMeshEntries()) { - const EMeshIndex mesh_index = iter->first; - const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = iter->second; + const EMeshIndex mesh_index = mesh_pair.first; + const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = mesh_pair.second; const EBakedTextureIndex baked_texture_index = mesh_dict->mBakedID; // Skip it if there's no associated baked texture. if (baked_texture_index == BAKED_NUM_INDICES) continue; - for (avatar_joint_mesh_list_t::iterator iter = mMeshLOD[mesh_index]->mMeshParts.begin(); - iter != mMeshLOD[mesh_index]->mMeshParts.end(); - ++iter) + for (LLAvatarJointMesh* mesh : mMeshLOD[mesh_index]->mMeshParts) { - LLAvatarJointMesh* mesh = (*iter); mBakedTextureDatas[(S32)baked_texture_index].mJointMeshes.push_back(mesh); } } @@ -297,10 +290,8 @@ LLAvatarAppearance::~LLAvatarAppearance() delete_and_clear(mBakedTextureDatas[i].mTexLayerSet); mBakedTextureDatas[i].mJointMeshes.clear(); - for (morph_list_t::iterator iter2 = mBakedTextureDatas[i].mMaskedMorphs.begin(); - iter2 != mBakedTextureDatas[i].mMaskedMorphs.end(); iter2++) + for (LLMaskedMorph* masked_morph : mBakedTextureDatas[i].mMaskedMorphs) { - LLMaskedMorph* masked_morph = (*iter2); delete masked_morph; } } @@ -319,11 +310,8 @@ LLAvatarAppearance::~LLAvatarAppearance() std::for_each(mPolyMeshes.begin(), mPolyMeshes.end(), DeletePairedPointer()); mPolyMeshes.clear(); - for (avatar_joint_list_t::iterator jointIter = mMeshLOD.begin(); - jointIter != mMeshLOD.end(); - ++jointIter) + for (LLAvatarJoint* joint : mMeshLOD) { - LLAvatarJoint* joint = *jointIter; std::for_each(joint->mMeshParts.begin(), joint->mMeshParts.end(), DeletePointer()); joint->mMeshParts.clear(); } @@ -477,10 +465,9 @@ void LLAvatarAppearance::compareJointStateMaps(joint_state_map_t& last_state, if (!last_state.empty() && (last_state != curr_state)) { S32 diff_count = 0; - joint_state_map_t::iterator it; - for (it=last_state.begin(); it != last_state.end(); ++it) + for (joint_state_map_t::value_type& pair : last_state) { - const std::string& key = it->first; + const std::string& key = pair.first; if (last_state[key] != curr_state[key]) { LL_DEBUGS("AvatarBodySize") << "BodySize change " << key << " " << last_state[key] << "->" << curr_state[key] << LL_ENDL; @@ -690,10 +677,8 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent // setup children - LLAvatarBoneInfo::bones_t::const_iterator iter; - for (iter = info->mChildren.begin(); iter != info->mChildren.end(); ++iter) + for (LLAvatarBoneInfo* child_info : info->mChildren) { - LLAvatarBoneInfo *child_info = *iter; if (!setupBone(child_info, joint, volume_num, joint_num)) { return FALSE; @@ -745,10 +730,8 @@ BOOL LLAvatarAppearance::buildSkeleton(const LLAvatarSkeletonInfo *info) S32 current_joint_num = 0; S32 current_volume_num = 0; - LLAvatarSkeletonInfo::bone_info_list_t::const_iterator iter; - for (iter = info->mBoneInfoList.begin(); iter != info->mBoneInfoList.end(); ++iter) + for (LLAvatarBoneInfo* bone_info : info->mBoneInfoList) { - LLAvatarBoneInfo *bone_info = *iter; if (!setupBone(bone_info, NULL, current_volume_num, current_joint_num)) { LL_ERRS() << "Error parsing bone in skeleton file" << LL_ENDL; @@ -826,14 +809,10 @@ void LLAvatarAppearance::buildCharacter() //------------------------------------------------------------------------- // clear mesh data //------------------------------------------------------------------------- - for (avatar_joint_list_t::iterator jointIter = mMeshLOD.begin(); - jointIter != mMeshLOD.end(); ++jointIter) + for (LLAvatarJoint* joint : mMeshLOD) { - LLAvatarJoint* joint = *jointIter; - for (avatar_joint_mesh_list_t::iterator meshIter = joint->mMeshParts.begin(); - meshIter != joint->mMeshParts.end(); ++meshIter) + for (LLAvatarJointMesh* mesh : joint->mMeshParts) { - LLAvatarJointMesh * mesh = *meshIter; mesh->setMesh(NULL); } } @@ -1007,12 +986,8 @@ BOOL LLAvatarAppearance::loadAvatar() } // avatar_lad.xml : <morph_masks> - for (LLAvatarXmlInfo::morph_info_list_t::iterator iter = sAvatarXmlInfo->mMorphMaskInfoList.begin(); - iter != sAvatarXmlInfo->mMorphMaskInfoList.end(); - ++iter) + for (LLAvatarXmlInfo::LLAvatarMorphInfo* info : sAvatarXmlInfo->mMorphMaskInfoList) { - LLAvatarXmlInfo::LLAvatarMorphInfo *info = *iter; - EBakedTextureIndex baked = sAvatarDictionary->findBakedByRegionName(info->mRegion); if (baked != BAKED_NUM_INDICES) { @@ -1031,11 +1006,8 @@ BOOL LLAvatarAppearance::loadAvatar() loadLayersets(); // avatar_lad.xml : <driver_parameters> - for (LLAvatarXmlInfo::driver_info_list_t::iterator iter = sAvatarXmlInfo->mDriverInfoList.begin(); - iter != sAvatarXmlInfo->mDriverInfoList.end(); - ++iter) + for (LLDriverParamInfo* info : sAvatarXmlInfo->mDriverInfoList) { - LLDriverParamInfo *info = *iter; LLDriverParam* driver_param = new LLDriverParam( this ); if (driver_param->setInfo(info)) { @@ -1067,11 +1039,8 @@ BOOL LLAvatarAppearance::loadSkeletonNode () mRoot->addChild( mSkeleton[0] ); // make meshes children before calling parent version of the function - for (avatar_joint_list_t::iterator iter = mMeshLOD.begin(); - iter != mMeshLOD.end(); - ++iter) + for (LLAvatarJoint* joint : mMeshLOD) { - LLAvatarJoint *joint = *iter; joint->mUpdateXform = FALSE; joint->setMeshesToChildren(); } @@ -1103,12 +1072,9 @@ BOOL LLAvatarAppearance::loadSkeletonNode () // SKELETAL DISTORTIONS { - LLAvatarXmlInfo::skeletal_distortion_info_list_t::iterator iter; - for (iter = sAvatarXmlInfo->mSkeletalDistortionInfoList.begin(); - iter != sAvatarXmlInfo->mSkeletalDistortionInfoList.end(); - ++iter) + for (LLViewerVisualParamInfo* visual_param_info : sAvatarXmlInfo->mSkeletalDistortionInfoList) { - LLPolySkeletalDistortionInfo *info = (LLPolySkeletalDistortionInfo*)*iter; + LLPolySkeletalDistortionInfo *info = (LLPolySkeletalDistortionInfo*)visual_param_info; LLPolySkeletalDistortion *param = new LLPolySkeletalDistortion(this); if (!param->setInfo(info)) { @@ -1132,11 +1098,8 @@ BOOL LLAvatarAppearance::loadSkeletonNode () //----------------------------------------------------------------------------- BOOL LLAvatarAppearance::loadMeshNodes() { - for (LLAvatarXmlInfo::mesh_info_list_t::const_iterator meshinfo_iter = sAvatarXmlInfo->mMeshInfoList.begin(); - meshinfo_iter != sAvatarXmlInfo->mMeshInfoList.end(); - ++meshinfo_iter) + for (const LLAvatarXmlInfo::LLAvatarMeshInfo* info : sAvatarXmlInfo->mMeshInfoList) { - const LLAvatarXmlInfo::LLAvatarMeshInfo *info = *meshinfo_iter; const std::string &type = info->mType; S32 lod = info->mLOD; @@ -1148,12 +1111,10 @@ BOOL LLAvatarAppearance::loadMeshNodes() switch(lod) case 0: mesh = &mHairMesh0; */ - for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator mesh_iter = sAvatarDictionary->getMeshEntries().begin(); - mesh_iter != sAvatarDictionary->getMeshEntries().end(); - ++mesh_iter) + for (const LLAvatarAppearanceDictionary::MeshEntries::value_type& mesh_pair : sAvatarDictionary->getMeshEntries()) { - const EMeshIndex mesh_index = mesh_iter->first; - const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = mesh_iter->second; + const EMeshIndex mesh_index = mesh_pair.first; + const LLAvatarAppearanceDictionary::MeshEntry *mesh_dict = mesh_pair.second; if (type.compare(mesh_dict->mName) == 0) { mesh_id = mesh_index; @@ -1221,20 +1182,17 @@ BOOL LLAvatarAppearance::loadMeshNodes() mesh->setMesh( poly_mesh ); mesh->setLOD( info->mMinPixelArea ); - for (LLAvatarXmlInfo::LLAvatarMeshInfo::morph_info_list_t::const_iterator xmlinfo_iter = info->mPolyMorphTargetInfoList.begin(); - xmlinfo_iter != info->mPolyMorphTargetInfoList.end(); - ++xmlinfo_iter) + for (const LLAvatarXmlInfo::LLAvatarMeshInfo::morph_info_pair_t& info_pair : info->mPolyMorphTargetInfoList) { - const LLAvatarXmlInfo::LLAvatarMeshInfo::morph_info_pair_t *info_pair = &(*xmlinfo_iter); LLPolyMorphTarget *param = new LLPolyMorphTarget(mesh->getMesh()); - if (!param->setInfo((LLPolyMorphTargetInfo*)info_pair->first)) + if (!param->setInfo((LLPolyMorphTargetInfo*)info_pair.first)) { delete param; return FALSE; } else { - if (info_pair->second) + if (info_pair.second) { addSharedVisualParam(param); param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER); @@ -1257,11 +1215,8 @@ BOOL LLAvatarAppearance::loadMeshNodes() BOOL LLAvatarAppearance::loadLayersets() { BOOL success = TRUE; - for (LLAvatarXmlInfo::layer_info_list_t::const_iterator layerset_iter = sAvatarXmlInfo->mLayerInfoList.begin(); - layerset_iter != sAvatarXmlInfo->mLayerInfoList.end(); - ++layerset_iter) + for (LLTexLayerSetInfo* layerset_info : sAvatarXmlInfo->mLayerInfoList) { - LLTexLayerSetInfo *layerset_info = *layerset_iter; if (isSelf()) { // Construct a layerset for each one specified in avatar_lad.xml and initialize it as such. @@ -1277,14 +1232,12 @@ BOOL LLAvatarAppearance::loadLayersets() // scan baked textures and associate the layerset with the appropriate one EBakedTextureIndex baked_index = BAKED_NUM_INDICES; - for (LLAvatarAppearanceDictionary::BakedTextures::const_iterator baked_iter = sAvatarDictionary->getBakedTextures().begin(); - baked_iter != sAvatarDictionary->getBakedTextures().end(); - ++baked_iter) + for (const LLAvatarAppearanceDictionary::BakedTextures::value_type& baked_pair : sAvatarDictionary->getBakedTextures()) { - const LLAvatarAppearanceDictionary::BakedEntry *baked_dict = baked_iter->second; + const LLAvatarAppearanceDictionary::BakedEntry *baked_dict = baked_pair.second; if (layer_set->isBodyRegion(baked_dict->mName)) { - baked_index = baked_iter->first; + baked_index = baked_pair.first; // ensure both structures are aware of each other mBakedTextureDatas[baked_index].mTexLayerSet = layer_set; layer_set->setBakedTexIndex(baked_index); @@ -1300,11 +1253,8 @@ BOOL LLAvatarAppearance::loadLayersets() } // scan morph masks and let any affected layers know they have an associated morph - for (LLAvatarAppearance::morph_list_t::const_iterator morph_iter = mBakedTextureDatas[baked_index].mMaskedMorphs.begin(); - morph_iter != mBakedTextureDatas[baked_index].mMaskedMorphs.end(); - ++morph_iter) + for (LLMaskedMorph* morph : mBakedTextureDatas[baked_index].mMaskedMorphs) { - LLMaskedMorph *morph = *morph_iter; LLTexLayerInterface* layer = layer_set->findLayerByName(morph->mLayer); if (layer) { @@ -1320,7 +1270,6 @@ BOOL LLAvatarAppearance::loadLayersets() else // !isSelf() { // Construct a layerset for each one specified in avatar_lad.xml and initialize it as such. - LLTexLayerSetInfo *layerset_info = *layerset_iter; layerset_info->createVisualParams(this); } } @@ -1747,13 +1696,13 @@ void LLAvatarAppearance::makeJointAliases(LLAvatarBoneInfo *bone_info) boost::char_separator<char> sep(" "); boost::tokenizer<boost::char_separator<char> > tok(aliases, sep); - for(boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i) + for(const std::string& i : tok) { - if ( mJointAliasMap.find(*i) != mJointAliasMap.end() ) + if ( mJointAliasMap.find(i) != mJointAliasMap.end() ) { - LL_WARNS() << "avatar skeleton: Joint alias \"" << *i << "\" remapped from " << mJointAliasMap[*i] << " to " << bone_name << LL_ENDL; + LL_WARNS() << "avatar skeleton: Joint alias \"" << i << "\" remapped from " << mJointAliasMap[i] << " to " << bone_name << LL_ENDL; } - mJointAliasMap[*i] = bone_name; + mJointAliasMap[i] = bone_name; } for (LLAvatarBoneInfo* bone : bone_info->mChildren) @@ -1768,21 +1717,14 @@ const LLAvatarAppearance::joint_alias_map_t& LLAvatarAppearance::getJointAliases if (mJointAliasMap.empty()) { - LLAvatarSkeletonInfo::bone_info_list_t::const_iterator iter; - for (iter = sAvatarSkeletonInfo->mBoneInfoList.begin(); - iter != sAvatarSkeletonInfo->mBoneInfoList.end(); - ++iter) + for (LLAvatarBoneInfo* bone_info : sAvatarSkeletonInfo->mBoneInfoList) { //LLAvatarBoneInfo *bone_info = *iter; - makeJointAliases( *iter ); + makeJointAliases(bone_info); } - LLAvatarXmlInfo::attachment_info_list_t::iterator attach_iter; - for (attach_iter = sAvatarXmlInfo->mAttachmentInfoList.begin(); - attach_iter != sAvatarXmlInfo->mAttachmentInfoList.end(); - ++attach_iter) + for (LLAvatarXmlInfo::LLAvatarAttachmentInfo* info : sAvatarXmlInfo->mAttachmentInfoList) { - LLAvatarXmlInfo::LLAvatarAttachmentInfo *info = *attach_iter; std::string bone_name = info->mName; // Also accept the name with spaces substituted with |