1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:59:54 +00:00

Code cleanup, fix missing const

This commit is contained in:
Sam Hellawell 2024-07-14 20:38:24 +01:00
parent df0a7a849b
commit db30d9a37a

View file

@ -413,18 +413,15 @@ namespace Resource
return; return;
std::vector<std::pair<std::string, std::string>> renameList; std::vector<std::pair<std::string, std::string>> renameList;
for (const auto& influence : *vertexInfluenceMap) for (const auto& [oldBoneName, _] : *vertexInfluenceMap)
{ {
const std::string& oldBoneName = influence.first; const std::string newBoneName = Misc::StringUtils::underscoresToSpaces(oldBoneName);
std::string newBoneName = Misc::StringUtils::underscoresToSpaces(oldBoneName);
if (newBoneName != oldBoneName) if (newBoneName != oldBoneName)
renameList.emplace_back(oldBoneName, newBoneName); renameList.emplace_back(oldBoneName, newBoneName);
} }
for (const auto& rename : renameList) for (const auto& [oldName, newName] : renameList)
{ {
const std::string& oldName = rename.first;
const std::string& newName = rename.second;
if (vertexInfluenceMap->find(newName) == vertexInfluenceMap->end()) if (vertexInfluenceMap->find(newName) == vertexInfluenceMap->end())
(*vertexInfluenceMap)[newName] = std::move((*vertexInfluenceMap)[oldName]); (*vertexInfluenceMap)[newName] = std::move((*vertexInfluenceMap)[oldName]);
vertexInfluenceMap->erase(oldName); vertexInfluenceMap->erase(oldName);
@ -433,16 +430,13 @@ namespace Resource
void renameAnimationChannelTargets(osgAnimation::BasicAnimationManager& animManager) void renameAnimationChannelTargets(osgAnimation::BasicAnimationManager& animManager)
{ {
for (const auto& animation : animManager.getAnimationList()) for (const osgAnimation::Animation* animation : animManager.getAnimationList())
{ {
if (animation) if (animation)
{ {
auto& channels = animation->getChannels(); const osgAnimation::ChannelList& channels = animation->getChannels();
for (auto& channel : channels) for (osgAnimation::Channel* channel : channels)
{ channel->setTargetName(Misc::StringUtils::underscoresToSpaces(channel->getTargetName()));
std::string newTargetName = Misc::StringUtils::underscoresToSpaces(channel->getTargetName());
channel->setTargetName(newTargetName);
}
} }
} }
} }
@ -696,7 +690,7 @@ namespace Resource
node->accept(rigFinder); node->accept(rigFinder);
// If a collada file with rigs, we should replace underscores with spaces // If a collada file with rigs, we should replace underscores with spaces
if (isColladaFile && rigFinder.mFoundNodes.size() > 0) if (isColladaFile && !rigFinder.mFoundNodes.empty())
{ {
ReplaceAnimationUnderscoresVisitor renamingVisitor; ReplaceAnimationUnderscoresVisitor renamingVisitor;
node->accept(renamingVisitor); node->accept(renamingVisitor);