From 52405bbe1bf647f3e53bca82a91e3e3f09c799ac Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 21 May 2016 22:04:39 +0300 Subject: [PATCH] Collada: Use C++11 range-based for loop --- code/ColladaLoader.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 9338452a5..7d8b29fbf 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -276,21 +276,20 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co resolved.reserve(pNode->mNodeInstances.size()); // ... and iterate through all nodes to be instanced as children of pNode - for (std::vector::const_iterator it = pNode->mNodeInstances.begin(), - end = pNode->mNodeInstances.end(); it != end; ++it) + for (const auto &nodeInst: pNode->mNodeInstances) { // find the corresponding node in the library - const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode); + const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find(nodeInst.mNode); const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second; // FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632 // need to check for both name and ID to catch all. To avoid breaking valid files, // the workaround is only enabled when the first attempt to resolve the node has failed. if (!nd) { - nd = FindNode(pParser.mRootNode,(*it).mNode); + nd = FindNode(pParser.mRootNode, nodeInst.mNode); } if (!nd) - DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode); + DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + nodeInst.mNode); else { // attach this node to the list of children @@ -1320,11 +1319,10 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser, // Fills materials from the collada material definitions void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pScene*/) { - for (std::vector >::iterator it = newMats.begin(), - end = newMats.end(); it != end; ++it) + for (auto &elem : newMats) { - aiMaterial& mat = (aiMaterial&)*it->second; - Collada::Effect& effect = *it->first; + aiMaterial& mat = (aiMaterial&)*elem.second; + Collada::Effect& effect = *elem.first; // resolve shading mode int shadeMode;